Fall back to registered country

This commit is contained in:
Martin Polden 2015-02-28 12:47:44 +01:00
parent b8ee0c2a5b
commit 6dbeb50677
1 changed files with 5 additions and 2 deletions

View File

@ -73,8 +73,11 @@ func (i *Ifconfig) LookupCountry(ip net.IP) (string, error) {
}
country, exists := record.Country.Names["en"]
if !exists {
return "", fmt.Errorf("no localized name for country: %+v",
record)
country, exists = record.RegisteredCountry.Names["en"]
if !exists {
return "", fmt.Errorf(
"could not determine country for IP: %s", ip)
}
}
return country, nil
}