diff --git a/network/default.go b/network/default.go index 315c8f19..3e8b4d61 100644 --- a/network/default.go +++ b/network/default.go @@ -213,6 +213,9 @@ func (n *network) handleNetConn(sess tunnel.Session, msg chan *transport.Message m := new(transport.Message) if err := sess.Recv(m); err != nil { log.Debugf("Network tunnel [%s] receive error: %v", NetworkChannel, err) + if sessErr := sess.Close(); sessErr != nil { + log.Debugf("Network tunnel [%s] closing connection error: %v", sessErr) + } return } @@ -230,9 +233,7 @@ func (n *network) acceptNetConn(l tunnel.Listener, recv chan *transport.Message) // accept a connection conn, err := l.Accept() if err != nil { - // TODO: handle this log.Debugf("Network tunnel [%s] accept error: %v", NetworkChannel, err) - return } select { @@ -730,6 +731,11 @@ func (n *network) Connect() error { log.Debugf("Network failed to resolve nodes: %v", err) } + // initialize the tunnel to resolved nodes + n.tunnel.Init( + tunnel.Nodes(nodes...), + ) + // connect network tunnel if err := n.tunnel.Connect(); err != nil { n.Unlock() @@ -742,11 +748,6 @@ func (n *network) Connect() error { n.server.Init(server.Advertise(n.tunnel.Address())) } - // initialize the tunnel to resolved nodes - n.tunnel.Init( - tunnel.Nodes(nodes...), - ) - // dial into ControlChannel to send route adverts ctrlClient, err := n.tunnel.Dial(ControlChannel, tunnel.DialMulticast()) if err != nil {