admin 发表于 2024-7-31 16:49:09

Custom-built Nezha panel doesn't show flag. Noob慎入.

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
[*]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 mapinterface{}
[*]      // 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"].(mapinterface{})
[*]      var location = strings.ToLower(resData["countryId"].(string)) // Write the country code into Host
[*]      singleton.ServerLock.RLock()
[*]      defer singleton.ServerLock.RUnlock()
[*]      if singleton.ServerList.Host == nil {
[*]                return nil, fmt.Errorf("host not found")
[*]      }
[*]      singleton.ServerList.Host.CountryCode = location
[*]
[*]      return &pb.GeoIP{Ip: ip, CountryCode: location}, nil复制代码
页: [1]
查看完整版本: Custom-built Nezha panel doesn't show flag. Noob慎入.