Add support for upstream Unix socket connections

References: https://todo.sr.ht/~emersion/soju/51
This commit is contained in:
Simon Ser 2020-07-06 17:31:11 +02:00
parent 7af21d9d81
commit 85fad93a71
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 9 additions and 2 deletions

View file

@ -116,8 +116,9 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
_addr_ supports several connection types:
- _[ircs://]host[:port]_ connects with TLS over TCP
- _irc+insecure://host[:port]_ connects with plain-text TCP
- _[ircs://]<host>[:port]_ connects with TLS over TCP
- _irc+insecure://<host>[:port]_ connects with plain-text TCP
- _unix:///<path>_ connects to a Unix socket
Other options are:

View file

@ -142,6 +142,12 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
if err != nil {
return nil, fmt.Errorf("failed to dial %q: %v", addr, err)
}
case "unix":
logger.Printf("connecting to Unix socket at path %q", u.Path)
netConn, err = dialer.Dial("unix", u.Path)
if err != nil {
return nil, fmt.Errorf("failed to connect to Unix socket %q: %v", u.Path, err)
}
default:
return nil, fmt.Errorf("failed to dial %q: unknown scheme: %v", network.Addr, u.Scheme)
}