fix: Fixes stalled connections and infinite throttle (#1796)
> [!Warning] > **Developer Warning** > The `PacketThrottle` callback return value is now reversed. `true` indicates the connection is _throttled_. ### Summary - Fixes an issue where connections get stalled forever - Fixes an issue where the throttler is not working properly - Removes account attack limiter - Rewrites IP limiter - Removes IP restrictions (they weren't used, and not practical) - Fixes issue where IP limiter was counting before firewall was blocking. View without whitespace: https://github.com/modernuo/ModernUO/pull/1796/files?diff=split&w=1
This commit is contained in:
parent
ccad915464
commit
a4522b9d43
13 changed files with 1538 additions and 1783 deletions
|
|
@ -33,15 +33,13 @@ public static class MovementThrottle
|
|||
IncomingPackets.RegisterThrottler(0x02, &Throttle);
|
||||
}
|
||||
|
||||
public static bool Throttle(int packetId, NetState ns, out bool drop)
|
||||
public static bool Throttle(int packetId, NetState ns)
|
||||
{
|
||||
drop = false;
|
||||
|
||||
var from = ns.Mobile;
|
||||
|
||||
if (from?.Deleted != false || from.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
long now = Core.TickCount;
|
||||
|
|
@ -53,7 +51,7 @@ public static class MovementThrottle
|
|||
{
|
||||
ns._movementCredit = 0;
|
||||
ns._nextMovementTime = now;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
long cost = nextMove - now;
|
||||
|
|
@ -61,11 +59,11 @@ public static class MovementThrottle
|
|||
if (credit < cost)
|
||||
{
|
||||
// Not enough credit, therefore throttled
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// On the next event loop, the player receives up to 400ms in grace latency
|
||||
ns._movementCredit = Math.Min(_throttleThreshold, credit - cost);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue