|
|
@ -25,6 +25,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"net" |
|
|
|
"net" |
|
|
|
|
|
|
|
"slices" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
@ -437,7 +438,7 @@ func (t *UDPv5) verifyResponseNode(c *callV5, r *enr.Record, distances []uint, s |
|
|
|
} |
|
|
|
} |
|
|
|
if distances != nil { |
|
|
|
if distances != nil { |
|
|
|
nd := enode.LogDist(c.id, node.ID()) |
|
|
|
nd := enode.LogDist(c.id, node.ID()) |
|
|
|
if !containsUint(uint(nd), distances) { |
|
|
|
if !slices.Contains(distances, uint(nd)) { |
|
|
|
return nil, errors.New("does not match any requested distance") |
|
|
|
return nil, errors.New("does not match any requested distance") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -448,15 +449,6 @@ func (t *UDPv5) verifyResponseNode(c *callV5, r *enr.Record, distances []uint, s |
|
|
|
return node, nil |
|
|
|
return node, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func containsUint(x uint, xs []uint) bool { |
|
|
|
|
|
|
|
for _, v := range xs { |
|
|
|
|
|
|
|
if x == v { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// callToNode sends the given call and sets up a handler for response packets (of message
|
|
|
|
// callToNode sends the given call and sets up a handler for response packets (of message
|
|
|
|
// type responseType). Responses are dispatched to the call's response channel.
|
|
|
|
// type responseType). Responses are dispatched to the call's response channel.
|
|
|
|
func (t *UDPv5) callToNode(n *enode.Node, responseType byte, req v5wire.Packet) *callV5 { |
|
|
|
func (t *UDPv5) callToNode(n *enode.Node, responseType byte, req v5wire.Packet) *callV5 { |
|
|
|