mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-07 02:06:38 +08:00
fix(tunnel): restore upstream ipv6 address normalization logic
This commit is contained in:
@@ -1620,27 +1620,23 @@ func processServerAddress(serverAddr string) string {
|
|||||||
if strings.HasPrefix(serverAddr, "[") {
|
if strings.HasPrefix(serverAddr, "[") {
|
||||||
return serverAddr
|
return serverAddr
|
||||||
}
|
}
|
||||||
if looksLikeIPv6(serverAddr) {
|
|
||||||
return "[" + strings.Trim(serverAddr, "[]") + "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
idx := strings.LastIndex(serverAddr, ":")
|
idx := strings.LastIndex(serverAddr, ":")
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
|
if looksLikeIPv6(serverAddr) {
|
||||||
|
return "[" + serverAddr + "]"
|
||||||
|
}
|
||||||
return serverAddr
|
return serverAddr
|
||||||
}
|
}
|
||||||
if strings.Count(serverAddr, ":") != 1 {
|
|
||||||
return "[" + strings.Trim(serverAddr, "[]") + "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
host := strings.TrimSpace(serverAddr[:idx])
|
host := strings.TrimSpace(serverAddr[:idx])
|
||||||
port := strings.TrimSpace(serverAddr[idx+1:])
|
port := strings.TrimSpace(serverAddr[idx+1:])
|
||||||
if host == "" || port == "" {
|
if host == "" || port == "" {
|
||||||
return serverAddr
|
return serverAddr
|
||||||
}
|
}
|
||||||
if looksLikeIPv6(host) {
|
if looksLikeIPv6(host) {
|
||||||
return "[" + strings.Trim(host, "[]") + "]:" + port
|
return "[" + host + "]:" + port
|
||||||
}
|
}
|
||||||
return host + ":" + port
|
return serverAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeServerAddressInput(serverAddr string) string {
|
func normalizeServerAddressInput(serverAddr string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user