@Think3r, @pspzockerscene, @coalado
Any chance to get this patch upstream in JDownloader?
It's still working fine here with interface name!
Quote:
Originally Posted by schwa226
This patch will add the option to enter a network interface name for direct gateway:
Code:
Index: src/jd/http/Request.java
===================================================================
--- src/jd/http/Request.java (revision 41595)
+++ src/jd/http/Request.java (working copy)
@@ -21,11 +21,16 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.NetworkInterface;
+import java.net.InetAddress;
+import java.net.SocketException;
import java.nio.charset.CharacterCodingException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
+import java.util.Enumeration;
+import java.util.Collections;
import org.appwork.exceptions.ThrowUncheckedException;
import org.appwork.exceptions.WTFException;
@@ -897,6 +902,29 @@
this.proxy = proxy;
} else {
this.proxy = new ClonedProxy(proxy);
+ switch (this.proxy.getType()) {
+ case DIRECT:
+ Enumeration<NetworkInterface> nets = null;
+ try {
+ nets = NetworkInterface.getNetworkInterfaces();
+ } catch (SocketException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (nets != null) {
+ for (NetworkInterface netint : Collections.list(nets)) {
+ if (StringUtils.equalsIgnoreCase(netint.getDisplayName(), this.proxy.getLocal())) {
+ Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
+ if (inetAddresses.hasMoreElements()) {
+ this.proxy.setLocal(inetAddresses.nextElement().getHostAddress());
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
}
}
Get the interface name by ipconfig/ifconfig and enter it as "Host/IP/Address". JDBrowser will search all adapter for a matching display name and use the IP for this direct proxy. This solve the issue of a dynamic IP on interfaces.
The patch is quick and dirty as I am not a Java programer
|