Add regex support to restricted users ip addresses #1227
Seems to work: https://regex101.com/r/zSp6Ke/1 @ljacqu What do you think?
This commit is contained in:
@@ -157,8 +157,25 @@ public class ValidationService implements Reloadable {
|
||||
|
||||
String ip = PlayerUtils.getPlayerIp(player);
|
||||
String domain = player.getAddress().getHostName();
|
||||
return restrictions.stream()
|
||||
.anyMatch(restriction -> ip.equals(restriction) || domain.equalsIgnoreCase(restriction));
|
||||
for(String restriction : restrictions) {
|
||||
if(restriction.startsWith("regex:")) {
|
||||
restriction = restriction.replace("regex:", "");
|
||||
if(ip.matches(restriction)) {
|
||||
return true;
|
||||
}
|
||||
if(domain.matches(restriction)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if(ip.equals(restriction)) {
|
||||
return true;
|
||||
}
|
||||
if(domain.equalsIgnoreCase(restriction)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user