Bypass virtual nif

pull/590/head
FongMi 12 months ago
parent 80c1a9cf63
commit e979a01a89
  1. 29
      catvod/src/main/java/com/github/catvod/utils/Util.java

@ -126,6 +126,22 @@ public class Util {
}
}
private static String getHostAddress() throws SocketException {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface networkInterface = en.nextElement();
byte[] mac = networkInterface.getHardwareAddress();
String name = networkInterface.getName();
if (mac == null || name.startsWith("veth") || name.startsWith("tun") || name.startsWith("tap")) continue;
for (Enumeration<InetAddress> addresses = networkInterface.getInetAddresses(); addresses.hasMoreElements(); ) {
InetAddress inetAddress = addresses.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
return "";
}
public static String digest(String userInfo, String header, Request request) {
Map<String, String> params = parse(header.substring(7));
String[] parts = userInfo.split(":", 2);
@ -154,19 +170,6 @@ public class Util {
return auth.toString();
}
private static String getHostAddress() throws SocketException {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface interfaces = en.nextElement();
for (Enumeration<InetAddress> addresses = interfaces.getInetAddresses(); addresses.hasMoreElements(); ) {
InetAddress inetAddress = addresses.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
return "";
}
private static Map<String, String> parse(String header) {
Map<String, String> params = new HashMap<>();
for (String part : header.split(",\\s*")) {

Loading…
Cancel
Save