The same name can be added more than once to whitelist
This commit is contained in:
@@ -62,19 +62,19 @@ namespace Barotrauma.Networking
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line[0] == '#')
|
||||
{
|
||||
string lineval = line.Substring(1, line.Length - 1);
|
||||
if (lineval.ToLower()=="true" || Convert.ToInt32(lineval)!=0)
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
if (line[0] == '#')
|
||||
{
|
||||
string lineval = line.Substring(1, line.Length - 1);
|
||||
if (lineval.ToLower()=="true" || Convert.ToInt32(lineval)!=0)
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
string[] separatedLine = line.Split(',');
|
||||
if (separatedLine.Length < 2) continue;
|
||||
@@ -94,13 +94,13 @@ namespace Barotrauma.Networking
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
|
||||
if (enabled)
|
||||
if (enabled)
|
||||
{
|
||||
lines.Add("#true");
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.Add("#false");
|
||||
else
|
||||
{
|
||||
lines.Add("#false");
|
||||
}
|
||||
foreach (WhiteListedPlayer wlp in whitelistedPlayers)
|
||||
{
|
||||
@@ -115,8 +115,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
DebugConsole.ThrowError("Saving the whitelist to " + SavePath + " failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsWhiteListed(string name, string ip)
|
||||
{
|
||||
if (!enabled) return true;
|
||||
@@ -142,16 +142,16 @@ namespace Barotrauma.Networking
|
||||
enabledTick.OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
enabled = !enabled;
|
||||
if (enabled)
|
||||
{
|
||||
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
if (!IsWhiteListed(c.name,c.Connection.RemoteEndPoint.Address.ToString()))
|
||||
{
|
||||
whitelistedPlayers.Add(new WhiteListedPlayer(c.name, c.Connection.RemoteEndPoint.Address.ToString()));
|
||||
CloseFrame(); CreateWhiteListFrame();
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
if (!IsWhiteListed(c.name,c.Connection.RemoteEndPoint.Address.ToString()))
|
||||
{
|
||||
whitelistedPlayers.Add(new WhiteListedPlayer(c.name, c.Connection.RemoteEndPoint.Address.ToString()));
|
||||
CloseFrame(); CreateWhiteListFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
Save();
|
||||
return true;
|
||||
@@ -207,7 +207,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
private bool AddToWhiteList(GUIButton button, object obj)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(nameBox.Text) || whitelistedPlayers.Find(x => x.Name.ToLower() == nameBox.Text.ToLower()) != null) return false;
|
||||
if (string.IsNullOrWhiteSpace(nameBox.Text)) return false;
|
||||
if (whitelistedPlayers.Find(x => x.Name.ToLower() == nameBox.Text.ToLower() && x.IP == ipBox.Text) != null) return false;
|
||||
whitelistedPlayers.Add(new WhiteListedPlayer(nameBox.Text,ipBox.Text));
|
||||
Save();
|
||||
CloseFrame(); CreateWhiteListFrame();
|
||||
|
||||
@@ -396,10 +396,10 @@ namespace Barotrauma
|
||||
|
||||
GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||
settingsButton.UserData = "settingsButton";
|
||||
|
||||
GUIButton whitelistButton = new GUIButton(new Rectangle(-200, 0, 80, 30), "Whitelist", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
whitelistButton.OnClicked = GameMain.Server.ToggleWhiteListFrame;
|
||||
settingsButton.UserData = "settingsButton";
|
||||
|
||||
GUIButton whitelistButton = new GUIButton(new Rectangle(-200, 0, 80, 30), "Whitelist", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
whitelistButton.OnClicked = GameMain.Server.ToggleWhiteListFrame;
|
||||
whitelistButton.UserData = "whitelistButton";
|
||||
|
||||
if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub));
|
||||
@@ -895,8 +895,8 @@ namespace Barotrauma
|
||||
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||
{
|
||||
GameMain.Client.KickPlayer(userData.ToString(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -911,8 +911,8 @@ namespace Barotrauma
|
||||
else if (GameMain.Client != null && GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||
{
|
||||
GameMain.Client.KickPlayer(userData.ToString(), true, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user