server: finish correction of inbound/outbound within the server
In this commit, we finish the fix for the inbound/outbound peer bool in the server. The prior commit forgot to also flip the inbound/output maps in Inbound/Outbound peer connected. As a result, the checks were incorrect and could cause lnd to refuse to accept any more inbound connections in the case of a concurrent connection attempt.
This commit is contained in:
1 file changed
+11
-6
@@ -1625,10 +1625,12 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
// If we already have an inbound connection to this peer, then ignore
|
// If we already have an outbound connection to this peer, then ignore
|
||||||
// this new connection.
|
// this new connection.
|
||||||
if _, ok := s.inboundPeers[pubStr]; ok {
|
if _, ok := s.outboundPeers[pubStr]; ok {
|
||||||
srvrLog.Debugf("Ignoring duplicate inbound connection")
|
srvrLog.Debugf("Already have outbound connection for %v, "+
|
||||||
|
"ignoring inbound connection", nodePub.SerializeCompressed())
|
||||||
|
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1705,10 +1707,13 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
// If we already have an outbound connection to this peer, then ignore
|
// If we already have an inbound connection to this peer, then ignore
|
||||||
// this new connection.
|
// this new connection.
|
||||||
if _, ok := s.outboundPeers[pubStr]; ok {
|
if _, ok := s.inboundPeers[pubStr]; ok {
|
||||||
srvrLog.Debugf("Ignoring duplicate outbound connection")
|
srvrLog.Debugf("Already have inbound connection for %v, "+
|
||||||
|
"ignoring outbound connection",
|
||||||
|
nodePub.SerializeCompressed())
|
||||||
|
|
||||||
if connReq != nil {
|
if connReq != nil {
|
||||||
s.connMgr.Remove(connReq.ID())
|
s.connMgr.Remove(connReq.ID())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user