]> Sergey Matveev's repositories - tofuproxy.git/blob - tls/hostport.go
More Fprintf usage
[tofuproxy.git] / tls / hostport.go
1 package tofuproxy
2
3 import (
4         "net"
5         "strings"
6 )
7
8 func SplitHostPort(addr string) (string, string, error) {
9         if net.ParseIP(addr) != nil {
10                 return addr, "", nil
11         }
12         host, port, err := net.SplitHostPort(addr)
13         if err == nil {
14                 return host, port, nil
15         }
16         if strings.Contains(err.Error(), "missing port") {
17                 return addr, "", nil
18         }
19         return addr, "", err
20 }