优化ip插件

This commit is contained in:
liyp 2024-04-18 17:54:15 +08:00
parent c7ce482511
commit 5def1cd668

View file

@ -52,12 +52,16 @@ func (a *Ip) GetMsg() string {
} else { } else {
defer resp.Body.Close() defer resp.Body.Close()
body, err := io.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
// println(string(body)) println(string(body))
if err != nil { if err != nil {
fmt.Println("err:", err) fmt.Println("err:", err)
} else { } else {
var resp_data map[string]interface{} var resp_data map[string]interface{}
json.Unmarshal(body, &resp_data) err := json.Unmarshal(body, &resp_data)
if err != nil {
return "DNS解析失败"
}
ip = resp_data["data"].(map[string]interface{})["ip"].(string) ip = resp_data["data"].(map[string]interface{})["ip"].(string)
// print("ip: ", ip) // print("ip: ", ip)
} }