Skip to content

Commit

Permalink
p2p/discover: filter bootnodes by netrestrict (#27701)
Browse files Browse the repository at this point in the history
This prevents an issue where the node would attempt to contact the bootstrap
nodes even if they weren't contained in the netrestrict list.
  • Loading branch information
fjl authored Jul 12, 2023
1 parent 0b1f97e commit a426999
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion p2p/discover/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,18 @@ func (tab *Table) close() {
// are used to connect to the network if the table is empty and there
// are no known nodes in the database.
func (tab *Table) setFallbackNodes(nodes []*enode.Node) error {
nursery := make([]*node, 0, len(nodes))
for _, n := range nodes {
if err := n.ValidateComplete(); err != nil {
return fmt.Errorf("bad bootstrap node %q: %v", n, err)
}
if tab.cfg.NetRestrict != nil && !tab.cfg.NetRestrict.Contains(n.IP()) {
tab.log.Error("Bootstrap node filtered by netrestrict", "id", n.ID(), "ip", n.IP())
continue
}
nursery = append(nursery, wrapNode(n))
}
tab.nursery = wrapNodes(nodes)
tab.nursery = nursery
return nil
}

Expand Down

0 comments on commit a426999

Please sign in to comment.