From b7f57c0617478b521e81c488abddced2ea12d13f Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sat, 19 Jun 2021 10:42:38 -0500 Subject: [PATCH] use TLS for multicast peers, fix TLS listener type in log output --- src/core/tcp.go | 8 ++++++-- src/multicast/multicast.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/tcp.go b/src/core/tcp.go index 4dc36a08..572fd652 100644 --- a/src/core/tcp.go +++ b/src/core/tcp.go @@ -185,17 +185,21 @@ func (t *tcp) listener(l *TcpListener, listenaddr string) { l.Listener.Close() return } + callproto := "TCP" + if l.opts.upgrade != nil { + callproto = strings.ToUpper(l.opts.upgrade.name) + } t.listeners[listenaddr] = l t.mutex.Unlock() // And here we go! defer func() { - t.links.core.log.Infoln("Stopping TCP listener on:", l.Listener.Addr().String()) + t.links.core.log.Infoln("Stopping", callproto, "listener on:", l.Listener.Addr().String()) l.Listener.Close() t.mutex.Lock() delete(t.listeners, listenaddr) t.mutex.Unlock() }() - t.links.core.log.Infoln("Listening for TCP on:", l.Listener.Addr().String()) + t.links.core.log.Infoln("Listening for", callproto, "on:", l.Listener.Addr().String()) go func() { <-l.stop l.Listener.Close() diff --git a/src/multicast/multicast.go b/src/multicast/multicast.go index 2b631ca2..ef564bb3 100644 --- a/src/multicast/multicast.go +++ b/src/multicast/multicast.go @@ -277,7 +277,7 @@ func (m *Multicast) _announce() { var info *listenerInfo if nfo, ok := m.listeners[iface.Name]; !ok || nfo.listener.Listener == nil { // No listener was found - let's create one - urlString := fmt.Sprintf("tcp://[%s]:%d", addrIP, m.listenPort) + urlString := fmt.Sprintf("tls://[%s]:%d", addrIP, m.listenPort) u, err := url.Parse(urlString) if err != nil { panic(err) @@ -370,7 +370,7 @@ func (m *Multicast) listen() { if _, ok := interfaces[from.Zone]; ok { addr.Zone = "" pin := fmt.Sprintf("/?key=%s", hex.EncodeToString(key)) - u, err := url.Parse("tcp://" + addr.String() + pin) + u, err := url.Parse("tls://" + addr.String() + pin) if err != nil { m.log.Debugln("Call from multicast failed, parse error:", addr.String(), err) }