mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
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:
parent
8885c3de8d
commit
15da55effb
17
server.go
17
server.go
@ -1625,10 +1625,12 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
|
||||
s.mu.Lock()
|
||||
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.
|
||||
if _, ok := s.inboundPeers[pubStr]; ok {
|
||||
srvrLog.Debugf("Ignoring duplicate inbound connection")
|
||||
if _, ok := s.outboundPeers[pubStr]; ok {
|
||||
srvrLog.Debugf("Already have outbound connection for %v, "+
|
||||
"ignoring inbound connection", nodePub.SerializeCompressed())
|
||||
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
@ -1705,10 +1707,13 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
|
||||
s.mu.Lock()
|
||||
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.
|
||||
if _, ok := s.outboundPeers[pubStr]; ok {
|
||||
srvrLog.Debugf("Ignoring duplicate outbound connection")
|
||||
if _, ok := s.inboundPeers[pubStr]; ok {
|
||||
srvrLog.Debugf("Already have inbound connection for %v, "+
|
||||
"ignoring outbound connection",
|
||||
nodePub.SerializeCompressed())
|
||||
|
||||
if connReq != nil {
|
||||
s.connMgr.Remove(connReq.ID())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user