Unban fuzzy IPs for admins. Fixes #187

This commit is contained in:
unknown 2014-05-16 15:39:40 +02:00
parent 179fe9d665
commit 00ac914066
6 changed files with 19 additions and 20 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Fri May 16 15:29:27 CEST 2014 #Fri May 16 15:39:23 CEST 2014
build.number=856 build.number=857

View File

@ -108,8 +108,7 @@ public class Command_glist extends TFM_Command
for (String ip : ips) for (String ip : ips)
{ {
TFM_BanManager.getInstance().unbanIp(ip); TFM_BanManager.getInstance().unbanIp(ip);
String[] ipParts = ip.split("\\."); TFM_BanManager.getInstance().unbanIp(TFM_Util.getFuzzyIp(ip));
TFM_BanManager.getInstance().unbanIp(ipParts[0] + "." + ipParts[1] + ".*.*");
} }
} }
else else

View File

@ -76,12 +76,7 @@ public class Command_gtfo extends TFM_Command
} }
// ban IP address: // ban IP address:
String ip = player.getAddress().getAddress().getHostAddress(); String ip = TFM_Util.getFuzzyIp(player.getAddress().getAddress().getHostAddress());
String[] ipParts = ip.split("\\.");
if (ipParts.length == 4)
{
ip = String.format("%s.%s.*.*", ipParts[0], ipParts[1]);
}
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", player.getName(), ip), ChatColor.RED); TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", player.getName(), ip), ChatColor.RED);
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), sender.getName(), null, reason)); TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), sender.getName(), null, reason));

View File

@ -714,15 +714,9 @@ public class TFM_PlayerListener implements Listener
// Verify strict IP match // Verify strict IP match
if (TFM_AdminList.isSuperAdmin(player)) if (TFM_AdminList.isSuperAdmin(player))
{ {
if (TFM_BanManager.getInstance().isIpBanned(ip)) TFM_BanManager.getInstance().unbanIp(ip);
{ TFM_BanManager.getInstance().unbanIp(TFM_Util.getFuzzyIp(ip));
TFM_BanManager.getInstance().unbanIp(ip); TFM_BanManager.getInstance().unbanUuid(player.getUniqueId());
}
if (TFM_BanManager.getInstance().isUuidBanned(player.getUniqueId()))
{
TFM_BanManager.getInstance().unbanUuid(player.getUniqueId());
}
player.setOp(true); player.setOp(true);

View File

@ -87,7 +87,7 @@ public class TFM_ServerInterface
} }
// not safe to use TFM_Util.isSuperAdmin for player logging in because player.getAddress() will return a null until after player login. // not safe to use TFM_Util.isSuperAdmin for player logging in because player.getAddress() will return a null until after player login.
boolean isAdmin; final boolean isAdmin;
if (server.getOnlineMode()) if (server.getOnlineMode())
{ {
isAdmin = TFM_AdminList.getSuperUUIDs().contains(uuid); isAdmin = TFM_AdminList.getSuperUUIDs().contains(uuid);

View File

@ -825,6 +825,17 @@ public class TFM_Util
return match; return match;
} }
public static String getFuzzyIp(String ip)
{
final String[] ipParts = ip.split("\\.");
if (ipParts.length == 4)
{
return String.format("%s.%s.*.*", ipParts[0], ipParts[1]);
}
return ip;
}
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius) public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
{ {
int affected = 0; int affected = 0;