修复集群启用“允许使用节点IP访问”时无法访问IPv6的问题

This commit is contained in:
刘祥超
2023-09-07 14:48:27 +08:00
parent e93275ac5c
commit a1e1b5ef98
4 changed files with 66 additions and 36 deletions

View File

@@ -72,3 +72,18 @@ func IsIPv6(ip string) bool {
}
return !IsIPv4(ip)
}
// IsWildIP 宽泛地判断一个数据是否为IP
func IsWildIP(v string) bool {
var l = len(v)
if l == 0 {
return false
}
// for [IPv6]
if v[0] == '[' && v[l-1] == ']' {
return IsWildIP(v[1 : l-1])
}
return net.ParseIP(v) != nil
}