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

Fix frequent warning on invalid Discovery packet size #7395

Merged
merged 2 commits into from
Sep 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ public override void ChannelRead(IChannelHandlerContext ctx, object msg)

protected bool ValidatePacket(DatagramPacket packet)
{
// Potential cases where this can happen:
// - Neighbors response containing 16+ nodes in a single packet
if (packet.Content.ReadableBytes is 0 or > MaxPacketSize)
{
if (_logger.IsWarn) _logger.Warn($"Skipping discovery packet of invalid size: {packet.Content.ReadableBytes}");
if (_logger.IsDebug) _logger.Debug($"Skipping discovery packet of invalid size: {packet.Content.ReadableBytes}");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task SendMsg(DiscoveryMsg discoveryMsg)
int size = msgBuffer.ReadableBytes;
if (size > MaxPacketSize)
{
if (_logger.IsWarn) _logger.Warn($"Attempting to send message larger than 1280 bytes. This is out of spec and may not work for all client. Msg: ${discoveryMsg}");
if (_logger.IsWarn) _logger.Warn($"Attempting to send message larger than 1280 bytes. This is out of spec and may not work for all clients. Msg: ${discoveryMsg}");
}

if (discoveryMsg is PingMsg pingMessage)
Expand Down