Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p2p/discover: unwrap 4-in-6 UDP source addresses #29944

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
p2p/discover: unwrap 4-in-6 UDP source addresses
Fixes an issue where discovery responses were not recognized.
  • Loading branch information
fjl committed Jun 6, 2024
commit f4e37d67782097077a07dc3d974afb7c68ca2502
5 changes: 5 additions & 0 deletions p2p/discover/v4_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ func (t *UDPv4) readLoop(unhandled chan<- ReadPacket) {
}

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)
if err != nil {
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
Expand Down
4 changes: 4 additions & 0 deletions p2p/discover/v5_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,10 @@ func (t *UDPv5) readLoop() {

// dispatchReadPacket sends a packet into the dispatch loop.
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 {
case t.packetInCh <- ReadPacket{content, from}:
return true
Expand Down
Loading