Skip to content

Commit

Permalink
log at debug when we override pingpacket from
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 ebf915b
Showing 1 changed file with 21 additions and 9 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 @@ -341,12 +344,21 @@ 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()))
LOG.atTrace()
.setMessage(
"Using \"From\" endpoint {} specified in ping packet. Ignoring UDP source host {}")
.addArgument(h)
.addArgument(sourceEndpoint::getHost)
.log())
.findFirst()
.orElseGet(sourceEndpoint::getHost);
.orElseGet(
() -> {
LOG.debug(
"Ignoring \"From\" endpoint {} specified in ping packet. Using UDP source host {}",
pingPacketHost.orElse("not specified"),
sourceEndpoint.getHost());
return sourceEndpoint.getHost();
});
}

/**
Expand Down

0 comments on commit ebf915b

Please sign in to comment.