fix: add connection state to handle reconnects

This commit is contained in:
braginini
2021-04-18 17:17:22 +02:00
parent 7d7417cd64
commit 3a02cc3903

View File

@@ -89,6 +89,11 @@ func (conn *Connection) Close() error {
conn.mux.Lock() conn.mux.Lock()
defer conn.mux.Unlock() defer conn.mux.Unlock()
if !conn.isActive {
log.Infof("connection to peer %s has been already closed, skipping", conn.Config.RemoteWgKey.String())
return nil
}
log.Debugf("closing connection to peer %s", conn.Config.RemoteWgKey.String()) log.Debugf("closing connection to peer %s", conn.Config.RemoteWgKey.String())
conn.closeChannel <- true conn.closeChannel <- true