p2p: skip netrestrict check for nodes without resolved IP

Hostname-only static nodes have no valid IP at checkDial time and are
resolved later in dialTask. Applying netrestrict to them incorrectly
rejected the dial before resolution could happen.
This commit is contained in:
Weixie Cui 2026-07-02 22:55:18 +08:00
parent c8953d10c2
commit 183d7a17ff

View file

@ -428,7 +428,7 @@ func (d *dialScheduler) checkDial(n *enode.Node) error {
if _, ok := d.pendingInbound[n.ID()]; ok {
return errPendingInbound
}
if d.netRestrict != nil && !d.netRestrict.ContainsAddr(n.IPAddr()) {
if d.netRestrict != nil && n.IPAddr().IsValid() && !d.netRestrict.ContainsAddr(n.IPAddr()) {
return errNetRestrict
}
if d.history.contains(string(n.ID().Bytes())) {