diff --git a/cmd/main.go b/cmd/main.go index 26d24f0..e1f25d9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -15,8 +15,12 @@ import ( ) func main() { - tcpAddr := flag.String("tcp", ":1883", "network address for TCP listener") - wsAddr := flag.String("ws", ":1882", "network address for Websocket listener") + tcpAddr := flag.String("tcp", ":1880", "network address for TCP listener") + tlsTcpAddr := flag.String("tls_tcp", ":1883", "network address for TLS TCP listener") + + wsAddr := flag.String("ws", ":1884", "network address for Websocket listener") + wssAddr := flag.String("wss", ":1882", "network address for Websocket listener") + infoAddr := flag.String("info", ":8080", "network address for web info dashboard listener") certFile := flag.String("cert", "/cert/fullchain.pem", "path the body of a public certificate") keyFile := flag.String("key", "/cert/privkey.pem", "path to body of a private key.") @@ -37,7 +41,6 @@ func main() { fmt.Println("Dashboard", *infoAddr) server := mqtt.NewServer(nil) - tcp := listeners.NewTCP("t1", *tcpAddr) cer, err := tls.LoadX509KeyPair(*certFile, *keyFile) if err != nil { @@ -47,21 +50,35 @@ func main() { config := &tls.Config{Certificates: []tls.Certificate{cer}} - if err := server.AddListener(tcp, &listeners.Config{ + tcp := listeners.NewTCP("tcp", *tcpAddr) + if err := server.AddListener(tcp, nil); err != nil { + log.Fatal(err) + } + + tlsTcp := listeners.NewTCP("tls", *tlsTcpAddr) + if err := server.AddListener(tlsTcp, &listeners.Config{ Auth: new(auth.Allow), TLSConfig: config, }); err != nil { log.Fatal(err) } - ws := listeners.NewWebsocket("ws1", *wsAddr) + ws := listeners.NewWebsocket("ws", *wsAddr) if err = server.AddListener(ws, &listeners.Config{ Auth: new(auth.Allow), + }); err != nil { + log.Fatal(err) + } + + wss := listeners.NewWebsocket("wss", *wssAddr) + if err = server.AddListener(wss, &listeners.Config{ + Auth: new(auth.Allow), TLSConfig: config, }); err != nil { log.Fatal(err) } + stats := listeners.NewHTTPStats("stats", *infoAddr) if err = server.AddListener(stats, nil); err != nil { log.Fatal(err)