Skip to content

Commit

Permalink
syncer: resolve domain before checking if peer is banned
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Jul 8, 2024
1 parent 4a9f0a6 commit 657868e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,18 @@ func (s *Syncer) allowConnect(peer string, inbound bool) error {
if s.l == nil {
return errors.New("syncer is shutting down")
}
if banned, err := s.pm.Banned(peer); err != nil {
return err
} else if banned {
return ErrPeerBanned
addrs, err := (&net.Resolver{}).LookupIPAddr(s.shutdownCtx, peer)
if err != nil {
return fmt.Errorf("failed to resolve peer address: %w", err)
} else if len(addrs) == 0 {
return fmt.Errorf("peer didn't resolve to any addresses")
}
for _, addr := range addrs {
if banned, err := s.pm.Banned(addr.String()); err != nil {
return err
} else if banned {
return ErrPeerBanned
}
}
var in, out int
for _, p := range s.peers {
Expand Down

0 comments on commit 657868e

Please sign in to comment.