feat(server): harden hostile input and overload behavior (#15)
quality-gate / quality (push) Failing after 1m5s

This commit is contained in:
KyuubiYoru
2026-07-16 12:37:38 +02:00
parent 2ff7cd6d9d
commit 88ef946af5
22 changed files with 2159 additions and 93 deletions
@@ -172,12 +172,21 @@ internal sealed partial class UdpMediatorService : BackgroundService
bool isFrozenEnvelope = length >= 2
&& data[0] == RendezvousUdpCodec.MagicFirst
&& data[1] == RendezvousUdpCodec.MagicSecond;
if (!processor.TryAcceptIngress(
endPoint,
isFrozenEnvelope ? "frozen" : "litenet-or-invalid"))
{
Drop(ref length);
return;
}
INatIntroductionSink? sink = _sink;
if (isFrozenEnvelope)
{
if (sink is not null)
{
_ = processor.ProcessDatagram(data.AsSpan(0, length), endPoint, sink);
_ = processor.ProcessDatagramAfterIngress(
data.AsSpan(0, length), endPoint, sink);
}
}
else if (sink is not null
@@ -188,7 +197,8 @@ internal sealed partial class UdpMediatorService : BackgroundService
&& claimedLocalEndpoint is not null
&& token is not null)
{
_ = processor.ProcessRequest(claimedLocalEndpoint, endPoint, token, sink);
_ = processor.ProcessRequestAfterIngress(
claimedLocalEndpoint, endPoint, token, sink);
}
// Every inbound packet is consumed here. NatPunchModule is used only for outbound introductions.