Skip to content

Commit

Permalink
to be reverted: do nothing when duplicate peer
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Sep 20, 2024
1 parent 21d8e38 commit c627746
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,9 @@ func (sw *Switch) addOutboundPeerWithConfig(
func (sw *Switch) filterPeer(p Peer) error {
// Avoid duplicate
if sw.peers.Has(p.ID()) {
return ErrRejected{id: p.ID(), isDuplicate: true}
//return ErrRejected{id: p.ID(), isDuplicate: true}
//sw.peers.Remove(p)
return nil
}

errc := make(chan error, len(sw.peerFilters))
Expand Down
14 changes: 8 additions & 6 deletions p2p/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ func ConnDuplicateIPFilter() ConnFilterFunc {
return func(cs ConnSet, c quic.Connection, ips []net.IP) error {
for _, ip := range ips {
if cs.HasIP(ip) {
return ErrRejected{
conn: c,
err: fmt.Errorf("ip<%v> already connected", ip),
isDuplicate: true,
}
return nil
//return ErrRejected{
// conn: c,
// err: fmt.Errorf("ip<%v> already connected", ip),
// isDuplicate: true,
//}
}
}

Expand Down Expand Up @@ -433,7 +434,8 @@ func (mt *MultiplexTransport) filterConn(c quic.Connection) (err error) {

// Reject if connection is already present.
if mt.conns.Has(c) {
return ErrRejected{conn: c, isDuplicate: true}
return nil
//return ErrRejected{conn: c, isDuplicate: true}
}

// Resolve ips for incoming conn.
Expand Down

0 comments on commit c627746

Please sign in to comment.