Skip to content

Commit

Permalink
to be reverted: remove filtering of peers
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Sep 23, 2024
1 parent fa7a8d6 commit 574cbb8
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions p2p/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ 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 ErrRejected{
// conn: c,
// err: fmt.Errorf("ip<%v> already connected", ip),
// isDuplicate: true,
//}
}
}

Expand Down Expand Up @@ -366,19 +366,19 @@ func (mt *MultiplexTransport) acceptPeers(ctx context.Context) {
go func(c quic.Connection) {
defer func() {
if r := recover(); r != nil {
err := ErrRejected{
conn: c,
err: fmt.Errorf("recovered from panic: %v", r),
isAuthFailure: true,
}
select {
case mt.acceptc <- accept{err: err}:
case <-mt.closec:
// Give up if the transport was closed.
// TODO(rach-id): valid error code
_ = c.CloseWithError(quic.ApplicationErrorCode(0), "some error 1")
return
}
//err := ErrRejected{
// conn: c,
// err: fmt.Errorf("recovered from panic: %v", r),
// isAuthFailure: true,
//}
//select {
//case mt.acceptc <- accept{err: err}:
//case <-mt.closec:
// // Give up if the transport was closed.
// // TODO(rach-id): valid error code
// _ = c.CloseWithError(quic.ApplicationErrorCode(0), "some error 1")
// return
//}
}
}()

Expand Down Expand Up @@ -433,7 +433,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 ErrRejected{conn: c, isDuplicate: true}
return nil
}

// Resolve ips for incoming conn.
Expand All @@ -454,7 +455,8 @@ func (mt *MultiplexTransport) filterConn(c quic.Connection) (err error) {
select {
case err := <-errc:
if err != nil {
return ErrRejected{conn: c, err: err, isFiltered: true}
return nil
//return ErrRejected{conn: c, err: err, isFiltered: true}
}
case <-time.After(mt.filterTimeout):
return ErrFilterTimeout{}
Expand Down

0 comments on commit 574cbb8

Please sign in to comment.