cmd/soju: allow specifying -listen multiple times
Closes: https://todo.sr.ht/~emersion/soju/67
This commit is contained in:
parent
bc7123f486
commit
c375c7d922
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -24,10 +25,22 @@ import (
|
|||||||
// TCP keep-alive interval for downstream TCP connections
|
// TCP keep-alive interval for downstream TCP connections
|
||||||
const downstreamKeepAlive = 1 * time.Hour
|
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() {
|
func main() {
|
||||||
var listen, configPath string
|
var listen []string
|
||||||
|
var configPath string
|
||||||
var debug bool
|
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.StringVar(&configPath, "config", "", "path to configuration file")
|
||||||
flag.BoolVar(&debug, "debug", false, "enable debug logging")
|
flag.BoolVar(&debug, "debug", false, "enable debug logging")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -43,9 +56,7 @@ func main() {
|
|||||||
cfg = config.Defaults()
|
cfg = config.Defaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
if listen != "" {
|
cfg.Listen = append(cfg.Listen, listen...)
|
||||||
cfg.Listen = append(cfg.Listen, listen)
|
|
||||||
}
|
|
||||||
if len(cfg.Listen) == 0 {
|
if len(cfg.Listen) == 0 {
|
||||||
cfg.Listen = []string{":6697"}
|
cfg.Listen = []string{":6697"}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ soju will reload the TLS certificate and key when it receives the HUP signal.
|
|||||||
passwords).
|
passwords).
|
||||||
|
|
||||||
*-listen* <uri>
|
*-listen* <uri>
|
||||||
Listening URI (default: ":6697").
|
Listening URI (default: ":6697"). Can be specified multiple times.
|
||||||
|
|
||||||
# CONFIG FILE
|
# CONFIG FILE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user