From 65eba098f174d5f91fcce3445c9197c38a12bd38 Mon Sep 17 00:00:00 2001 From: naiba Date: Sat, 20 Mar 2021 10:14:15 +0800 Subject: [PATCH] fix: agent ipv6 info --- service/monitor/monitor.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/service/monitor/monitor.go b/service/monitor/monitor.go index cd6c7c5..2a22b5f 100644 --- a/service/monitor/monitor.go +++ b/service/monitor/monitor.go @@ -65,10 +65,11 @@ func GetHost() *model.Host { if err == nil { defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) - if ip.IP == "" { - cachedIP = string(body) + json.Unmarshal(body, &ip) + if cachedIP == "" { + cachedIP = ip.IP } else { - cachedIP = fmt.Sprintf("ip(v4: %s, v6: %s)", ip.IP, body) + cachedIP = fmt.Sprintf("ip(v4: %s, v6: %s)", cachedIP, ip.IP) } country = ip.CountryCode }