From 3989ee87c86cdb967e5a03cea043b0b3894e4ad3 Mon Sep 17 00:00:00 2001 From: naiba Date: Sun, 28 Jul 2024 22:22:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=8C=E6=A0=88=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/monitor/myip.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/monitor/myip.go b/pkg/monitor/myip.go index e0acc34..64b6c31 100644 --- a/pkg/monitor/myip.go +++ b/pkg/monitor/myip.go @@ -38,19 +38,17 @@ func UpdateIP(useIPv6CountryCode bool, period uint32) { } continue } + if ipv4 == "" || ipv6 == "" { - if ipv4 == "" { - GeoQueryIP = ipv6 - } else { - GeoQueryIP = ipv4 - } CachedIP = fmt.Sprintf("%s%s", ipv4, ipv6) } else { CachedIP = fmt.Sprintf("%s/%s", ipv4, ipv6) } - if useIPv6CountryCode { + if ipv6 != "" && useIPv6CountryCode { GeoQueryIP = ipv6 + } else { + GeoQueryIP = ipv4 } time.Sleep(time.Second * time.Duration(period))