mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...
Date: Sun, 24 Jun 2007 18:40:03 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       07/06/24 18:40:03

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonGlobals.ml commonOptions.ml 
        src/daemon/driver: driverCommands.ml driverMain.ml 

Log message:
        patch #6043

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1287&r2=1.1288
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonGlobals.ml?cvsroot=mldonkey&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.208&r2=1.209
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverCommands.ml?cvsroot=mldonkey&r1=1.237&r2=1.238
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverMain.ml?cvsroot=mldonkey&r1=1.141&r2=1.142

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1287
retrieving revision 1.1288
diff -u -b -r1.1287 -r1.1288
--- distrib/ChangeLog   24 Jun 2007 18:38:27 -0000      1.1287
+++ distrib/ChangeLog   24 Jun 2007 18:40:02 -0000      1.1288
@@ -15,6 +15,12 @@
 =========
 
 2007/06/24
+6043: Discover WAN IP
+- new command "discover_ip" to force discovery
+- new option "discover_ip" to enable automatic discovery on startup
+  and after SIGHUP, default true
+- this patch is important for BT-only usage, without this patch the
+  WAN IP was discovered only by using EDK server replies
 6034: Load $MLDONKEY/web_infos/* before activating network modules
 - this fixes a security hole when networks started connecting
   before IP blocklist was loaded

Index: src/daemon/common/commonGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonGlobals.ml,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- src/daemon/common/commonGlobals.ml  17 Jun 2007 01:28:24 -0000      1.84
+++ src/daemon/common/commonGlobals.ml  24 Jun 2007 18:40:02 -0000      1.85
@@ -883,6 +883,38 @@
   else
     Printf.bprintf o.conn_buf "%s" result
 
+let discover_ip force =
+  if !!discover_ip || force then
+    begin
+      if !verbose then lprintf_nl "started IP discovery";
+      let module H = Http_client in
+      let r = { H.basic_request with
+        H.req_url = Url.of_string "http://ip.discoveryvip.com/ip.asp";;
+        H.req_proxy = !CommonOptions.http_proxy;
+        H.req_max_retry = 10;
+        H.req_user_agent = get_user_agent () }
+      in
+      H.wget r (fun file ->
+        if !verbose then lprintf_nl "downloaded IP discovery page, parsing...";
+        Unix2.tryopen_read file (fun cin ->
+          try
+            while true do
+              let line = input_line cin in
+              let search_string = "Your Ip address is  " in
+                try
+                  if Str.string_match (Str.regexp ("^" ^ search_string)) line 
0 then
+                    begin
+                      set_client_ip =:=
+                        Ip.of_string (String.sub line (String.length 
search_string)
+                          ((String.length line) - (String.length 
search_string)));
+                      if !verbose then lprintf_nl "discovered IP %s" 
(Ip.to_string !!set_client_ip)
+                    end
+                with e -> lprintf_nl "IP discovery parse error: %s" 
(Printexc2.to_string e)
+            done
+          with End_of_file -> ())
+      )
+    end
+
 let _ =
   Heap.add_memstat "CommonGlobals" (fun level buf ->
       let counter = ref 0 in

Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -b -r1.208 -r1.209
--- src/daemon/common/commonOptions.ml  24 Jun 2007 18:38:28 -0000      1.208
+++ src/daemon/common/commonOptions.ml  24 Jun 2007 18:40:02 -0000      1.209
@@ -989,6 +989,10 @@
   ourself. Don't set this option to true if you have dynamic IP."
     bool_option false
 
+let discover_ip = define_option current_section ["discover_ip"]
+  "Use http://ip.discoveryvip.com/ip.asp to obtain WAN IP"
+    bool_option true
+
 let user_agent = define_option current_section ["user_agent"]
   "User agent string (default = \"default\")"
     string_option "default"

Index: src/daemon/driver/driverCommands.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -b -r1.237 -r1.238
--- src/daemon/driver/driverCommands.ml 24 Jun 2007 18:38:28 -0000      1.237
+++ src/daemon/driver/driverCommands.ml 24 Jun 2007 18:40:03 -0000      1.238
@@ -1427,6 +1427,12 @@
         _s ""
     ) , "<num> :\t\t\t\tdisable a particular network";
     
+    "discover_ip", Arg_none (fun o ->
+      CommonGlobals.discover_ip true;
+      print_command_result o "discover ip started";
+           ""
+    ) , ":\t\t\t\tstart IP discovery";
+
     "force_porttest", Arg_none (fun o ->
     networks_iter (fun n ->
       match network_porttest_result n with
@@ -1778,6 +1784,7 @@
                 strings_of_option allowed_ips;
                 strings_of_option set_client_ip;
                 strings_of_option force_client_ip;
+                strings_of_option discover_ip;
               ] );
 
             Printf.bprintf buf "\\</td\\>\\</tr\\>\\<tr\\>\\<td\\>\\<table 
cellspacing=0 cellpadding=0  width=100%%\\>\\<tr\\>\\<td class=downloaded 
width=100%%\\>\\</td\\>
@@ -1802,6 +1809,7 @@
               strings_of_option allowed_ips;
               strings_of_option set_client_ip;
               strings_of_option force_client_ip;
+              strings_of_option discover_ip;
             ]
           );
 
@@ -1913,6 +1921,7 @@
                        strings_of_option global_login;
                        strings_of_option set_client_ip;
                        strings_of_option force_client_ip;
+                       strings_of_option discover_ip;
                        strings_of_option max_upload_slots;
                        strings_of_option max_release_slots;
                        strings_of_option dynamic_slots;

Index: src/daemon/driver/driverMain.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverMain.ml,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -b -r1.141 -r1.142
--- src/daemon/driver/driverMain.ml     24 Jun 2007 18:38:28 -0000      1.141
+++ src/daemon/driver/driverMain.ml     24 Jun 2007 18:40:03 -0000      1.142
@@ -435,6 +435,8 @@
       with _ -> ()
   ) web_infos_table;
 
+  discover_ip false;
+
   lprintf_nl (_b "Check http://www.mldonkey.org for updates");
   networks_iter (fun r -> network_load_complex_options r);
   lprintf_nl (_b "enabling networks: ");
@@ -575,11 +577,12 @@
 
   if not Autoconf.windows then
     MlUnix.set_signal  Sys.sighup
-      (Sys.Signal_handle (fun _ -> lprintf_nl (_b "Received SIGHUP, closing 
all files and client/server sockets");
+      (Sys.Signal_handle (fun _ -> lprintf_nl (_b "Received SIGHUP, closing 
all files and client/server sockets, start IP discovery");
          networks_iter (fun r -> CommonNetwork.network_reset r); (* 
stop_all_bt *)
         CommonServer.disconnect_all_servers ();
         CommonClient.disconnect_all_clients ();
-        Unix32.close_all () (* close all files *)
+         Unix32.close_all (); (* close all files *)
+         discover_ip false;
          ));
 
   if not Autoconf.windows then




reply via email to

[Prev in Thread] Current Thread [Next in Thread]