Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #260 from libp2p/remove-incorrect-gating
Browse files Browse the repository at this point in the history
remove incorrect call to InterceptAddrDial
  • Loading branch information
marten-seemann authored May 30, 2021
2 parents fbd1280 + f004a10 commit e6dd8fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 0 additions & 10 deletions swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,6 @@ func (s *Swarm) addConn(tc transport.CapableConn, dir network.Direction) (*Conn,
addr = tc.RemoteMultiaddr()
)

if s.gater != nil {
if allow := s.gater.InterceptAddrDial(p, addr); !allow {
err := tc.Close()
if err != nil {
log.Warnf("failed to close connection with peer %s and addr %s; err: %s", p.Pretty(), addr, err)
}
return nil, ErrAddrFiltered
}
}

// create the Stat object, initializing with the underlying connection Stat if available
var stat network.Stat
if cs, ok := tc.(network.ConnStat); ok {
Expand Down
9 changes: 9 additions & 0 deletions swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ func TestConnectionGating(t *testing.T) {
p2ConnectednessToP1: network.NotConnected,
isP1OutboundErr: true,
},
"p2 accepts inbound peer dial if outgoing dial is gated": {
p2Gater: func(c *MockConnectionGater) *MockConnectionGater {
c.Dial = func(peer.ID, ma.Multiaddr) bool { return false }
return c
},
p1ConnectednessToP2: network.Connected,
p2ConnectednessToP1: network.Connected,
isP1OutboundErr: false,
},
"p2 gates inbound peer dial before securing": {
p2Gater: func(c *MockConnectionGater) *MockConnectionGater {
c.Accept = func(c network.ConnMultiaddrs) bool { return false }
Expand Down

0 comments on commit e6dd8fb

Please sign in to comment.