Skip to content

Commit

Permalink
Merge pull request #540 from wirenboard/fix-unix-socket
Browse files Browse the repository at this point in the history
Support use of uri.Path for UNIX domain socket URLs (uri.Host will still be used if it is populated).
  • Loading branch information
MattBrittan committed Sep 21, 2021
2 parents 3f47407 + 387914c commit 2601804
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion netconn.go
Expand Up @@ -62,7 +62,17 @@ func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, heade
}
return conn, nil
case "unix":
conn, err := net.DialTimeout("unix", uri.Host, timeout)
var conn net.Conn
var err error

// this check is preserved for compatibility with older versions
// which used uri.Host only (it works for local paths, e.g. unix://socket.sock in current dir)
if len(uri.Host) > 0 {
conn, err = net.DialTimeout("unix", uri.Host, timeout)
} else {
conn, err = net.DialTimeout("unix", uri.Path, timeout)
}

if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2601804

Please sign in to comment.