- Added ip exemptions in addition to the existing player exemptions./
- Fixing System.out usage warnings that some users were experiencing.
- Fixing MySQL drivers not loading on some servers.
- Fixing bug that would make whitelisted players not load for awhile after server starts
This commit is contained in:
Dawson Hessler
2021-11-04 10:36:31 -04:00
parent 5ba19b42f9
commit a9d356a04a
14 changed files with 287 additions and 76 deletions
@@ -1,6 +1,16 @@
package dev.brighten.antivpn.utils;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
public class MiscUtils {
@@ -20,4 +30,44 @@ public class MiscUtils {
}
}
public static boolean isIpv4(String ip)
{
try {
InetAddress address = InetAddress.getByName(ip);
return address instanceof Inet4Address;
} catch(Exception e) {
return false;
}
}
/* Borrowed from FireFlyx ngxdev */
public static void download(File file, String from) throws Exception {
URL url = new URL(from);
InputStream stream = url.openStream();
ReadableByteChannel channel = Channels.newChannel(stream);
FileOutputStream out = new FileOutputStream(file);
out.getChannel().transferFrom(channel, 0L, Long.MAX_VALUE);
}
/* Borrowed from FireFlyx ngxdev */
public static ClassLoader injectorClassLoader = MiscUtils.class.getClassLoader();
/* Borrowed from FireFlyx ngxdev */
public static void injectURL(URL url) {
try {
URLClassLoader systemClassLoader = (URLClassLoader) injectorClassLoader;
Class<URLClassLoader> classLoaderClass = URLClassLoader.class;
try {
Method method = classLoaderClass.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(systemClassLoader, url);
} catch (Throwable t) {
t.printStackTrace();
}
} catch (Exception e) {
}
}
}