Fixed rangeban

This commit is contained in:
juanjp600
2016-09-03 18:15:36 -03:00
parent 6f25bee9e1
commit 2116a1a93a
4 changed files with 41 additions and 39 deletions
+1
View File
@@ -157,6 +157,7 @@
<Compile Include="Source\Networking\NetStats.cs" /> <Compile Include="Source\Networking\NetStats.cs" />
<Compile Include="Source\Networking\RespawnManager.cs" /> <Compile Include="Source\Networking\RespawnManager.cs" />
<Compile Include="Source\Networking\ServerLog.cs" /> <Compile Include="Source\Networking\ServerLog.cs" />
<Compile Include="Source\Networking\WhiteList.cs" />
<Compile Include="Source\Particles\ParticleEmitter.cs" /> <Compile Include="Source\Particles\ParticleEmitter.cs" />
<Compile Include="Source\Networking\GameServerSettings.cs" /> <Compile Include="Source\Networking\GameServerSettings.cs" />
<Compile Include="Source\Screens\BlurEffect.cs" /> <Compile Include="Source\Screens\BlurEffect.cs" />
+8 -6
View File
@@ -774,7 +774,7 @@ namespace Barotrauma.Networking
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
public override void KickPlayer(string playerName, bool ban) public override void KickPlayer(string playerName, bool ban, bool range=false)
{ {
playerName = playerName.ToLowerInvariant(); playerName = playerName.ToLowerInvariant();
@@ -782,10 +782,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); KickClient(client, ban, range);
} }
public void KickClient(NetConnection conn, bool ban = false) 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)
@@ -801,18 +801,20 @@ namespace Barotrauma.Networking
} }
else else
{ {
KickClient(client, ban); KickClient(client, ban, range);
} }
} }
public void KickClient(Client client, bool ban = false) public void KickClient(Client client, 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"); DisconnectClient(client, client.name + " has been banned from the server", "You have been banned from the server");
banList.BanPlayer(client.name, client.Connection.RemoteEndPoint.Address.ToString()); string ip = client.Connection.RemoteEndPoint.Address.ToString();
if (range) { ip = banList.ToRange(ip); }
banList.BanPlayer(client.name, ip);
} }
else else
{ {
@@ -158,7 +158,6 @@ namespace Barotrauma.Networking
return; return;
} }
#endif
if (!whitelist.IsWhiteListed(name, inc.SenderConnection.RemoteEndPoint.Address.ToString())) if (!whitelist.IsWhiteListed(name, inc.SenderConnection.RemoteEndPoint.Address.ToString()))
{ {
inc.SenderConnection.Disconnect("You're not in this server's whitelist."); inc.SenderConnection.Disconnect("You're not in this server's whitelist.");