Agent 获取 IP 增加 api.myip.la

This commit is contained in:
naiba 2022-04-05 11:54:38 +08:00
parent 7bca2988f4
commit 97ef37ac56

View File

@ -15,6 +15,9 @@ type geoIP struct {
CountryCode2 string `json:"countryCode,omitempty"`
IP string `json:"ip,omitempty"`
Query string `json:"query,omitempty"`
Location struct {
CountryCode string `json:"country_code,omitempty"`
} `json:"location,omitempty"`
}
func (ip *geoIP) Unmarshal(body []byte) error {
@ -27,11 +30,15 @@ func (ip *geoIP) Unmarshal(body []byte) error {
if ip.CountryCode == "" && ip.CountryCode2 != "" {
ip.CountryCode = ip.CountryCode2
}
if ip.CountryCode == "" && ip.Location.CountryCode != "" {
ip.CountryCode = ip.Location.CountryCode
}
return nil
}
var (
geoIPApiList = []string{
"https://api.myip.la/en?json",
"https://api.ip.sb/geoip",
"https://ipapi.co/json",
"https://freegeoip.app/json/",