~emersion/soju

c375c7d922c997cb2f9c11ff2c73a2337eef90f4 — Simon Ser 16 days ago bc7123f
cmd/soju: allow specifying -listen multiple times

Closes: https://todo.sr.ht/~emersion/soju/67
2 files changed, 17 insertions(+), 6 deletions(-)

M cmd/soju/main.go
M doc/soju.1.scd
M cmd/soju/main.go => cmd/soju/main.go +16 -5
@@ 4,6 4,7 @@ import (
	"context"
	"crypto/tls"
	"flag"
	"fmt"
	"log"
	"net"
	"net/http"


@@ 24,10 25,22 @@ import (
// TCP keep-alive interval for downstream TCP connections
const downstreamKeepAlive = 1 * time.Hour

type stringSliceFlag []string

func (v *stringSliceFlag) String() string {
	return fmt.Sprint([]string(*v))
}

func (v *stringSliceFlag) Set(s string) error {
	*v = append(*v, s)
	return nil
}

func main() {
	var listen, configPath string
	var listen []string
	var configPath string
	var debug bool
	flag.StringVar(&listen, "listen", "", "listening address")
	flag.Var((*stringSliceFlag)(&listen), "listen", "listening address")
	flag.StringVar(&configPath, "config", "", "path to configuration file")
	flag.BoolVar(&debug, "debug", false, "enable debug logging")
	flag.Parse()


@@ 43,9 56,7 @@ func main() {
		cfg = config.Defaults()
	}

	if listen != "" {
		cfg.Listen = append(cfg.Listen, listen)
	}
	cfg.Listen = append(cfg.Listen, listen...)
	if len(cfg.Listen) == 0 {
		cfg.Listen = []string{":6697"}
	}

M doc/soju.1.scd => doc/soju.1.scd +1 -1
@@ 59,7 59,7 @@ soju will reload the TLS certificate and key when it receives the HUP signal.
	passwords).

*-listen* <uri>
	Listening URI (default: ":6697").
	Listening URI (default: ":6697"). Can be specified multiple times.

# CONFIG FILE