Using regex to check ipv4 and fixing allowlist ips

This commit is contained in:
funkemunky
2022-02-21 08:19:46 -05:00
parent 2afb31b073
commit a6aac8fce7
2 changed files with 10 additions and 10 deletions
@@ -11,9 +11,12 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.regex.Pattern;
public class MiscUtils {
private static final Pattern ipv4 = Pattern.compile("[1-9]{1,3}\\.[1-9]{1,3}\\.[1-9]{1,3}.[1-9]{1,3}");
public static void close(Closeable... closeables) {
try {
for (Closeable closeable : closeables) if (closeable != null) closeable.close();
@@ -32,13 +35,6 @@ public class MiscUtils {
public static boolean isIpv4(String ip)
{
try {
InetAddress address = InetAddress.getByName(ip);
return address instanceof Inet4Address;
} catch(Exception e) {
return false;
}
return ipv4.matcher(ip).matches();
}
}