From 85fad93a71e317ceef5f11623bca40deeaf26240 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Jul 2020 17:31:11 +0200 Subject: [PATCH] Add support for upstream Unix socket connections References: https://todo.sr.ht/~emersion/soju/51 --- doc/soju.1.scd | 5 +++-- upstream.go | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/soju.1.scd b/doc/soju.1.scd index 896bf5d..3e816b7 100644 --- a/doc/soju.1.scd +++ b/doc/soju.1.scd @@ -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://][:port]_ connects with TLS over TCP + - _irc+insecure://[:port]_ connects with plain-text TCP + - _unix:///_ connects to a Unix socket Other options are: diff --git a/upstream.go b/upstream.go index 3eb08e2..e43a045 100644 --- a/upstream.go +++ b/upstream.go @@ -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) }