Fix constructor of conn.go

This commit is contained in:
Zoltán Papp
2025-02-26 14:37:31 +01:00
parent 884d10cceb
commit 9188fcabaf
2 changed files with 3 additions and 4 deletions

View File

@@ -77,7 +77,7 @@ func (m *Manager) RemovePeer(peerID string) bool {
m.listenerMgr.RemovePeer(peerID)
delete(m.managedPeers, peerID)
return false
return true
}
// Close the manager and all the listeners

View File

@@ -158,8 +158,6 @@ func NewConn(engineCtx context.Context, config ConnConfig, statusRecorder *Statu
conn.guard = guard.NewGuard(connLog, ctrl, conn.isConnectedOnAllWay, config.Timeout, srWatcher)
go conn.handshaker.Listen()
return conn, nil
}
@@ -169,12 +167,13 @@ func NewConn(engineCtx context.Context, config ConnConfig, statusRecorder *Statu
// todo: prevent double open
func (conn *Conn) Open() {
conn.semaphore.Add(conn.ctx)
conn.Log.Infof("open connection to peer")
conn.mu.Lock()
defer conn.mu.Unlock()
conn.opened = true
go conn.handshaker.Listen()
peerState := State{
PubKey: conn.config.Key,
IP: conn.config.WgConfig.AllowedIps[0].Addr().String(),