mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
add fromAddr check
This commit is contained in:
parent
b788e266a7
commit
e7430ef236
1 changed files with 5 additions and 1 deletions
|
|
@ -229,10 +229,14 @@ func (tc *conn) read(c net.PacketConn) v5wire.Packet {
|
|||
if err := c.SetReadDeadline(time.Now().Add(waitTime)); err != nil {
|
||||
return &readError{err}
|
||||
}
|
||||
n, _, err := c.ReadFrom(buf)
|
||||
n, fromAddr, err := c.ReadFrom(buf)
|
||||
if err != nil {
|
||||
return &readError{err}
|
||||
}
|
||||
// Verify the packet is from an expected remote address.
|
||||
if fromAddr.String() != tc.remoteAddrFor(c).String() {
|
||||
return readErrorf("packet from unexpected address %v", fromAddr)
|
||||
}
|
||||
// Always use remoteAddr for codec session lookup, even if the actual sender
|
||||
// address differs (e.g. in multi-network setups where packets are routed
|
||||
// through a different interface).
|
||||
|
|
|
|||
Loading…
Reference in a new issue