add more
This commit is contained in:
parent
8fac8ca4f6
commit
ee70ab5bbb
27
cmd/main.go
27
cmd/main.go
@ -15,8 +15,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
tcpAddr := flag.String("tcp", ":1883", "network address for TCP listener")
|
tcpAddr := flag.String("tcp", ":1880", "network address for TCP listener")
|
||||||
wsAddr := flag.String("ws", ":1882", "network address for Websocket 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")
|
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")
|
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.")
|
keyFile := flag.String("key", "/cert/privkey.pem", "path to body of a private key.")
|
||||||
@ -37,7 +41,6 @@ func main() {
|
|||||||
fmt.Println("Dashboard", *infoAddr)
|
fmt.Println("Dashboard", *infoAddr)
|
||||||
|
|
||||||
server := mqtt.NewServer(nil)
|
server := mqtt.NewServer(nil)
|
||||||
tcp := listeners.NewTCP("t1", *tcpAddr)
|
|
||||||
|
|
||||||
cer, err := tls.LoadX509KeyPair(*certFile, *keyFile)
|
cer, err := tls.LoadX509KeyPair(*certFile, *keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,21 +50,35 @@ func main() {
|
|||||||
|
|
||||||
config := &tls.Config{Certificates: []tls.Certificate{cer}}
|
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),
|
Auth: new(auth.Allow),
|
||||||
TLSConfig: config,
|
TLSConfig: config,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ws := listeners.NewWebsocket("ws1", *wsAddr)
|
ws := listeners.NewWebsocket("ws", *wsAddr)
|
||||||
if err = server.AddListener(ws, &listeners.Config{
|
if err = server.AddListener(ws, &listeners.Config{
|
||||||
Auth: new(auth.Allow),
|
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,
|
TLSConfig: config,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stats := listeners.NewHTTPStats("stats", *infoAddr)
|
stats := listeners.NewHTTPStats("stats", *infoAddr)
|
||||||
if err = server.AddListener(stats, nil); err != nil {
|
if err = server.AddListener(stats, nil); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user