Skip to content

Commit 78428d4

Browse files
committed
fix(geodns): support UPPERCASE country codes from API
- API returns country codes in UPPERCASE (AF, AX, AL...) - Updated isCountryCode() to accept both uppercase and lowercase - Convert to lowercase when storing in GeoDNSMap for consistency - Add detailed logging showing original and stored format - Add strings import to config/manager.go This fixes the issue where 250 country codes were treated as regular DNS instead of GeoDNS.
1 parent ba3541f commit 78428d4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

config/manager.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"log"
88
"net/http"
9+
"strings"
910
"sync"
1011
"time"
1112
)
@@ -141,9 +142,9 @@ func (cm *ConfigManager) updateConfig(resp PollResponse) {
141142
if len(name) != 2 {
142143
return false
143144
}
144-
// Check if both characters are lowercase letters
145+
// Check if both characters are letters (uppercase or lowercase)
145146
for _, c := range name {
146-
if c < 'a' || c > 'z' {
147+
if !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
147148
return false
148149
}
149150
}
@@ -160,8 +161,10 @@ func (cm *ConfigManager) updateConfig(resp PollResponse) {
160161

161162
// Check if this is a GeoDNS location record (ISO 3166-1 alpha-2 country code)
162163
if isCountryCode(recordName) {
163-
domain.GeoDNSMap[recordName] = record.Value
164-
log.Printf("[Config] Converting DNS record to GeoDNS: %s -> %s", recordName, record.Value)
164+
// Store in lowercase for consistent GeoDNS lookups
165+
countryCode := strings.ToLower(recordName)
166+
domain.GeoDNSMap[countryCode] = record.Value
167+
log.Printf("[Config] Converting DNS record to GeoDNS: %s -> %s (stored as %s)", recordName, record.Value, countryCode)
165168
} else if recordName == "@" || recordName == "" || recordName == domain.Domain {
166169
// This is the default record
167170
domain.GeoDNSMap["default"] = record.Value

0 commit comments

Comments
 (0)