From 061347f9f91fdd80dd2e8819a4dec98a90eda7e5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 16 Mar 2021 09:27:40 +0100 Subject: [PATCH] Add Unix socket listener Closes: https://todo.sr.ht/~emersion/soju/51 --- cmd/soju/main.go | 11 +++++++++++ doc/soju.1.scd | 1 + 2 files changed, 12 insertions(+) diff --git a/cmd/soju/main.go b/cmd/soju/main.go index 1b1dacb..1d4e33b 100644 --- a/cmd/soju/main.go +++ b/cmd/soju/main.go @@ -114,6 +114,17 @@ func main() { log.Printf("serving %q: %v", listen, err) } }() + case "unix": + ln, err := net.Listen("unix", u.Path) + if err != nil { + log.Fatalf("failed to start listener on %q: %v", listen, err) + } + ln = proxyProtoListener(ln, srv) + go func() { + if err := srv.Serve(ln); err != nil { + log.Printf("serving %q: %v", listen, err) + } + }() case "wss": addr := u.Host if _, _, err := net.SplitHostPort(addr); err != nil { diff --git a/doc/soju.1.scd b/doc/soju.1.scd index 70b78b4..3e169a2 100644 --- a/doc/soju.1.scd +++ b/doc/soju.1.scd @@ -82,6 +82,7 @@ The following directives are supported: omitted: 6697) - _irc+insecure://[host][:port]_ listens with plain-text over TCP (default port if omitted: 6667) + - _unix:///_ listens on a Unix domain socket - _wss://[host][:port]_ listens for WebSocket connections over TLS (default port: 443) - _ws+insecure://[host][:port]_ listens for plain-text WebSocket