p2p/discover: unwrap 4-in-6 UDP source addresses (#29944)
Fixes an issue where discovery responses were not recognized.
This commit is contained in:
parent
0750cb0c8f
commit
85459e1439
|
@ -557,6 +557,11 @@ func (t *UDPv4) readLoop(unhandled chan<- ReadPacket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *UDPv4) handlePacket(from netip.AddrPort, buf []byte) error {
|
func (t *UDPv4) handlePacket(from netip.AddrPort, buf []byte) error {
|
||||||
|
// Unwrap IPv4-in-6 source address.
|
||||||
|
if from.Addr().Is4In6() {
|
||||||
|
from = netip.AddrPortFrom(netip.AddrFrom4(from.Addr().As4()), from.Port())
|
||||||
|
}
|
||||||
|
|
||||||
rawpacket, fromKey, hash, err := v4wire.Decode(buf)
|
rawpacket, fromKey, hash, err := v4wire.Decode(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
|
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
|
||||||
|
|
|
@ -674,6 +674,10 @@ func (t *UDPv5) readLoop() {
|
||||||
|
|
||||||
// dispatchReadPacket sends a packet into the dispatch loop.
|
// dispatchReadPacket sends a packet into the dispatch loop.
|
||||||
func (t *UDPv5) dispatchReadPacket(from netip.AddrPort, content []byte) bool {
|
func (t *UDPv5) dispatchReadPacket(from netip.AddrPort, content []byte) bool {
|
||||||
|
// Unwrap IPv4-in-6 source address.
|
||||||
|
if from.Addr().Is4In6() {
|
||||||
|
from = netip.AddrPortFrom(netip.AddrFrom4(from.Addr().As4()), from.Port())
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case t.packetInCh <- ReadPacket{content, from}:
|
case t.packetInCh <- ReadPacket{content, from}:
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue