From 1767a289b1e083709f6c5f135f5342cb6006f0e4 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Sat, 31 Aug 2024 19:15:57 -0700 Subject: [PATCH] syncer: always allow manual peer connections --- syncer/syncer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syncer/syncer.go b/syncer/syncer.go index b6f6d20..ed2667e 100644 --- a/syncer/syncer.go +++ b/syncer/syncer.go @@ -526,7 +526,11 @@ func (s *Syncer) peerLoop(ctx context.Context) error { for _, p := range candidates { if numOutbound() >= s.config.MaxOutboundPeers { break + } else if err := s.allowConnect(ctx, p, false); err != nil { + log.Debug("rejected outbound peer", zap.String("peer", p), zap.Error(err)) + break } + ctx, cancel := context.WithTimeout(ctx, s.config.ConnectTimeout) if _, err := s.Connect(ctx, p); err != nil { log.Debug("connected to peer", zap.String("peer", p)) @@ -684,10 +688,6 @@ func (s *Syncer) Close() error { // Connect forms an outbound connection to a peer. func (s *Syncer) Connect(ctx context.Context, addr string) (*Peer, error) { - if err := s.allowConnect(ctx, addr, false); err != nil { - return nil, err - } - conn, err := (&net.Dialer{}).DialContext(ctx, "tcp", addr) if err != nil { return nil, err