diff --git a/core/internal/helpers/validation.go b/core/internal/helpers/validation.go index 242cdbfd..7b57e12f 100644 --- a/core/internal/helpers/validation.go +++ b/core/internal/helpers/validation.go @@ -112,6 +112,10 @@ func ValidateHostList(hosts []string) bool { // ValidateHostPort returns true if the provided string is of the form "hostname:port", where hostname is a valid // hostname or IP address (as parsed by ValidateIP or ValidateHostname), and port is a valid integer. func ValidateHostPort(host string, allowBlankHost bool) bool { + if strings.HasPrefix(host, "unix:") { + return true + } + // Must be hostname:port, ipv4:port, or [ipv6]:port. Optionally allow blank hostname hostname, portString, err := net.SplitHostPort(host) if err != nil { diff --git a/core/internal/httpserver/coordinator.go b/core/internal/httpserver/coordinator.go index cfc4552a..c00604b2 100644 --- a/core/internal/httpserver/coordinator.go +++ b/core/internal/httpserver/coordinator.go @@ -171,7 +171,13 @@ func (hc *Coordinator) Start() error { listeners := make(map[string]net.Listener) for name, server := range hc.servers { - ln, err := net.Listen("tcp", hc.servers[name].Addr) + network := "tcp" + if strings.HasPrefix(hc.servers[name].Addr, "unix:") { + network = "unix" + hc.servers[name].Addr = hc.servers[name].Addr[len("unix:"):] + } + + ln, err := net.Listen(network, hc.servers[name].Addr) if err != nil { hc.Log.Error("failed to listen", zap.String("listener", hc.servers[name].Addr), zap.Error(err)) for _, listenerToClose := range listeners { @@ -184,10 +190,14 @@ func (hc *Coordinator) Start() error { } return err } + hc.Log.Info("started listener", zap.String("listener", ln.Addr().String())) - listeners[name] = tcpKeepAliveListener{ - Keepalive: server.IdleTimeout, - TCPListener: ln.(*net.TCPListener), + listeners[name] = ln + if network == "tcp" { + listeners[name] = tcpKeepAliveListener{ + Keepalive: server.IdleTimeout, + TCPListener: ln.(*net.TCPListener), + } } }