反向代理设置中增加移除回源主机名端口功能

This commit is contained in:
GoEdgeLab
2022-06-30 12:12:05 +08:00
parent 146a947d0b
commit 080a88aa1e
4 changed files with 45 additions and 17 deletions

View File

@@ -25,3 +25,16 @@ func ListenReuseAddr(network string, addr string) (net.Listener, error) {
}
return config.Listen(context.Background(), network, addr)
}
// ParseAddrHost 分析地址中的主机名部分
func ParseAddrHost(addr string) string {
if len(addr) == 0 {
return addr
}
host, _, err := net.SplitHostPort(addr)
if err != nil {
return addr
}
return host
}