mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-04 20:25:16 +03:00
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:
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user