~emersion/public-inbox

soju: Support UNIX listeners v1 NEEDS REVISION

Hubert Hirtz: 1
 Support UNIX listeners

 2 files changed, 14 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/10697/mbox | git am -3
Learn more about email & git

[PATCH soju] Support UNIX listeners Export this patch

Since soju isn't shutting down gracefully, UNIX sockets aren't closed
and thus need to be removed manually before running soju again. For now.
---
 cmd/soju/main.go | 11 +++++++++--
 doc/soju.1.scd   |  9 +++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/cmd/soju/main.go b/cmd/soju/main.go
index 5f80fb4..647530d 100644
--- a/cmd/soju/main.go
+++ b/cmd/soju/main.go
@@ -5,6 +5,7 @@ import (
	"flag"
	"log"
	"net"
	"strings"

	"git.sr.ht/~emersion/soju"
	"git.sr.ht/~emersion/soju/config"
@@ -13,7 +14,7 @@ import (
func main() {
	var addr, configPath string
	var debug bool
	flag.StringVar(&addr, "listen", "", "listening address")
	flag.StringVar(&addr, "listen", "", "listening address or UNIX socket path")
	flag.StringVar(&configPath, "config", "", "path to configuration file")
	flag.BoolVar(&debug, "debug", false, "enable debug logging")
	flag.Parse()
@@ -39,7 +40,13 @@ func main() {
	}

	var ln net.Listener
	if cfg.TLS != nil {
	if strings.Contains(cfg.Addr, "/") {
		var err error
		ln, err = net.Listen("unix", cfg.Addr)
		if err != nil {
			log.Fatalf("failed to start unix listener: %v", err)
		}
	} else if cfg.TLS != nil {
		cert, err := tls.LoadX509KeyPair(cfg.TLS.CertPath, cfg.TLS.KeyPath)
		if err != nil {
			log.Fatalf("failed to load TLS certificate and key: %v", err)
diff --git a/doc/soju.1.scd b/doc/soju.1.scd
index 00bdc8e..d13a675 100644
--- a/doc/soju.1.scd
+++ b/doc/soju.1.scd
@@ -56,21 +56,22 @@ be done by adding a "@<client>" suffix to the username.
	Enable debug logging (this will leak sensitive information such as
	passwords).

*-listen* <address>
	Listening address (default: ":6667").
*-listen* <address|path>
	Listening address, or path to a UNIX socket (default: ":6667").

# CONFIG FILE

The config file has one directive per line.

*listen* <address>
	Listening address (default: ":6667").
*listen* <address|path>
	Listening address, or path to a UNIX socket (default: ":6667").

*hostname* <name>
	Server hostname (default: system hostname).

*tls* <cert> <key>
	Enable TLS support. The certificate and the key files must be PEM-encoded.
    This is ignored when *listen* is a UNIX socket.

*sql* <driver> <source>
	Set the SQL driver settings. The only supported driver is "sqlite3". The
-- 
2.26.2
View this thread in the archives