Ban before disconnecting client

This commit is contained in:
juanjp600
2016-09-02 22:49:40 -03:00
parent 03948d5f58
commit 4b10ca21c4
2 changed files with 21 additions and 21 deletions

View File

@@ -554,14 +554,14 @@ namespace Barotrauma.Networking
case ClientNetObject.SYNC_IDS:
//TODO: might want to use a clever class for this
UInt32 lastLobbyUpdID = inc.ReadUInt32();
if (lastLobbyUpdID > c.lastRecvLobbyUpdate)
{
c.lastRecvLobbyUpdate = lastLobbyUpdID;
if (lastLobbyUpdID > c.lastRecvLobbyUpdate)
{
c.lastRecvLobbyUpdate = lastLobbyUpdID;
}
UInt32 lastChatID = inc.ReadUInt32();
if (lastChatID > c.lastRecvChatMsgID)
{
c.lastRecvChatMsgID = lastChatID;
UInt32 lastChatID = inc.ReadUInt32();
if (lastChatID > c.lastRecvChatMsgID)
{
c.lastRecvChatMsgID = lastChatID;
}
break;
case ClientNetObject.CHAT_MESSAGE:
@@ -604,36 +604,36 @@ namespace Barotrauma.Networking
private void ClientWriteLobby(Client c)
{
NetOutgoingMessage outmsg = server.CreateMessage();
outmsg.Write((byte)ServerPacketHeader.UPDATE_LOBBY);
outmsg.Write((byte)ServerPacketHeader.UPDATE_LOBBY);
outmsg.Write((byte)ServerNetObject.SYNC_IDS);
if (c.lastRecvLobbyUpdate<GameMain.NetLobbyScreen.LastUpdateID)
if (c.lastRecvLobbyUpdate<GameMain.NetLobbyScreen.LastUpdateID)
{
outmsg.Write(true);
outmsg.Write(true);
outmsg.WritePadBits();
outmsg.Write(GameMain.NetLobbyScreen.LastUpdateID);
outmsg.Write(GameMain.NetLobbyScreen.GetServerName());
outmsg.Write(GameMain.NetLobbyScreen.ServerMessage);
if (c.lastRecvLobbyUpdate < 1)
if (c.lastRecvLobbyUpdate < 1)
{
var subList = GameMain.NetLobbyScreen.GetSubList();
outmsg.Write((UInt16)subList.Count);
for (int i = 0; i < subList.Count; i++)
for (int i = 0; i < subList.Count; i++)
{
outmsg.Write(subList[i].Name);
outmsg.Write(subList[i].MD5Hash.ToString());
}
}
else
{
outmsg.Write((UInt16)0);
else
{
outmsg.Write((UInt16)0);
}
}
else
{
outmsg.Write(false);
outmsg.WritePadBits();
else
{
outmsg.Write(false);
outmsg.WritePadBits();
}
outmsg.Write(c.lastSentChatMsgID); //send this to client so they know which chat messages weren't received by the server

View File

@@ -102,9 +102,9 @@ namespace Barotrauma.Networking
if (unauthClient.failedAttempts > 3)
{
//disconnect and ban after too many failed attempts
banList.BanPlayer("Unnamed", unauthClient.Connection.RemoteEndPoint.Address.ToString());
unauthClient.Connection.Disconnect("Too many failed login attempts. You have been automatically banned from the server.");
unauthenticatedClients.Remove(unauthClient);
banList.BanPlayer("Unnamed", unauthClient.Connection.RemoteEndPoint.Address.ToString());
unauthClient = null;
return;
}