mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-18 18:49:23 +08:00
Fix regex for extracting IPv6 addresses
Updated regex to allow for zero-length groups in IPv6 address extraction.
This commit is contained in:
@@ -108,7 +108,7 @@ func GetIPv6Address() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用正则表达式从响应体中提取IPv6地址
|
// 使用正则表达式从响应体中提取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))
|
ipv6 := re.FindString(string(body))
|
||||||
if ipv6 != "" {
|
if ipv6 != "" {
|
||||||
log.Printf("Get IPV6 Success: %s", ipv6)
|
log.Printf("Get IPV6 Success: %s", ipv6)
|
||||||
|
Reference in New Issue
Block a user