🐛 Stop broadcasting to unauthenticated sockets

Change and radar packets reached every connected socket, leaking
map edit activity to anyone who had opened a connection without
logging in. The state sweep also ran per loop tick; it now runs
once per second.
This commit is contained in:
2026-11-15 22:08:32 +01:00
parent 4a7f525937
commit 7acd461086
+9 -2
View File
@@ -48,6 +48,7 @@ type
FTCPServer: TLTcp; FTCPServer: TLTcp;
FQuit: Boolean; FQuit: Boolean;
FLastFlush: TDateTime; FLastFlush: TDateTime;
FLastNetCheck: TDateTime;
FValid: Boolean; FValid: Boolean;
procedure OnAccept(ASocket: TLSocket); procedure OnAccept(ASocket: TLSocket);
procedure OnCanSend(ASocket: TLSocket); procedure OnCanSend(ASocket: TLSocket);
@@ -121,6 +122,7 @@ begin
FTCPServer.OnError := @OnError; FTCPServer.OnError := @OnError;
FQuit := False; FQuit := False;
FLastFlush := Now; FLastFlush := Now;
FLastNetCheck := Now;
end; end;
destructor TCEDServer.Destroy; destructor TCEDServer.Destroy;
@@ -321,7 +323,11 @@ begin
begin begin
repeat repeat
FTCPServer.CallAction; FTCPServer.CallAction;
CheckNetStates; if SecondsBetween(FLastNetCheck, Now) >= 1 then
begin
CheckNetStates;
FLastNetCheck := Now;
end;
if SecondsBetween(FLastFlush, Now) >= 60 then if SecondsBetween(FLastFlush, Now) >= 60 then
begin begin
FLandscape.Flush; FLandscape.Flush;
@@ -349,7 +355,8 @@ begin
while FTCPServer.IterNext do while FTCPServer.IterNext do
begin begin
netState := TNetState(FTCPServer.Iterator.UserData); netState := TNetState(FTCPServer.Iterator.UserData);
if (netState <> nil) and (FTCPServer.Iterator.ConnectionStatus = scConnected) then if (netState <> nil) and (netState.Account <> nil) and
(FTCPServer.Iterator.ConnectionStatus = scConnected) then
begin begin
netState.SendQueue.Seek(0, soFromEnd); netState.SendQueue.Seek(0, soFromEnd);
netState.SendQueue.CopyFrom(APacket.Stream, 0); netState.SendQueue.CopyFrom(APacket.Stream, 0);