X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=tls%2Fhostport.go;fp=tls%2Fhostport.go;h=14b1ce38eb62bc758a08d6cb7b413bd74bd7f983;hb=df6f0b184c5689eab0a4b4be4769902200f2b241;hp=0000000000000000000000000000000000000000;hpb=12ef431d87442cac2111a0d3af3d13017e695348;p=tofuproxy.git diff --git a/tls/hostport.go b/tls/hostport.go new file mode 100644 index 0000000..14b1ce3 --- /dev/null +++ b/tls/hostport.go @@ -0,0 +1,20 @@ +package tofuproxy + +import ( + "net" + "strings" +) + +func SplitHostPort(addr string) (string, string, error) { + if net.ParseIP(addr) != nil { + return addr, "", nil + } + host, port, err := net.SplitHostPort(addr) + if err == nil { + return host, port, nil + } + if strings.Contains(err.Error(), "missing port") { + return addr, "", nil + } + return addr, "", err +}