Skip to content

Commit

Permalink
fix: add connection state to handle reconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
braginini committed Apr 18, 2021
1 parent 7d7417c commit 3a02cc3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func (conn *Connection) Close() error {
conn.mux.Lock()
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())

conn.closeChannel <- true
Expand Down

0 comments on commit 3a02cc3

Please sign in to comment.