|
Because you can customize the interface and functions;
Lazy people directly move to the official website;
As agent continues to update, I don't know what has changed, and it doesn't display the flag all the time today, so I manually coded the code for geolocation query service/rpc/nezha.go
Find the LookupGeoIP method in the code
Directly modify the code below code and compile it
[ol]var clientID uint64 var err error if clientID, err = s.Auth.Check(c); err != nil { return nil, err } ip := r.GetIp() url := "https://xxxxxx.xx/api/ip?ip=" + ip // Send HTTP POST request resp, err := http.Post(url, "application/json;charset=utf-8", nil) if err != nil { return nil, err } defer resp.Body.Close() resBody, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } var data map[string]interface{} // Parse JSON data err = json.Unmarshal(resBody, &data) if err != nil { return nil, err } // Define the content of data according to the interface resData := data["data"].(map[string]interface{}) var location = strings.ToLower(resData["countryId"].(string)) // Write the country code into Host singleton.ServerLock.RLock() defer singleton.ServerLock.RUnlock() if singleton.ServerList[clientID].Host == nil { return nil, fmt.Errorf("host not found") } singleton.ServerList[clientID].Host.CountryCode = location return &pb.GeoIP{Ip: ip, CountryCode: location}, nil[/ol]复制代码 |
|