You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// AdaptIPv6 adapts an IPv6 address to a format that can be used with net.DialContext, it will return the original address if the address is not a valid IPv6 address
76
+
// addr must contain a valid IPv6 address and a port number
77
+
funcAdaptIPv6(addrstring) string {
78
+
varhost, portstring
79
+
varerrerror
80
+
host, port, err=net.SplitHostPort(addr)
81
+
iferr!=nil {
82
+
// if the address is not in the format of host:port, return the original address
83
+
ifaddrErr, ok:=err.(*net.AddrError); ok&&addrErr.Err=="too many colons in address" {
84
+
ifi:=strings.LastIndex(addr, ":"); i>0 {
85
+
host=addr[:i]
86
+
port=addr[i+1:]
87
+
}
88
+
} else {
89
+
returnaddr
90
+
}
91
+
}
92
+
93
+
if_, err:=strconv.Atoi(port); err!=nil {
94
+
// if the port is not a valid port, return the original address
0 commit comments