mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-01 01:41:55 +00:00
Using regex to check ipv4 and fixing allowlist ips
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user