Option to supply a reason for banning/kicking, logic for handling question prompts in the debug console

This commit is contained in:
Joonas Rikkonen
2017-07-02 15:25:55 +03:00
parent fb5db81d10
commit da71b6bf9c
11 changed files with 185 additions and 142 deletions
@@ -29,6 +29,7 @@ namespace Barotrauma.Networking
Alignment.Left, Alignment.Left, banFrame); Alignment.Left, Alignment.Left, banFrame);
textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f); textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f);
textBlock.UserData = banFrame; textBlock.UserData = banFrame;
textBlock.ToolTip = bannedPlayer.Reason;
var removeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Remove", Alignment.Right | Alignment.CenterY, "", textBlock); var removeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Remove", Alignment.Right | Alignment.CenterY, "", textBlock);
removeButton.UserData = bannedPlayer; removeButton.UserData = bannedPlayer;
@@ -565,26 +565,23 @@ namespace Barotrauma.Networking
{ {
string disconnectMsg = inc.ReadString(); string disconnectMsg = inc.ReadString();
switch (disconnectMsg) if (disconnectMsg.Contains("You have been disconnected") ||
disconnectMsg.Contains("You have been banned") ||
disconnectMsg.Contains("You have been kicked") ||
disconnectMsg == "The server has been shut down")
{ {
case "The server has been shut down": var msgBox = new GUIMessageBox("CONNECTION LOST", disconnectMsg);
case "You have been banned from the server": msgBox.Buttons[0].OnClicked += ReturnToServerList;
case "You have been kicked from the server":
case "You have been disconnected because of excessive desync":
case "You have been disconnected because syncing your client with the server took too long.":
var msgBox = new GUIMessageBox("CONNECTION LOST", disconnectMsg);
msgBox.Buttons[0].OnClicked += ReturnToServerList;
break;
default:
reconnectBox = new GUIMessageBox(
"CONNECTION LOST",
"You have been disconnected from the server. Reconnecting...", new string[0]);
connected = false;
ConnectToServer(serverIP);
break;
} }
else
{
reconnectBox = new GUIMessageBox(
"CONNECTION LOST",
"You have been disconnected from the server. Reconnecting...", new string[0]);
connected = false;
ConnectToServer(serverIP);
}
} }
break; break;
} }
@@ -1244,7 +1241,7 @@ namespace Barotrauma.Networking
return true; return true;
} }
public override void KickPlayer(string kickedName, bool ban, bool range = false) public override void KickPlayer(string kickedName, string reason, bool ban, bool range = false)
{ {
NetOutgoingMessage msg = client.CreateMessage(); NetOutgoingMessage msg = client.CreateMessage();
msg.Write((byte)ClientPacketHeader.SERVER_COMMAND); msg.Write((byte)ClientPacketHeader.SERVER_COMMAND);
@@ -161,5 +161,20 @@ namespace Barotrauma.Networking
{ {
return false; return false;
} }
public void CreateKickReasonPrompt(string clientName, bool ban, bool rangeBan = false)
{
var banReasonPrompt = new GUIMessageBox(ban ? "Reason for the ban?" : "Reason for kicking?", "", new string[] { "OK" }, 400, 250);
var textBox = new GUITextBox(new Rectangle(0, 0, 0, 50), Alignment.Center, "", banReasonPrompt.children[0]);
textBox.Wrap = true;
textBox.MaxTextLength = 100;
banReasonPrompt.Buttons[0].OnClicked += (btn, userData) =>
{
KickPlayer(clientName, textBox.Text, ban, rangeBan);
return true;
};
banReasonPrompt.Buttons[0].OnClicked += banReasonPrompt.Close;
}
} }
} }
@@ -893,49 +893,22 @@ namespace Barotrauma
public bool KickPlayer(GUIButton button, object userData) public bool KickPlayer(GUIButton button, object userData)
{ {
if (userData == null) return false; if (userData == null || GameMain.NetworkMember == null) return false;
GameMain.NetworkMember.CreateKickReasonPrompt(userData.ToString(), false);
if (GameMain.Server != null)
{
GameMain.Server.KickPlayer(userData.ToString(), false);
}
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Kick))
{
GameMain.Client.KickPlayer(userData.ToString(), false);
}
return false; return false;
} }
public bool BanPlayer(GUIButton button, object userData) public bool BanPlayer(GUIButton button, object userData)
{ {
if (userData == null) return false; if (userData == null || GameMain.NetworkMember == null) return false;
GameMain.NetworkMember.CreateKickReasonPrompt(userData.ToString(), true);
if (GameMain.Server != null)
{
GameMain.Server.KickPlayer(userData.ToString(), true);
}
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
{
GameMain.Client.KickPlayer(userData.ToString(), true);
}
return false; return false;
} }
public bool BanPlayerRange(GUIButton button, object userData) public bool BanPlayerRange(GUIButton button, object userData)
{ {
if (userData == null) return false; if (userData == null || GameMain.NetworkMember == null) return false;
GameMain.NetworkMember.CreateKickReasonPrompt(userData.ToString(), true, true);
if (GameMain.Server != null)
{
GameMain.Server.KickPlayer(userData.ToString(), true, true);
}
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
{
GameMain.Client.KickPlayer(userData.ToString(), true, true);
}
return false; return false;
} }
@@ -141,7 +141,6 @@ namespace Barotrauma
#endif #endif
default: default:
return false; return false;
break;
} }
return true; //command found return true; //command found
} }
@@ -32,6 +32,10 @@ namespace Barotrauma
public static List<ColoredText> Messages = new List<ColoredText>(); public static List<ColoredText> Messages = new List<ColoredText>();
private delegate void QuestionCallback(string answer);
private static QuestionCallback activeQuestionCallback;
private static GUIComponent activeQuestionText;
private static string[] SplitCommand(string command) private static string[] SplitCommand(string command)
{ {
command = command.Trim(); command = command.Trim();
@@ -41,7 +45,7 @@ namespace Barotrauma
bool inQuotes = false; bool inQuotes = false;
string piece = ""; string piece = "";
for (int i=0;i<command.Length;i++) for (int i = 0; i < command.Length; i++)
{ {
if (command[i] == '\\') if (command[i] == '\\')
{ {
@@ -71,6 +75,15 @@ namespace Barotrauma
public static void ExecuteCommand(string command, GameMain game) public static void ExecuteCommand(string command, GameMain game)
{ {
if (string.IsNullOrWhiteSpace(command)) return; if (string.IsNullOrWhiteSpace(command)) return;
if (activeQuestionCallback != null)
{
activeQuestionText = null;
activeQuestionCallback(command);
activeQuestionCallback = null;
return;
}
string[] commands = SplitCommand(command); string[] commands = SplitCommand(command);
if (!commands[0].ToLowerInvariant().Equals("admin")) if (!commands[0].ToLowerInvariant().Equals("admin"))
@@ -95,7 +108,7 @@ namespace Barotrauma
DebugConsole.NewMessage("***************", Color.Cyan); DebugConsole.NewMessage("***************", Color.Cyan);
foreach (Client c in GameMain.Server.ConnectedClients) foreach (Client c in GameMain.Server.ConnectedClients)
{ {
DebugConsole.NewMessage("- " + c.ID.ToString() + ": " + c.name + ", " + c.Connection.RemoteEndPoint.Address.ToString(),Color.Cyan); DebugConsole.NewMessage("- " + c.ID.ToString() + ": " + c.name + ", " + c.Connection.RemoteEndPoint.Address.ToString(), Color.Cyan);
} }
DebugConsole.NewMessage("***************", Color.Cyan); DebugConsole.NewMessage("***************", Color.Cyan);
break; break;
@@ -208,7 +221,7 @@ namespace Barotrauma
if (spawnPoint != null) spawnPosition = spawnPoint.WorldPosition; if (spawnPoint != null) spawnPosition = spawnPoint.WorldPosition;
if (commands[1].ToLowerInvariant()=="human") if (commands[1].ToLowerInvariant() == "human")
{ {
spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition); spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition);
@@ -261,7 +274,7 @@ namespace Barotrauma
var itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == itemName) as ItemPrefab; var itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == itemName) as ItemPrefab;
if (itemPrefab == null) if (itemPrefab == null)
{ {
ThrowError("Item \""+itemName+"\" not found!"); ThrowError("Item \"" + itemName + "\" not found!");
return; return;
} }
@@ -302,47 +315,62 @@ namespace Barotrauma
} }
break;*/ break;*/
case "kick": case "kick":
if (GameMain.NetworkMember == null || commands.Length < 2) break; if (GameMain.NetworkMember != null && commands.Length >= 2)
GameMain.NetworkMember.KickPlayer(string.Join(" ", commands.Skip(1)), false); {
string playerName = string.Join(" ", commands.Skip(1));
ShowQuestionPrompt("Reason for kicking \"" + playerName + "\"?", (answer) =>
{
GameMain.NetworkMember.KickPlayer(playerName, answer, false);
});
}
break; break;
case "kickid": case "kickid":
if (GameMain.Server == null || commands.Length < 2) break;
{
int id = 0;
int.TryParse(commands[1], out id);
GameMain.Server.KickPlayer(id, false);
}
break;
case "banid": case "banid":
if (GameMain.Server == null || commands.Length < 2) break; if (GameMain.Server != null && commands.Length >= 2)
{ {
bool ban = commands[0].ToLowerInvariant() == "banid";
int id = 0; int id = 0;
int.TryParse(commands[1], out id); int.TryParse(commands[1], out id);
GameMain.Server.KickPlayer(id, true); var client = GameMain.Server.ConnectedClients.Find(c => c.ID == id);
}
break;
case "ban":
if (GameMain.NetworkMember == null || commands.Length < 2) break;
GameMain.NetworkMember.KickPlayer(string.Join(" ", commands.Skip(1)), true);
break;
case "banip":
{
if (GameMain.Server == null || commands.Length < 2) break;
var client = GameMain.Server.ConnectedClients.Find(c => c.Connection.RemoteEndPoint.Address.ToString() == commands[1]);
if (client == null) if (client == null)
{ {
GameMain.Server.BanList.BanPlayer("Unnamed", commands[1]); ThrowError("Client id \"" + id + "\" not found.");
return;
} }
else
ShowQuestionPrompt(ban ? "Reason for banning \"" + client.name + "\"?" : "Reason for kicking \"" + client.name + "\"?", (answer) =>
{ {
GameMain.Server.KickClient(client, true); GameMain.Server.KickPlayer(client.name, answer, ban);
} });
}
break;
case "ban":
if (GameMain.NetworkMember != null || commands.Length >= 2)
{
string clientName = string.Join(" ", commands.Skip(1));
ShowQuestionPrompt("Reason for banning \"" + clientName + "\"?", (answer) =>
{
GameMain.NetworkMember.KickPlayer(clientName, answer, true);
});
}
break;
case "banip":
if (GameMain.Server != null || commands.Length >= 2)
{
ShowQuestionPrompt("Reason for banning the ip \"" + commands[1] + "\"?", (answer) =>
{
var client = GameMain.Server.ConnectedClients.Find(c => c.Connection.RemoteEndPoint.Address.ToString() == commands[1]);
if (client == null)
{
GameMain.Server.BanList.BanPlayer("Unnamed", commands[1], answer);
}
else
{
GameMain.Server.KickClient(client, answer, true);
}
});
} }
break; break;
case "teleportcharacter": case "teleportcharacter":
@@ -367,6 +395,7 @@ namespace Barotrauma
if (Submarine.MainSub == null) return; if (Submarine.MainSub == null) return;
Submarine.MainSub.GodMode = !Submarine.MainSub.GodMode; Submarine.MainSub.GodMode = !Submarine.MainSub.GodMode;
NewMessage(Submarine.MainSub.GodMode ? "Godmode on" : "Godmode off", Color.White);
break; break;
case "lockx": case "lockx":
Submarine.LockX = !Submarine.LockX; Submarine.LockX = !Submarine.LockX;
@@ -441,7 +470,11 @@ namespace Barotrauma
break; break;
case "editwater": case "editwater":
case "water": case "water":
if (GameMain.Client == null) Hull.EditWater = !Hull.EditWater; if (GameMain.Client == null)
{
Hull.EditWater = !Hull.EditWater;
NewMessage(Hull.EditWater ? "Water editing on" : "Water editing off", Color.White);
}
break; break;
case "explosion": case "explosion":
@@ -453,7 +486,11 @@ namespace Barotrauma
new Explosion(range, force, damage, damage).Explode(explosionPos); new Explosion(range, force, damage, damage).Explode(explosionPos);
break; break;
case "fire": case "fire":
if (GameMain.Client == null) Hull.EditFire = !Hull.EditFire; if (GameMain.Client == null)
{
Hull.EditFire = !Hull.EditFire;
NewMessage(Hull.EditWater ? "Fire spawning on" : "Fire spawning off", Color.White);
}
break; break;
case "fixitems": case "fixitems":
@@ -604,9 +641,27 @@ namespace Barotrauma
} }
selectedIndex = listBox.children.Count; selectedIndex = listBox.children.Count;
if (activeQuestionText != null)
{
//make sure the active question stays at the bottom of the list
listBox.children.Remove(activeQuestionText);
listBox.children.Add(activeQuestionText);
}
#endif #endif
} }
private static void ShowQuestionPrompt(string question, QuestionCallback onAnswered)
{
NewMessage(" >>" + question, Color.Cyan);
activeQuestionCallback += onAnswered;
if (listBox != null && listBox.children.Count > 0)
{
activeQuestionText = listBox.children[listBox.children.Count - 1];
}
}
public static void Log(string message) public static void Log(string message)
{ {
if (GameSettings.VerboseLogging) NewMessage(message, Color.Gray); if (GameSettings.VerboseLogging) NewMessage(message, Color.Gray);
@@ -3,7 +3,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma.Networking namespace Barotrauma.Networking
{ {
@@ -11,11 +10,12 @@ namespace Barotrauma.Networking
{ {
public string Name; public string Name;
public string IP; public string IP;
public string Reason;
public bool CompareTo(string ipCompare) public bool CompareTo(string ipCompare)
{ {
int rangeBanIndex = IP.IndexOf(".x"); int rangeBanIndex = IP.IndexOf(".x");
if (rangeBanIndex<=-1) if (rangeBanIndex <= -1)
{ {
return ipCompare == IP; return ipCompare == IP;
} }
@@ -26,10 +26,11 @@ namespace Barotrauma.Networking
} }
} }
public BannedPlayer(string name, string ip) public BannedPlayer(string name, string ip, string reason)
{ {
this.Name = name; this.Name = name;
this.IP = ip; this.IP = ip;
this.Reason = reason;
} }
} }
@@ -61,21 +62,24 @@ namespace Barotrauma.Networking
string[] separatedLine = line.Split(','); string[] separatedLine = line.Split(',');
if (separatedLine.Length < 2) continue; if (separatedLine.Length < 2) continue;
string name = String.Join(",", separatedLine.Take(separatedLine.Length - 1)); string name = separatedLine[0];
string ip = separatedLine.Last(); string ip = separatedLine[1];
string reason = separatedLine.Length > 2 ? string.Join(",", separatedLine.Skip(2)) : "";
bannedPlayers.Add(new BannedPlayer(name, ip)); bannedPlayers.Add(new BannedPlayer(name, ip,reason));
} }
} }
} }
public void BanPlayer(string name, string ip) public void BanPlayer(string name, string ip, string reason)
{ {
if (bannedPlayers.Any(bp => bp.IP == ip)) return; if (bannedPlayers.Any(bp => bp.IP == ip)) return;
System.Diagnostics.Debug.Assert(!name.Contains(','));
DebugConsole.Log("Banned " + name); DebugConsole.Log("Banned " + name);
bannedPlayers.Add(new BannedPlayer(name, ip)); bannedPlayers.Add(new BannedPlayer(name, ip, reason));
Save(); Save();
} }
@@ -131,7 +135,9 @@ namespace Barotrauma.Networking
foreach (BannedPlayer banned in bannedPlayers) foreach (BannedPlayer banned in bannedPlayers)
{ {
lines.Add(banned.Name + "," + banned.IP); string line = banned.Name + "," + banned.IP;
if (!string.IsNullOrWhiteSpace(banned.Reason)) line += "," + banned.Reason;
lines.Add(line);
} }
try try
@@ -172,7 +172,7 @@ namespace Barotrauma.Networking
if (c.ChatSpamCount > 3) if (c.ChatSpamCount > 3)
{ {
//kick for spamming too much //kick for spamming too much
GameMain.Server.KickClient(c); GameMain.Server.KickClient(c, "You have been kicked by the spam filter.");
} }
else else
{ {
@@ -531,7 +531,7 @@ namespace Barotrauma.Networking
{ {
if (banList.IsBanned(inc.SenderEndPoint.Address.ToString())) if (banList.IsBanned(inc.SenderEndPoint.Address.ToString()))
{ {
KickClient(inc.SenderConnection, true); KickClient(inc.SenderConnection, "You have been banned from the server.", true);
return; return;
} }
@@ -727,8 +727,8 @@ namespace Barotrauma.Networking
private void ClientReadServerCommand(NetIncomingMessage inc) private void ClientReadServerCommand(NetIncomingMessage inc)
{ {
Client c = ConnectedClients.Find(x => x.Connection == inc.SenderConnection); Client sender = ConnectedClients.Find(x => x.Connection == inc.SenderConnection);
if (c == null) if (sender == null)
{ {
inc.SenderConnection.Disconnect("You're not a connected client."); inc.SenderConnection.Disconnect("You're not a connected client.");
return; return;
@@ -745,9 +745,9 @@ namespace Barotrauma.Networking
return; return;
} }
if (!c.HasPermission(command)) if (!sender.HasPermission(command))
{ {
Log("Client \""+c.name+"\" sent a server command \""+command+"\". Permission denied.", ServerLog.MessageType.ServerMessage); Log("Client \""+sender.name+"\" sent a server command \""+command+"\". Permission denied.", ServerLog.MessageType.ServerMessage);
return; return;
} }
@@ -755,26 +755,26 @@ namespace Barotrauma.Networking
{ {
case ClientPermissions.Kick: case ClientPermissions.Kick:
string kickedName = inc.ReadString(); string kickedName = inc.ReadString();
var kickedClient = connectedClients.Find(cl => cl != c && cl.name == kickedName); var kickedClient = connectedClients.Find(cl => cl != sender && cl.name == kickedName);
if (kickedClient != null) if (kickedClient != null)
{ {
Log("Client \"" + c.name + "\" kicked \"" + kickedClient.name + "\".", ServerLog.MessageType.ServerMessage); Log("Client \"" + sender.name + "\" kicked \"" + kickedClient.name + "\".", ServerLog.MessageType.ServerMessage);
KickClient(kickedClient, false, false); KickClient(kickedClient, "Kicked by " + sender.name, false, false);
} }
break; break;
case ClientPermissions.Ban: case ClientPermissions.Ban:
string bannedName = inc.ReadString(); string bannedName = inc.ReadString();
var bannedClient = connectedClients.Find(cl => cl != c && cl.name == bannedName); var bannedClient = connectedClients.Find(cl => cl != sender && cl.name == bannedName);
if (bannedClient != null) if (bannedClient != null)
{ {
Log("Client \"" + c.name + "\" banned \"" + bannedClient.name + "\".", ServerLog.MessageType.ServerMessage); Log("Client \"" + sender.name + "\" banned \"" + bannedClient.name + "\".", ServerLog.MessageType.ServerMessage);
KickClient(bannedClient, true, false); KickClient(bannedClient, "Banned by " + sender.name, true, false);
} }
break; break;
case ClientPermissions.EndRound: case ClientPermissions.EndRound:
if (gameStarted) if (gameStarted)
{ {
Log("Client \"" + c.name + "\" ended the round.", ServerLog.MessageType.ServerMessage); Log("Client \"" + sender.name + "\" ended the round.", ServerLog.MessageType.ServerMessage);
EndGame(); EndGame();
} }
break; break;
@@ -1416,7 +1416,7 @@ namespace Barotrauma.Networking
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
public override void KickPlayer(string playerName, bool ban, bool range=false) public override void KickPlayer(string playerName, string reason, bool ban, bool range = false)
{ {
playerName = playerName.ToLowerInvariant(); playerName = playerName.ToLowerInvariant();
@@ -1424,17 +1424,10 @@ namespace Barotrauma.Networking
c.name.ToLowerInvariant() == playerName || c.name.ToLowerInvariant() == playerName ||
(c.Character != null && c.Character.Name.ToLowerInvariant() == playerName)); (c.Character != null && c.Character.Name.ToLowerInvariant() == playerName));
KickClient(client, ban, range); KickClient(client, reason, ban, range);
} }
public void KickPlayer(int id,bool ban,bool range=false) public void KickClient(NetConnection conn, string reason, bool ban = false, bool range = false)
{
Client client = connectedClients.Find(c => c.ID == id);
KickClient(client, ban, range);
}
public void KickClient(NetConnection conn, bool ban = false, bool range = false)
{ {
Client client = connectedClients.Find(c => c.Connection == conn); Client client = connectedClients.Find(c => c.Connection == conn);
if (client == null) if (client == null)
@@ -1444,30 +1437,34 @@ namespace Barotrauma.Networking
{ {
if (!banList.IsBanned(conn.RemoteEndPoint.Address.ToString())) if (!banList.IsBanned(conn.RemoteEndPoint.Address.ToString()))
{ {
banList.BanPlayer("Unnamed", conn.RemoteEndPoint.Address.ToString()); banList.BanPlayer("Unnamed", conn.RemoteEndPoint.Address.ToString(), reason);
} }
} }
} }
else else
{ {
KickClient(client, ban, range); KickClient(client, reason, ban, range);
} }
} }
public void KickClient(Client client, bool ban = false, bool range = false) public void KickClient(Client client, string reason, bool ban = false, bool range = false)
{ {
if (client == null) return; if (client == null) return;
if (ban) if (ban)
{ {
DisconnectClient(client, client.name + " has been banned from the server", "You have been banned from the server"); string msg = "You have been banned from the server.";
if (!string.IsNullOrWhiteSpace(reason)) msg += "\nReason: " + reason;
DisconnectClient(client, client.name + " has been banned from the server.", msg);
string ip = client.Connection.RemoteEndPoint.Address.ToString(); string ip = client.Connection.RemoteEndPoint.Address.ToString();
if (range) { ip = banList.ToRange(ip); } if (range) { ip = banList.ToRange(ip); }
banList.BanPlayer(client.name, ip); banList.BanPlayer(client.name, ip, reason);
} }
else else
{ {
DisconnectClient(client, client.name + " has been kicked from the server", "You have been kicked from the server"); string msg = "You have been kicked from the server.";
if (!string.IsNullOrWhiteSpace(reason)) msg += "\nReason: " + reason;
DisconnectClient(client, client.name + " has been kicked from the server.", msg);
} }
} }
@@ -1785,8 +1782,8 @@ namespace Barotrauma.Networking
var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount >= connectedClients.Count * KickVoteRequiredRatio); var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount >= connectedClients.Count * KickVoteRequiredRatio);
foreach (Client c in clientsToKick) foreach (Client c in clientsToKick)
{ {
SendChatMessage(c.name+" has been kicked from the server.", ChatMessageType.Server, null); SendChatMessage(c.name + " has been kicked from the server.", ChatMessageType.Server, null);
KickClient(c); KickClient(c, "Kicked by vote");
} }
GameMain.NetLobbyScreen.LastUpdateID++; GameMain.NetLobbyScreen.LastUpdateID++;
@@ -102,7 +102,7 @@ namespace Barotrauma.Networking
if (unauthClient.failedAttempts > 3) if (unauthClient.failedAttempts > 3)
{ {
//disconnect and ban after too many failed attempts //disconnect and ban after too many failed attempts
banList.BanPlayer("Unnamed", unauthClient.Connection.RemoteEndPoint.Address.ToString()); banList.BanPlayer("Unnamed", unauthClient.Connection.RemoteEndPoint.Address.ToString(), "Too many failed login attempts.");
DisconnectUnauthClient(inc, unauthClient, "Too many failed login attempts. You have been automatically banned from the server."); DisconnectUnauthClient(inc, unauthClient, "Too many failed login attempts. You have been automatically banned from the server.");
Log(inc.SenderConnection.RemoteEndPoint.Address.ToString() + " has been banned from the server (too many wrong passwords)", ServerLog.MessageType.Error); Log(inc.SenderConnection.RemoteEndPoint.Address.ToString() + " has been banned from the server (too many wrong passwords)", ServerLog.MessageType.Error);
@@ -191,7 +191,7 @@ namespace Barotrauma.Networking
#endif #endif
} }
public virtual void KickPlayer(string kickedName, bool ban, bool range = false) { } public virtual void KickPlayer(string kickedName, string reason, bool ban, bool range = false) { }
public virtual void Update(float deltaTime) public virtual void Update(float deltaTime)
{ {