mirror of https://github.com/mpolden/echoip
Fall back to registered country
This commit is contained in:
parent
b8ee0c2a5b
commit
6dbeb50677
|
@ -73,8 +73,11 @@ func (i *Ifconfig) LookupCountry(ip net.IP) (string, error) {
|
||||||
}
|
}
|
||||||
country, exists := record.Country.Names["en"]
|
country, exists := record.Country.Names["en"]
|
||||||
if !exists {
|
if !exists {
|
||||||
return "", fmt.Errorf("no localized name for country: %+v",
|
country, exists = record.RegisteredCountry.Names["en"]
|
||||||
record)
|
if !exists {
|
||||||
|
return "", fmt.Errorf(
|
||||||
|
"could not determine country for IP: %s", ip)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return country, nil
|
return country, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue