#1
|
|||
|
|||
Any way to activate upnp for reconnection/get external IP ?
Any way to activate the use jd.nrouter.UPNPRouter for reconnection and getting the external IP?
Last edited by Jiaz; 07.07.2010 at 10:16. |
#2
|
|||
|
|||
I think this depends on your router. If you can't find that function in your router's manual, you can ask your router's manufacturer if it's supported.
See also http://jdownloader.org/knowledge/wik...ect/tools/upnp. |
#3
|
|||
|
|||
My router supports upnp, Thomson TG585 v7.
i'm using upnp to reconnect using the liveheader But this way I'm not using the full capacity of jdownloader code, jd.nrouter.UPNPRouter. And has a limitation because it can't get the external IP using upnp Router Reconnect 1.3, as is suggested in the link you posted, will only work in windows(not ubuntu), and it will not use jdownloader code the same way. |
#4
|
|||
|
|||
Any jd dev.
|
#5
|
|||
|
|||
I think this might be a language barrier problem, but I'm afraid nobody understands what you really want to achieve.
Do you have any further questions for the developers? If you want to discuss something, can you please explain what you want to discuss. |
#6
|
||||
|
||||
getting external ip with upnp is not possible at the moment. just use the balanced ip checker and all is fine.
can you provide example httpliveheader script to request external ip?
__________________
JD-Dev & Server-Admin |
#7
|
|||
|
|||
Quote:
The most common services are "WANPPPConnection:1" and "WANIPConnection:1", my is the first because my isp uses ppoe. Code:
[[[HSRC]]] [[[STEP]]] [[[REQUEST]]] POST /upnp/control/igd/wanpppcInternet HTTP/1.1 Host: %%%routerip%%% Content-Type: text/xml; charset="utf-8" SOAPAction: "urn:schemas-upnp-org:service:WANPPPConnection:1#GetExternalIPAddress" <?xml version="1.0"?> <s:Envelope xmlns:s="**External links are only visible to Support Staff** s:encodingStyle="**External links are only visible to Support Staff**> <s:Body> <m:GetExternalIPAddress xmlns:m="urn:schemas-upnp-org:service:WANPPPConnection:1"></m:GetExternalIPAddress> </s:Body> </s:Envelope> [[[/REQUEST]]] [[[/STEP]]] [[[/HSRC]]] Code:
61 11-03-2010 22:19:22 - FINEST [jd.http.Browser(openRequestConnection)] -> -->**External links are only visible to Support Staff** ----------------Request------------------ POST /upnp/control/igd/wanpppcInternet HTTP/1.1 Accept-Language: de, en-gb;q=0.9, en;q=0.8 Host: dsldevice.lan Content-Length: 296 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 SOAPAction: "urn:schemas-upnp-org:service:WANPPPConnection:1#GetExternalIPAddress" Accept-Encoding: gzip User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10 Content-Type: text/xml; charset="utf-8" Connection: close Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Pragma: no-cache Cache-Control: no-cache <?xml version="1.0"?> <s:Envelope xmlns:s="**External links are only visible to Support Staff** s:encodingStyle="**External links are only visible to Support Staff**> <s:Body> <m:GetExternalIPAddress xmlns:m="urn:schemas-upnp-org:service:WANPPPConnection:1"></m:GetExternalIPAddress> </s:Body> </s:Envelope> ----------------Response------------------ HTTP/1.0 200 OK Content-Length: 380 EXT: Connection: close Content-Type: text/xml; charset="utf-8" Server: Thomson TG 585 v7 7.4.3.2 UPnP/1.0 (xxxxxxxxx) 61 11-03-2010 22:19:22 - FINEST [jd.http.Browser(loadConnection)] -> <?xml version="1.0"?> <s:Envelope xmlns:s="**External links are only visible to Support Staff** s:encodingStyle="**External links are only visible to Support Staff**> <s:Body> <m:GetExternalIPAddressResponse xmlns:m="urn:schemas-upnp-org:service:WANPPPConnection:1"> <NewExternalIPAddress>XXX.XXX.XXX.XXX</NewExternalIPAddress> </m:GetExternalIPAddressResponse> </s:Body> </s:Envelope> I in 14.09.2008 posted a thread named "Discover upnp router and autoconfig reconnect" at **External links are only visible to Support Staff** In that thread I posted a java code programmed by me that finds externalIP using upnp. And it still works even after changing my ISP and router. Example.java Code:
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.DatagramPacket; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MulticastSocket; import java.net.NetworkInterface; import java.net.URL; import java.net.URLConnection; import java.util.Enumeration; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String args[]) throws Exception { String str = "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "MAN: \"ssdp:discover\"\r\n" + "MX: 3\r\n" + "ST: upnp:rootdevice\r\n\r\n"; byte[] data = str.getBytes(); Enumeration x = NetworkInterface.getNetworkInterfaces(); while( x != null && x.hasMoreElements()){ NetworkInterface network_interface = (NetworkInterface)x.nextElement(); Enumeration ni_addresses = network_interface.getInetAddresses(); boolean ok = false; while( ni_addresses.hasMoreElements()){ InetAddress ni_address = (InetAddress)ni_addresses.nextElement(); if ( !( ni_address instanceof Inet6Address || ni_address.isLoopbackAddress())){ ok = true; break; } } if ( !ok ){ continue; } MulticastSocket sock = new MulticastSocket(null); sock.setReuseAddress(true); sock.setTimeToLive( 4 ); sock.bind( new InetSocketAddress( 1900 )); sock.setNetworkInterface( network_interface ); DatagramPacket packet = new DatagramPacket(data, data.length, InetAddress.getByAddress("239.255.255.250", new byte[] {(byte) 239,(byte) 255,(byte) 255,(byte) 250}), 1900 ); sock.send(packet); byte[] buf = new byte[1024]; DatagramPacket packet_r = new DatagramPacket(buf, buf.length); sock.receive(packet_r); sock.close(); Matcher URL = Pattern.compile( "^LOCATION: ?(.+)$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE ).matcher( new String(packet_r.getData()) ); while ( URL.find() ) { URL device = new URL(URL.group(1)); URLConnection c2device = device.openConnection(); BufferedReader stream = new BufferedReader( new InputStreamReader( c2device.getInputStream() ) ); String xmlstr = ""; String nextln; while ( (nextln = stream.readLine()) != null ) { xmlstr += nextln.trim(); } stream.close(); //System.out.println(xmlstr); Matcher friendlyName = Pattern.compile( "<\\s*friendlyName\\s*>\\s*([^<]+)\\s*<\\s*/\\s*friendlyName\\s*>", Pattern.CASE_INSENSITIVE ).matcher( xmlstr ); if ( friendlyName.find() ) { System.out.println("Name: " + friendlyName.group(1)); } Matcher URLBase = Pattern.compile( "<\\s*urlbase\\s*>\\s*(https?://.+)\\s*<\\s*/\\s*urlbase\\s*>", Pattern.CASE_INSENSITIVE ).matcher( xmlstr ); String URLbase; if ( URLBase.find() ) { URLbase = URLBase.group(1); //System.out.println(URLBase.group(1).trim()); } else { URLbase = device.getProtocol() + "://" + device.getHost(); if (device.getPort() != -1) { URLbase += ":" + device.getPort(); } //System.out.println(URLbase); } Matcher services = Pattern.compile( "<\\s*servicetype\\s*>\\s*urn:schemas-upnp-org:service:(WAN[I|P]PP?Connection:[0-9]).+\\s*<\\s*controlURL\\s*>\\s*(.*)\\s*<\\s*/\\s*controlURL\\s*>", Pattern.CASE_INSENSITIVE ).matcher( xmlstr ); while ( services.find() ) { String controlURL = URLbase; if (services.group(2).trim().startsWith("/")) { controlURL += services.group(2).trim(); } else { controlURL += "/" + services.group(2).trim(); } System.out.println("ServiceType: " + services.group(1).trim()); System.out.println("ControlURL: " + controlURL); System.out.println("ExternalIP: " + getexternalip(services.group(1).trim(), controlURL.trim())); } } } } public static String getexternalip(String servicetype, String controlURL) throws Exception { String data = "<?xml version=\"1.0\"?>\n" + "<s:Envelope xmlns:s=\"**External links are only visible to Support Staff** s:encodingStyle=\"**External links are only visible to Support Staff**>\n" + " <s:Body>\n" + " <m:GetExternalIPAddress xmlns:m=\"urn:schemas-upnp-org:service:" + servicetype + "\"></m:GetExternalIPAddress>\n" + " </s:Body>\n" + "</s:Envelope>"; URL url = new URL(controlURL); URLConnection conn = url.openConnection(); conn.setDoOutput(true); conn.addRequestProperty("Content-Type", "text/xml; charset=\"utf-8\""); conn.addRequestProperty("SOAPAction", "urn:schemas-upnp-org:service:" + servicetype + "#GetExternalIPAddress\""); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String xmlstr = null; String nextln; while ( (nextln = rd.readLine()) != null ) { xmlstr += nextln.trim(); } wr.close(); rd.close(); //System.out.println(xmlstr); Matcher friendlyName = Pattern.compile( "<\\s*NewExternalIPAddress\\s*>\\s*(.+)\\s*<\\s*/\\s*NewExternalIPAddress\\s*>", Pattern.CASE_INSENSITIVE ).matcher( xmlstr ); if ( friendlyName.find() ) { return friendlyName.group(1); } else { return "unknown"; } } } regards Last edited by zitmar; 27.07.2010 at 13:29. |
#8
|
||||
|
||||
This thread is inactive. Add a substantive post to reopen it.
Getting the external IP from the router is not a good idea, because it is not general and can change with both the router and the ISP (NAT, etc.). Using an external server is a much more reliable approach. |
#9
|
||||
|
||||
added to bugtracker
http://svn.jdownloader.org/issues/show/2027
__________________
JD-Dev & Server-Admin |
#10
|
|||
|
|||
thanks
|
Thread Tools | |
Display Modes | |
|
|