mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
🐛 fix: 修复双栈IP只能获取到v6的问题 close #61
This commit is contained in:
parent
1a0355894d
commit
7df63939d2
@ -182,6 +182,10 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
|
||||
|
||||
## 变更日志
|
||||
|
||||
- `agent 0.2.2`
|
||||
|
||||
- 修复双栈IP只能获取到v6的问题 #61
|
||||
|
||||
- `dashboard 0.2.1` `agent 0.2.1`
|
||||
|
||||
- dashboard
|
||||
|
@ -37,20 +37,18 @@ func GetHost() *model.Host {
|
||||
ms, _ := mem.SwapMemory()
|
||||
u, _ := disk.Usage("/")
|
||||
var ip ipDotSbGeoIP
|
||||
resp, err := http.Get("https://api.ip.sb/geoip")
|
||||
resp, err := http.Get("https://api-ipv4.ip.sb/geoip")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
json.Unmarshal(body, &ip)
|
||||
}
|
||||
|
||||
resp, err = http.Get("https://api-ipv6.ip.sb/ip")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
ip.IP = fmt.Sprintf("ip(v4: %s, v6: %s)", ip.IP, body)
|
||||
}
|
||||
|
||||
return &model.Host{
|
||||
Platform: hi.OS,
|
||||
PlatformVersion: hi.PlatformVersion,
|
||||
|
Loading…
Reference in New Issue
Block a user