|
Why compile it yourself? To customize the interface and features, of course. For those who prefer convenience, head straight to the official site.
As the agent keeps updating, I noticed an issue where the country flag wasn't showing up. Today, I decided to manually update the geolocation lookup code.
Navigate to `service/rpc/nezha.go` and locate the `LookupGeoIP` function. Replace it with the following:
```go
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 response
err = json.Unmarshal(resBody, &data)
if err != nil {
return nil, err
}
// Define data based on API response
resData := data["data"].(map[string]interface{})
location := strings.ToLower(resData["countryId"].(string))
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
```
Compile and you're good to go! |
|