mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-24 12:15:17 +00:00
only broadcast the DisconnectPacket if the client was connected
Otherwise port scans, banned players or clients failing to initialize correctly,
will cause the server to send unnecessary packets to all connected clients.
They currently are informed about a disconnect for a client that hasn't even connected correctly.
(cherry picked from commit 4b04a3d5be
)
This commit is contained in:
parent
e14616030c
commit
76fc4a80a6
1 changed files with 6 additions and 2 deletions
|
@ -308,6 +308,8 @@ public class Server {
|
||||||
disconnect:
|
disconnect:
|
||||||
Logger.Info($"Client {socket.RemoteEndPoint} ({client.Name}/{client.Id}) disconnected from the server");
|
Logger.Info($"Client {socket.RemoteEndPoint} ({client.Name}/{client.Id}) disconnected from the server");
|
||||||
|
|
||||||
|
close:
|
||||||
|
bool wasConnected = client.Connected;
|
||||||
// Clients.Remove(client)
|
// Clients.Remove(client)
|
||||||
client.Connected = false;
|
client.Connected = false;
|
||||||
try {
|
try {
|
||||||
|
@ -316,8 +318,10 @@ public class Server {
|
||||||
catch { /*lol*/ }
|
catch { /*lol*/ }
|
||||||
|
|
||||||
#pragma warning disable CS4014
|
#pragma warning disable CS4014
|
||||||
Task.Run(() => Broadcast(new DisconnectPacket(), client))
|
if (wasConnected) {
|
||||||
.ContinueWith(x => { if (x.Exception != null) { Logger.Error(x.Exception.ToString()); } });
|
Task.Run(() => Broadcast(new DisconnectPacket(), client))
|
||||||
|
.ContinueWith(x => { if (x.Exception != null) { Logger.Error(x.Exception.ToString()); } });
|
||||||
|
}
|
||||||
#pragma warning restore CS4014
|
#pragma warning restore CS4014
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue