Skip to content

Commit

Permalink
Use P2P 'from' host when parsing incoming P2P packets, if it is present
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
  • Loading branch information
matthew1001 committed Dec 1, 2023
1 parent 0b28f01 commit 0af44e7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,16 @@ protected void handleIncomingPacket(final Endpoint sourceEndpoint, final Packet
.flatMap(Endpoint::getTcpPort)
.orElse(udpPort);

// If the host is present in the P2P packet itself, use that as the endpoint. Otherwise
// take it from the UDP packet source IP.
final String host =
packet
.getPacketData(PingPacketData.class)
.flatMap(PingPacketData::getFrom)
.map(Endpoint::getHost)
.orElse(sourceEndpoint.getHost());

// Notify the peer controller.
final String host = sourceEndpoint.getHost();
final DiscoveryPeer peer =
DiscoveryPeer.fromEnode(
EnodeURLImpl.builder()
Expand Down

0 comments on commit 0af44e7

Please sign in to comment.