Skip to content

Commit

Permalink
only log ignored pingpacket from host if we actually ignore it.
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <[email protected]>
  • Loading branch information
garyschulte committed Jan 31, 2024
1 parent 4e025dc commit b9d08c7
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,13 @@ protected void handleIncomingPacket(final Endpoint sourceEndpoint, final Packet
* @return host address as string
*/
static String deriveHost(final Endpoint sourceEndpoint, final Packet packet) {
return packet
.getPacketData(PingPacketData.class)
.flatMap(PingPacketData::getFrom)
.map(Endpoint::getHost)
final Optional<String> pingPacketHost =
packet
.getPacketData(PingPacketData.class)
.flatMap(PingPacketData::getFrom)
.map(Endpoint::getHost);

return pingPacketHost
// fall back to source endpoint "from" if ping packet from address does not satisfy filters
.filter(InetAddresses::isInetAddress)
.filter(h -> !NetworkUtility.isUnspecifiedAddress(h))
Expand All @@ -339,14 +342,15 @@ static String deriveHost(final Endpoint sourceEndpoint, final Packet packet) {
}
})
.stream()
.peek(
h ->
LOG.trace(
"Using \"From\" endpoint {} specified in ping packet. Ignoring UDP source host {}",
h,
sourceEndpoint.getHost()))
.findFirst()
.orElseGet(sourceEndpoint::getHost);
.orElseGet(
() -> {
LOG.trace(
"Using \"From\" endpoint {} specified in ping packet. Ignoring UDP source host {}",
pingPacketHost.orElse("not specified"),
sourceEndpoint.getHost());
return sourceEndpoint.getHost();
});
}

/**
Expand Down

0 comments on commit b9d08c7

Please sign in to comment.