JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 23.02.2010, 12:37
zitmar
Guest
 
Posts: n/a
Default 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.
Reply With Quote
  #2  
Old 23.02.2010, 13:15
remi
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #3  
Old 23.02.2010, 17:02
zitmar
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #4  
Old 11.03.2010, 00:01
zitmar
Guest
 
Posts: n/a
Default

Any jd dev.
Reply With Quote
  #5  
Old 11.03.2010, 10:46
remi
Guest
 
Posts: n/a
Cool

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.
Reply With Quote
  #6  
Old 11.03.2010, 11:29
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

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
Reply With Quote
  #7  
Old 12.03.2010, 01:00
zitmar
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
(...)can you provide example httpliveheader script to request external ip?
Hi Jiaz, I will provide the example for my router TG585 v7, but it can be different for other routers in url("/upnp/control/igd/wanpppcInternet") and in the service("WANPPPConnection:1").

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]]]
If I start JDownloader with -brdebug and input this script in liveheader reconnecter and press reconnect , this will appear in the log:
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";
      }
   }
}
Runnig it:


regards
Attached Files
File Type: zip Example_code.zip (4.8 KB, 340 views)

Last edited by zitmar; 27.07.2010 at 13:29.
Reply With Quote
  #8  
Old 07.07.2010, 00:20
drbits's Avatar
drbits drbits is offline
JD English Support (inactive)
 
Join Date: Sep 2009
Location: Physically in Los Angeles, CA, USA
Posts: 4,434
Default

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.
Reply With Quote
  #9  
Old 07.07.2010, 10:16
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

added to bugtracker
http://svn.jdownloader.org/issues/show/2027
__________________
JD-Dev & Server-Admin
Reply With Quote
  #10  
Old 07.07.2010, 16:57
zitmar
Guest
 
Posts: n/a
Default

thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 14:35.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.