fix(node): apply the client gate to emails with non-ASCII capitals

The node client gate loaded the records it judges with LOWER(email) IN
the lowered reported emails, but SQLite's LOWER folds ASCII only. For a
stored email such as Иван no record was found, so the node's claim was
treated as a new client and passed untouched, rewriting a client that
lives only on the master's inbounds.

The lookup matches the lowered or the stored spellings, as the shared
email checks already do.
This commit is contained in:
MHSanaei
2026-11-01 13:12:15 +01:00
parent 4cddcff12b
commit 828855cdb5
2 changed files with 25 additions and 4 deletions
+5 -4
View File
@@ -84,14 +84,15 @@ func loadNodeClientClaims(tx *gorm.DB, nodeID int, snap *runtime.TrafficSnapshot
return claims, nil
}
lowered := make([]string, 0, len(subIDByEmail))
reported := make([]string, 0, len(subIDByEmail))
for email := range subIDByEmail {
lowered = append(lowered, strings.ToLower(email))
reported = append(reported, email)
}
// SQLite's LOWER folds ASCII only, so a non-ASCII capital is matched by its spellings too.
var records []model.ClientRecord
for _, batch := range chunkStrings(uniqueNonEmptyStrings(lowered), sqlInChunk) {
for _, batch := range chunkStrings(emailSpellings(reported), sqlInChunk) {
var rows []model.ClientRecord
if err := tx.Where("LOWER(email) IN ?", batch).Find(&rows).Error; err != nil {
if err := tx.Where("LOWER(email) IN ? OR email IN ?", batch, batch).Find(&rows).Error; err != nil {
return nil, err
}
records = append(records, rows...)