一元网络论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 207|回复: 0

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

[复制链接]

3万

主题

3万

帖子

9万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
94972
发表于 2024-7-31 16:49:09 | 显示全部楼层 |阅读模式
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]复制代码
  • 回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|一元网络论坛

    GMT+8, 2024-11-24 09:21 , Processed in 0.065021 second(s), 20 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表