--- /dev/null
+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
+}