From bc40bdc04dc1cd3ccdc9e9c369170799b7e02d3e Mon Sep 17 00:00:00 2001 From: Akizon <64686663+Akizon77@users.noreply.github.com> Date: Thu, 9 Oct 2025 20:38:21 +0800 Subject: [PATCH] Fix regex for extracting IPv6 addresses Updated regex to allow for zero-length groups in IPv6 address extraction. --- monitoring/unit/ip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitoring/unit/ip.go b/monitoring/unit/ip.go index 4391e25..2dfba47 100644 --- a/monitoring/unit/ip.go +++ b/monitoring/unit/ip.go @@ -108,7 +108,7 @@ func GetIPv6Address() (string, error) { } // 使用正则表达式从响应体中提取IPv6地址 - re := regexp.MustCompile(`(([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{1,4})`) + re := regexp.MustCompile(`(([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{0,4})`) ipv6 := re.FindString(string(body)) if ipv6 != "" { log.Printf("Get IPV6 Success: %s", ipv6)