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:38:29 +0000

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

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonBlocking.ml commonOptions.ml 
                           commonTypes.ml commonWeb.ml 
        src/daemon/driver: driverCommands.ml driverMain.ml 
        src/networks/direct_connect: dcInteractive.ml 
        src/networks/donkey: donkeyInteractive.ml donkeyOvernet.ml 
        src/networks/fasttrack: fasttrackServers.ml 
        src/utils/lib  : options.ml4 options.mli 

Log message:
        patch #6034

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1286&r2=1.1287
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonBlocking.ml?cvsroot=mldonkey&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.207&r2=1.208
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonTypes.ml?cvsroot=mldonkey&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonWeb.ml?cvsroot=mldonkey&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverCommands.ml?cvsroot=mldonkey&r1=1.236&r2=1.237
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverMain.ml?cvsroot=mldonkey&r1=1.140&r2=1.141
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/direct_connect/dcInteractive.ml?cvsroot=mldonkey&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyInteractive.ml?cvsroot=mldonkey&r1=1.159&r2=1.160
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyOvernet.ml?cvsroot=mldonkey&r1=1.80&r2=1.81
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/fasttrack/fasttrackServers.ml?cvsroot=mldonkey&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/lib/options.ml4?cvsroot=mldonkey&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/lib/options.mli?cvsroot=mldonkey&r1=1.11&r2=1.12

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1286
retrieving revision 1.1287
diff -u -b -r1.1286 -r1.1287
--- distrib/ChangeLog   24 Jun 2007 18:37:03 -0000      1.1286
+++ distrib/ChangeLog   24 Jun 2007 18:38:27 -0000      1.1287
@@ -15,6 +15,9 @@
 =========
 
 2007/06/24
+6034: Load $MLDONKEY/web_infos/* before activating network modules
+- this fixes a security hole when networks started connecting
+  before IP blocklist was loaded
 6025: Extend command "links" to optionally display all downloading files
 - "links" displays all files, not only shared ones like before
 - "links shared" lists only shared files

Index: src/daemon/common/commonBlocking.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonBlocking.ml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- src/daemon/common/commonBlocking.ml 17 Jun 2007 01:20:19 -0000      1.7
+++ src/daemon/common/commonBlocking.ml 24 Jun 2007 18:38:28 -0000      1.8
@@ -110,21 +110,17 @@
   CommonWeb.add_web_kind "guarding.p2p"
     "IP blocking lists (ipfilter and guardian v2 formats)"
     (fun url filename ->
-    (try
       web_ip_blocking_list :=
        if filename = "" then
          Ip_set.bl_empty
        else
          Ip_set.load filename;
       update_bans ()
-    with _ -> ());
-    CommonWeb.remove_job url
   );
   CommonWeb.add_web_kind "geoip.dat" "IP to country mapping database"
     (fun url filename ->
     Geoip.init (Geoip.unpack filename);
-    update_bans ();
-    CommonWeb.remove_job url
+    update_bans ()
   );
 
   Heap.add_memstat "CommonBlocking" (fun level buf ->

Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -b -r1.207 -r1.208
--- src/daemon/common/commonOptions.ml  26 May 2007 23:21:46 -0000      1.207
+++ src/daemon/common/commonOptions.ml  24 Jun 2007 18:38:28 -0000      1.208
@@ -24,6 +24,7 @@
 open TcpBufferedSocket
 open Options
 open Unix
+open CommonTypes
 
 let log_prefix = "[cO]"
 
@@ -938,7 +939,7 @@
     string_option ""
 
 let use_html_mods o =
-  o.CommonTypes.conn_output = CommonTypes.HTML && !!html_mods
+  o.conn_output = HTML && !!html_mods
 
 let html_checkbox_vd_file_list = define_expert_option current_section 
["html_checkbox_vd_file_list"]
   "Whether to use checkboxes in the WEB interface for download list"
@@ -1789,16 +1790,6 @@
       let gc_control = Gc.get () in
       Gc.set { gc_control with Gc.space_overhead = !!space_overhead };
   );
-  option_hook web_infos (fun _ ->
-      List.iter (fun remove ->
-          if List.mem remove !!web_infos then
-            web_infos =:= List2.remove remove !!web_infos
-      )
-      [
-        ("server.met", 1, 
"http://savannah.nongnu.org/download/mldonkey/network/servers.met";);
-        ("ocl",1, 
"http://savannah.nongnu.org/download/mldonkey/network/peers.ocl";);
-      ]
-  );
   option_hook tcpip_packet_size (fun _ ->
       TcpBufferedSocket.ip_packet_size := !!tcpip_packet_size
   );
@@ -2033,21 +2024,54 @@
   option_hook allow_local_network (fun _ ->
       Ip.allow_local_network := !!allow_local_network)
 
-let web_infos_exists url =
-  List.exists (fun (_, _, weburl) ->
-    weburl = url) !!web_infos
-
-let web_infos_remove outdated_web_infos =
-  web_infos =:=
-  List.fold_left (fun acc owi ->
-    let (kind2, _, url2) = owi in
-    List.filter (fun (_,_,url) -> url <> url2) acc
-  ) !!web_infos outdated_web_infos
+let web_infos_table = Hashtbl.create 10
+
+exception Found_web_infos of web_infos
+
+let web_infos_find url =
+  let found = ref None in
+  (try
+    Hashtbl.iter (fun key w ->
+      if w.url = url then raise (Found_web_infos w)
+    ) web_infos_table
+  with Found_web_infos w -> found := Some w);
+  !found
+
+let web_infos_remove url =
+  let delete_list = ref [] in
+  Hashtbl.iter (fun key w -> 
+    if w.url = url then delete_list := !delete_list @ [key]
+  ) web_infos_table;
+  List.iter (fun key -> Hashtbl.remove web_infos_table key) !delete_list
 
 let web_infos_add kind period url =
-  let web_info = (kind,period,url) in
-  if web_infos_exists url then web_infos_remove [web_info];
-  web_infos =:=  web_info :: !!web_infos
+  (match web_infos_find url with
+  | None -> ()
+  | Some w -> web_infos_remove w.url);
+  Hashtbl.add web_infos_table (kind, period, url)
+    {
+      kind = kind;
+      period = period;
+      url = url;
+      state = None;
+    }
+
+let _ =
+(* convert list option web_infos to a hashtable for better usage *)
+  set_after_load_hook downloads_ini (fun _ ->
+    List.iter (fun (kind, period, url) ->
+      web_infos_add kind period url
+    ) !!web_infos;
+    web_infos =:= []
+  );
+  set_before_save_hook downloads_ini (fun _ ->
+    Hashtbl.iter (fun _ w ->
+      web_infos =:= !!web_infos @ [(w.kind, w.period, w.url)]
+    ) web_infos_table
+  );
+  set_after_save_hook downloads_ini (fun _ ->
+    web_infos =:= []
+  )
 
 let rec update_options () =
   let update v =
@@ -2061,14 +2085,9 @@
       web_infos =:= List.map (fun (kind, period, url) ->
           kind, period * Date.day_in_hours, url
       ) !!web_infos;
-      web_infos =:= !!web_infos @ [
-        ("rss", 6,
-          "http://www.ed2k-it.com/forum/news_rss.php";);
-        ("rss", 6,
-          "http://www.torrents.co.uk/backend.php";);
-        ("rss", 6,
-          "http://varchars.com/rss/suprnova-movies.rss";);
-      ];
+      web_infos_add "rss" 6 "http://www.ed2k-it.com/forum/news_rss.php";;
+      web_infos_add "rss" 6 "http://www.torrents.co.uk/backend.php";;
+      web_infos_add "rss" 6 "http://varchars.com/rss/suprnova-movies.rss";;
       update 1
 
   | 1 ->
@@ -2077,34 +2096,19 @@
       update 2
 
   | 2 ->
-      web_infos_remove
-        [
-          ("rss", 6,
-            "http://www.ed2k-it.com/forum/news_rss.php";);
-          ("rss", 6,
-            "http://www.torrents.co.uk/backend.php";);
-          ("rss", 6,
-            "http://varchars.com/rss/suprnova-movies.rss";);
-        ];
-      if !!min_reask_delay = 720 then
-          min_reask_delay =:= 600;
+      web_infos_remove "http://www.ed2k-it.com/forum/news_rss.php";;
+      web_infos_remove "http://www.torrents.co.uk/backend.php";;
+      web_infos_remove "http://varchars.com/rss/suprnova-movies.rss";;
+      if !!min_reask_delay = 720 then min_reask_delay =:= 600;
       update 3
 
   | 3 ->
-      web_infos_remove
-        [
-          ("ocl", 24,
-            
"http://members.lycos.co.uk/appbyhp2/FlockHelpApp/contact-files/contact.ocl";);
-        ];
+      web_infos_remove 
"http://members.lycos.co.uk/appbyhp2/FlockHelpApp/contact-files/contact.ocl";;
       web_infos_add "contact.dat" 168 
"http://www.overnet.org/download/contact.dat";;
       update 4
 
   | 4 ->
-      web_infos_remove
-        [
-          ("server.met", 24,
-            
"http://ocbmaurice.dyndns.org/pl/slist.pl/server.met?download/server-best.met";);
-        ];
+      web_infos_remove 
"http://ocbmaurice.dyndns.org/pl/slist.pl/server.met?download/server-best.met";;
       web_infos_add "server.met" 0 "http://www.gruk.org/server.met.gz";;
       update 5
 
@@ -2128,38 +2132,18 @@
       update 9
 
   | 9 ->
-      if web_infos_exists "http://www.gruk.org/server.met.gz"; then
-      begin
-        web_infos_remove
-          [
-      ("server.met", 0, "http://www.gruk.org/server.met.gz";)
-          ];
+      web_infos_remove "http://www.gruk.org/server.met.gz";;
       web_infos_add "server.met" 0 "http://www.jd2k.com/server.met";;
-      end;
       update 10
 
   | 10 ->
-      if web_infos_exists "http://www.overnet.org/download/contact.dat"; then
-      begin
-        web_infos_remove
-          [
-      ("contact.dat", 672,
-        "http://www.overnet.org/download/contact.dat";);
-          ];
+      web_infos_remove "http://www.overnet.org/download/contact.dat";;
   web_infos_add "contact.dat" 168 "http://download.overnet.org/contact.dat";;
-      end;
       update 11
 
   | 11 ->
-      if web_infos_exists "http://www.bluetack.co.uk/config/antip2p.txt"; then
-      begin
-        web_infos_remove
-          [
-      ("guarding.p2p", 96,
-        "http://www.bluetack.co.uk/config/antip2p.txt";);
-          ];
+      web_infos_remove "http://www.bluetack.co.uk/config/antip2p.txt";;
   web_infos_add "guarding.p2p" 0 "http://www.bluetack.co.uk/config/level1.gz";;
-      end;
       update 12
 
   | 12 ->
@@ -2167,12 +2151,8 @@
       update 13
 
   | 13 ->
-      if web_infos_exists "http://www.jd2k.com/server.met"; then
-      begin
-        web_infos_remove
-          [("server.met", 0, "http://www.jd2k.com/server.met";)];
+      web_infos_remove "http://www.jd2k.com/server.met";;
        web_infos_add "server.met" 0 "http://www.gruk.org/server.met.gz";;
-      end;
       update 14
 
   | 14 ->

Index: src/daemon/common/commonTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonTypes.ml,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- src/daemon/common/commonTypes.ml    17 Jun 2007 01:56:29 -0000      1.71
+++ src/daemon/common/commonTypes.ml    24 Jun 2007 18:38:28 -0000      1.72
@@ -974,3 +974,21 @@
 type swarming_strategy =
   LinearStrategy    (* one after the other one *)
 | AdvancedStrategy
+
+type web_infos_state =
+| DownloadStarted
+| FileLoaded
+
+type web_infos = {
+  kind : string;
+  period : int;
+  url : string;
+  mutable state : web_infos_state option;
+}
+
+let string_of_web_infos_state state =
+  match state with
+  | None -> "unknown"
+  | Some DownloadStarted -> "DL started"
+  | Some FileLoaded -> "File loaded"
+

Index: src/daemon/common/commonWeb.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonWeb.ml,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- src/daemon/common/commonWeb.ml      1 Apr 2007 13:05:05 -0000       1.40
+++ src/daemon/common/commonWeb.ml      24 Jun 2007 18:38:28 -0000      1.41
@@ -45,21 +45,6 @@
 let days = ref 0
 let hours = ref 0
 
-type web_jobs = {
-  mutable downloaded : bool;
-}
-
-let running_jobs = Hashtbl.create (List.length !!web_infos)
-
-let add_job url =
-  let wj = {
-    downloaded = false;
-  } in
-  Hashtbl.add running_jobs url wj
-
-let remove_job url =
-  Hashtbl.remove running_jobs url
-
 (*************************************************************************)
 (*                                                                       *)
 (*                         load_url                                      *)
@@ -73,22 +58,24 @@
   file_kinds := (kind, kind_record) :: !file_kinds
 
   
-let mldonkey_wget_url url f =
-  add_job url;
+let mldonkey_wget_url w f =
+  (match w.state with
+  | None -> w.state <- Some DownloadStarted;
+  | _ -> ());
   let module H = Http_client in
   let r = {
       H.basic_request with
-      H.req_url = Url.of_string url;
+      H.req_url = Url.of_string w.url;
       H.req_proxy = !CommonOptions.http_proxy;
       H.req_referer = (
         let (rule_search,rule_value) =
           try (List.find(fun (rule_search,rule_value) ->
-            Str.string_match (Str.regexp rule_search) url 0
+            Str.string_match (Str.regexp rule_search) w.url 0
           ) !!referers )
-          with Not_found -> ("",url) in
+          with Not_found -> ("", w.url) in
         Some (Url.of_string rule_value) );
       H.req_headers = (try
-        let cookies = List.assoc url !!cookies in
+        let cookies = List.assoc w.url !!cookies in
           [ ( "Cookie", List.fold_left (fun res (key, value) ->
               if res = "" then
                 key ^ "=" ^ value
@@ -115,7 +102,10 @@
          with _ -> ()
     ) headers;
     match !date with
-      None -> H.wget r f
+      None -> (try
+          H.wget r f;
+          w.state <- Some FileLoaded
+        with e -> w.state <- None; raise e)
     | Some date ->
        let file = Filename.concat "web_infos" (Filename.basename 
r.H.req_url.Url.short_file) in
        r.H.req_save_to_file_time <- (begin try
@@ -124,20 +114,38 @@
            Unix.time ()
          end);
        if not (Sys.file_exists file) then
-         H.wget r f
+          begin
+            try
+              H.wget r f;
+              w.state <- Some FileLoaded
+            with e -> w.state <- None; raise e
+          end
        else
          begin
+            let file_loaded state =
+              match state with
+              | Some FileLoaded -> true
+              | _ -> false
+            in
            let file_date = Unix.LargeFile.stat file in
              if r.H.req_save_to_file_time <= file_date.Unix.LargeFile.st_mtime 
then
                begin
-               lprintf_nl (_b "using local version of %s (%s), HTML header 
(%s)")
+                  lprintf_nl (_b "%s version of %s (%s), HTML header (%s)")
+                    (if file_loaded w.state then "already loaded local" else 
"re-loading possible broken")
                  file (Date.to_full_string file_date.Unix.LargeFile.st_mtime) 
date;
-               (f file : unit)
+                  if not (file_loaded w.state) then
+                    try
+                      H.wget r f;
+                      w.state <- Some FileLoaded
+                    with e -> w.state <- None; raise e
                end
              else
                begin
                  lprintf_nl (_b "downloading newer %s, HTML header (%s)") file 
date;
-                 H.wget r f
+                  try
+                    H.wget r f;
+                    w.state <- Some FileLoaded
+                  with e -> w.state <- None; raise e
                end
          end
       )
@@ -146,9 +154,11 @@
           | x when x < 200 || x > 299 -> begin
             (* use local version if wget fail and file exists *)
             let file = Filename.concat "web_infos" (Filename.basename 
r.H.req_url.Url.short_file) in
-            (try (* mark this job downloaded *)
-                (Hashtbl.find running_jobs url).downloaded <- true
-             with Not_found -> ());
+            (* mark this job downloaded *)
+            match w.state with
+            | Some FileLoaded ->
+                lprintf_nl (_b "already loaded local version of %s, HTTP 
request failed (error %d)") file x
+            | _ ->
             if Sys.file_exists file then begin
               lprintf_nl (_b "using local version of %s, HTTP request failed 
(error %d)") file x;
               add_timer 5. (fun timer ->
@@ -156,9 +166,11 @@
                   (* check if other jobs are still in downloading state to 
avoid calling
                      function f, which might hurt other downloads for 
expensive functions *)
                   let others_running = ref 0 in
-                  Hashtbl.iter (fun url j ->
-                    if not j.downloaded then incr others_running
-                  ) running_jobs;
+                  Hashtbl.iter (fun key w ->
+                    match w.state with
+                    | Some DownloadStarted -> incr others_running
+                    | _ -> ()
+                  ) web_infos_table;
                   !others_running
                 in
                 if jobs = 0 then
@@ -171,44 +183,44 @@
               end
             else
               lprintf_nl (_b "local file %s not found, HTTP request failed 
(error %d)") file x;
+              w.state <- None
             end
          | _ -> ()
       )
     with e -> 
-      remove_job url;
-      lprintf_nl (_b "Exception %s while loading %s")
-        (Printexc2.to_string e) url
+      w.state <- None;
+      lprintf_nl (_b "Exception %s while loading %s") (Printexc2.to_string e) 
w.url
     end
 
-let mldonkey_wget_shell url f =
-  let command_urlencoded = Str.string_after url 8 in
+let mldonkey_wget_shell w f =
+  let command_urlencoded = Str.string_after w.url 8 in
   let command = Url.decode command_urlencoded in
   let filename = Filename.temp_file "wget_" ".tmp" in
     ignore (Sys.command (Printf.sprintf "%s > %s" command filename));
     (f filename : unit)
       
-let mldonkey_wget url f =
-  if Str.string_match (Str.regexp "shell://") url 0 then
-    mldonkey_wget_shell url f
+let mldonkey_wget w f =
+  if Str.string_match (Str.regexp "shell://") w.url 0 then
+    mldonkey_wget_shell w f
   else
-    mldonkey_wget_url url f
+    mldonkey_wget_url w f
       
-let load_url can_fail kind url =
+let load_url can_fail w =
   let f =
     try
-      (List.assoc kind !file_kinds).f url
-    with e -> failwith (Printf.sprintf "Unknown kind [%s]" kind)
+      (List.assoc w.kind !file_kinds).f w.url
+    with e -> failwith (Printf.sprintf "Unknown kind [%s]" w.kind)
   in
   try
-    lprintf_nl (_b "request %s (%s)") kind url;
-    mldonkey_wget url f
+    lprintf_nl (_b "request %s (%s)") w.kind w.url;
+    mldonkey_wget w f
   with e ->
     if can_fail then
       failwith (Printf.sprintf "Exception %s while loading %s"
-          (Printexc2.to_string e) url)
+          (Printexc2.to_string e) w.url)
     else
       lprintf_nl (_b "Exception %s while loading %s")
-          (Printexc2.to_string e) url
+          (Printexc2.to_string e) w.url
 
 (*************************************************************************)
 (*                                                                       *)
@@ -217,16 +229,16 @@
 (*************************************************************************)
 
 let load_web_infos core_start force =
-  List.iter (fun (kind, period, url) ->
-    if (core_start && period = 0) || (period <> 0 && !hours mod period = 0) || 
force then
+  Hashtbl.iter (fun key w ->
+    if (core_start && w.period = 0) || (w.period <> 0 && !hours mod w.period = 
0) || force then
       begin
         try
-          load_url false kind url
+          load_url false w
        with e ->
             lprintf_nl (_b "%s while loading %s")
-             (Printexc2.to_string e) url
+             (Printexc2.to_string e) w.url
       end
-  ) !!CommonOptions.web_infos
+  ) CommonOptions.web_infos_table
 
 type rss_feed = {
     mutable rss_date : int;
@@ -288,5 +300,4 @@
       in
       feed.rss_date <- last_time ();
       feed.rss_value <- c;
-      remove_job url
   )

Index: src/daemon/driver/driverCommands.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml,v
retrieving revision 1.236
retrieving revision 1.237
diff -u -b -r1.236 -r1.237
--- src/daemon/driver/driverCommands.ml 24 Jun 2007 18:37:04 -0000      1.236
+++ src/daemon/driver/driverCommands.ml 24 Jun 2007 18:38:28 -0000      1.237
@@ -346,20 +346,19 @@
           | _  -> failwith "Bad number of arguments"
         in
        web_infos_add kind period url;
-       CommonWeb.load_url true kind url;
+        (match web_infos_find url with
+        | None -> ()
+        | Some w -> CommonWeb.load_url true w);
         "url added to web_infos. downloading now"
     ), "<kind> <url> [<period>] :\tload this file from the web\n"
        ^"\t\t\t\t\tkind is either server.met (if the downloaded file is a 
server.met)\n"
        ^"\t\t\t\t\tperiod is the period between updates (in hours, default 0 = 
only loaded at startup)";
 
     "urlremove", Arg_one (fun url o ->
-       if web_infos_exists url then
-         begin
-           web_infos_remove [("",0,url)];
+        match web_infos_find url with
+        | None -> "URL does not exists in web_infos"
+        | Some w -> web_infos_remove w.url;
             "removed URL from web_infos"
-         end
-       else
-            "URL does not exists in web_infos"
     ), "<url> :\t\t\tremove URL from web_infos";
 
     "force_web_infos", Arg_multiple (fun args o ->
@@ -368,12 +367,12 @@
                 "requesting all web_infos files"
         | args -> let list = ref [] in
                   List.iter (fun arg ->
-                    List.iter (fun (kind, _, url) ->
-                      if kind = arg || url = arg then begin
-                        CommonWeb.load_url false kind url;
+                    Hashtbl.iter (fun key w ->
+                      if w.kind = arg || w.url = arg then begin
+                        CommonWeb.load_url false w;
                         list := arg :: !list
                       end
-                  ) !!web_infos) args;
+                  ) web_infos_table) args;
                   if !list = [] then
                     Printf.sprintf "found no web_infos entries for %s" 
(String.concat " " args)
                   else
@@ -2191,7 +2190,7 @@
 \\</td\\>\\</tr\\>
 \\<tr\\>\\<td\\>";
 
-            if !!web_infos = [] then
+            if Hashtbl.length web_infos_table = 0 then
               html_mods_table_one_row buf "serversTable" "servers" [
                 ("", "srh", "no jobs defined"); ]
            else begin
@@ -2199,12 +2198,14 @@
              html_mods_table_header buf "web_infoTable" "vo" [
                ( "0", "srh ac", "Click to remove URL", "Remove" ) ;
                ( "0", "srh", "Download now", "DL" ) ;
-               ( "0", "srh", "Option type", "Type" ) ;
-               ( "0", "srh", "Option delay", "Delay" ) ;
-               ( "0", "srh", "Option value", "Value" ) ] ;
+               ( "0", "srh", "Filetype", "Type" ) ;
+               ( "0", "srh", "Interval in hours", "Interval" ) ;
+               ( "0", "srh", "URL", "URL" ) ;
+               ( "0", "srh", "URL state", "State" ) ;
+              ] ;
 
               html_mods_cntr_init ();
-              List.iter (fun (kind, period, url) ->
+              Hashtbl.iter (fun key w ->
                 Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" 
(html_mods_cntr ());
                Printf.bprintf buf "
         \\<td title=\\\"Click to remove URL\\\"
@@ -2213,21 +2214,23 @@
         onClick=\\\'javascript:{
        
parent.fstatus.location.href=\\\"submit?q=urlremove+\\\\\\\"%s\\\\\\\"\\\"
         setTimeout(\\\"window.location.reload()\\\",1000);}'
-        class=\\\"srb\\\"\\>Remove\\</td\\>" (Url.encode url);
+        class=\\\"srb\\\"\\>Remove\\</td\\>" (Url.encode w.url);
                Printf.bprintf buf "
         \\<td title=\\\"Download now\\\"
         onMouseOver=\\\"mOvr(this);\\\"
         onMouseOut=\\\"mOut(this);\\\"
         onClick=\\\'javascript:{
        
parent.fstatus.location.href=\\\"submit?q=force_web_infos+\\\\\\\"%s\\\\\\\"\\\";}'
-        class=\\\"srb\\\"\\>DL\\</td\\>" (Url.encode url);
+        class=\\\"srb\\\"\\>DL\\</td\\>" (Url.encode w.url);
           Printf.bprintf buf "
               \\<td title=\\\"%s\\\" class=\\\"sr\\\"\\>%s\\</td\\>
-             \\<td class=\\\"sr\\\"\\>%d\\</td\\>"  url kind period;
+             \\<td class=\\\"sr\\\"\\>%d\\</td\\>"  w.url w.kind w.period;
+          Printf.bprintf buf "
+              \\<td class=\\\"sr\\\"\\>%s\\</td\\>" w.url;
           Printf.bprintf buf "
               \\<td class=\\\"sr\\\"\\>%s\\</td\\>
-              \\</tr\\>" url
-              ) !!web_infos;
+              \\</tr\\>" (string_of_web_infos_state w.state);
+              ) web_infos_table;
            end;
             Printf.bprintf buf 
"\\</table\\>\\</td\\>\\<tr\\>\\</table\\>\\</div\\>\\<P\\>";
 
@@ -2249,10 +2252,11 @@
           end
         else
            begin
-             Printf.bprintf buf "kind / period / url :\n";
-             List.iter (fun (kind, period, url) ->
-                 Printf.bprintf buf "%s ; %d ; %s\n"  kind period url
-             ) !!web_infos;
+             Printf.bprintf buf "kind / period / url / state :\n";
+             Hashtbl.iter (fun key w ->
+                 Printf.bprintf buf "%s ; %d ; %s; %s\n"
+                    w.kind w.period w.url (string_of_web_infos_state w.state)
+             ) web_infos_table;
              Printf.bprintf buf "\nAllowed values for kind:\n";
              List.iter (fun (kind, data) ->
                  Printf.bprintf buf "%s - %s\n" kind data.description

Index: src/daemon/driver/driverMain.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverMain.ml,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -b -r1.140 -r1.141
--- src/daemon/driver/driverMain.ml     23 Apr 2007 23:40:28 -0000      1.140
+++ src/daemon/driver/driverMain.ml     24 Jun 2007 18:38:28 -0000      1.141
@@ -423,6 +423,18 @@
 
   CommonGlobals.is_startup_phase := false;
 
+(* before activating network modules load all local files from web_infos/
+   to avoid security holes, especially for IP blocking *)
+  Hashtbl.iter (fun key w ->
+    let file = Filename.concat "web_infos" (Filename.basename w.url) in
+    if Sys.file_exists file then
+      try
+        lprintf_nl "loading %s from %s" w.kind file;
+        ((List.assoc w.kind !CommonWeb.file_kinds).f w.url) file;
+        w.state <- Some FileLoaded;
+      with _ -> ()
+  ) web_infos_table;
+
   lprintf_nl (_b "Check http://www.mldonkey.org for updates");
   networks_iter (fun r -> network_load_complex_options r);
   lprintf_nl (_b "enabling networks: ");
@@ -501,7 +513,6 @@
 
   Options.prune_file downloads_ini;
   Options.prune_file users_ini;
-(*  Options.prune_file downloads_expert_ini; *)
   add_timer 1. (fun _ -> try CommonWeb.load_web_infos true false with _ -> ());
   lprintf_nl  (_b "To command: telnet %s %d")
        (if !!telnet_bind_addr = Ip.any then "127.0.0.1"

Index: src/networks/direct_connect/dcInteractive.ml
===================================================================
RCS file: 
/sources/mldonkey/mldonkey/src/networks/direct_connect/dcInteractive.ml,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- src/networks/direct_connect/dcInteractive.ml        1 Jun 2007 19:51:12 
-0000       1.31
+++ src/networks/direct_connect/dcInteractive.ml        24 Jun 2007 18:38:28 
-0000      1.32
@@ -699,10 +699,15 @@
         | "load" ->
           let url =
             if (!!servers_list_url = empty_string) then failwith "No valid 
url" 
-            else !!servers_list_url
+            else
+              { url = !!servers_list_url;
+                kind = "";
+                period = 0;
+                state = None;
+              }
           in
           CommonWeb.mldonkey_wget url (fun _ -> () );
-          Printf.bprintf buf "Trying to load %s\n" url;
+          Printf.bprintf buf "Trying to load %s\n" url.url;
         | "show" ->
             let filename = Filename.concat "web_infos" (Filename.basename 
!!servers_list_url) in
             if !verbose_msg_servers then lprintf_nl "Loading hublist with 
filename (%s) " filename;   

Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- src/networks/donkey/donkeyInteractive.ml    17 Jun 2007 01:56:29 -0000      
1.159
+++ src/networks/donkey/donkeyInteractive.ml    24 Jun 2007 18:38:28 -0000      
1.160
@@ -1930,23 +1930,18 @@
     if !!enable_donkey && !!update_server_list_server_met then
       begin
         lprintf_nl "server.met loaded from %s" url;
-  begin
-    try
       let s = unpack_server_met filename url in
         let nservers = List.length (Hashtbl2.to_list servers_by_key) in
               let n = load_server_met s in
                 if s <> filename then Sys.remove s;
             lprintf_nl "%d servers found, %d new ones inserted"
         n ((List.length (Hashtbl2.to_list servers_by_key)) - nservers)
-           with _ -> ()
-  end;
       end
     else
       if not !!enable_donkey then
         lprintf_nl "eDonkey module is disabled, ignoring..."
       else
-        lprintf_nl "ED2K-update_server_list_server_met is disabled, 
ignoring...";
-    CommonWeb.remove_job url
+        lprintf_nl "ED2K-update_server_list_server_met is disabled, 
ignoring..."
   );
 
   file_ops.op_file_proposed_filenames <- op_file_proposed_filenames;

Index: src/networks/donkey/donkeyOvernet.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyOvernet.ml,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -b -r1.80 -r1.81
--- src/networks/donkey/donkeyOvernet.ml        31 May 2007 19:24:58 -0000      
1.80
+++ src/networks/donkey/donkeyOvernet.ml        24 Jun 2007 18:38:28 -0000      
1.81
@@ -1916,15 +1916,21 @@
         let urls =
           match args with
             [] -> let list = ref [] in
-              List.iter (fun (kind,_, url) ->
-                  if kind = web_info then list := url :: !list
-              )!!web_infos;
+              Hashtbl.iter (fun key w ->
+                  if w.kind = web_info then list := w :: !list
+              ) web_infos_table;
               !list
-          | _ -> args
+          | _ -> List.map (fun url -> 
+                    { 
+                      url = url;
+                      kind = web_info;
+                      period = 0;
+                      state = None;
+                    }) args
         in
-        List.iter (fun url ->
-            Printf.bprintf o.conn_buf "Loading %s\n" url;
-            CommonWeb.load_url true web_info url) urls;
+        List.iter (fun w ->
+            Printf.bprintf o.conn_buf "Loading %s\n" w.url;
+            CommonWeb.load_url true w) urls;
         "web boot started"
     ), "<urls> : \t\t\tdownload .ocl URLs (no arg load default)";
 
@@ -2097,8 +2103,7 @@
                     bootstrap ip port) (fun _ -> ())
             | _ -> lprintf_nl "BAD LINE ocl: %s" s;
           with _ -> lprintf_nl "DNS failed";
-      ) lines;
-  CommonWeb.remove_job url
+      ) lines
   );
 
   (* Add this kind of web_info only for overnet *)
@@ -2112,8 +2117,7 @@
          if not !!enable_overnet then
       lprintf_nl "Overnet module is disabled, ignoring..."
          else
-      lprintf_nl "Overnet_update_nodes is disabled, ignoring...";
-      CommonWeb.remove_job url
+            lprintf_nl "Overnet_update_nodes is disabled, ignoring..."
         );
 
 (*************************************************************

Index: src/networks/fasttrack/fasttrackServers.ml
===================================================================
RCS file: 
/sources/mldonkey/mldonkey/src/networks/fasttrack/fasttrackServers.ml,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- src/networks/fasttrack/fasttrackServers.ml  17 Mar 2007 18:03:01 -0000      
1.31
+++ src/networks/fasttrack/fasttrackServers.ml  24 Jun 2007 18:38:29 -0000      
1.32
@@ -84,12 +84,9 @@
     CommonWeb.add_web_kind "nodes.gzip" "List of fasttrack nodes"
     (fun url filename -> 
         lprintf_nl "nodes.gzip loaded from %s" url;
-        (try
           let f = unpack_nodes_gzip filename url in
           load_nodes_file f;
-          if f <> filename then Sys.remove f;
-        with _ -> ());
-        CommonWeb.remove_job url
+        if f <> filename then Sys.remove f
     )    
 
 let server_parse_after s gconn sock =

Index: src/utils/lib/options.ml4
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/lib/options.ml4,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- src/utils/lib/options.ml4   25 Mar 2007 12:37:09 -0000      1.24
+++ src/utils/lib/options.ml4   24 Jun 2007 18:38:29 -0000      1.25
@@ -467,12 +467,12 @@
 let options_file_name f = f.file_name
 
 let load opfile =
-  try
+  (try
     opfile.file_rc <-
       really_load opfile.file_name opfile.file_sections;
-    opfile.file_after_load_hook ()
   with
-    Not_found | Sys_error _ -> (* lprintf "No %s found\n" opfile.file_name *) 
()
+  | Not_found | Sys_error _ -> ());
+  opfile.file_after_load_hook ()
       
 let append opfile filename =
   try
@@ -1091,9 +1091,6 @@
     None -> safe_value_to_string (o.option_class.to_value o.option_value)
   | Some (to_string, _) -> to_string o.option_value
   
-let set_option_hook opfile name hook =
-  let o = get_option opfile name in o.option_hooks <- hook :: o.option_hooks
-  
 let set_string_wrappers o to_string from_string =
   o.string_wrappers <- Some (to_string, from_string)
 

Index: src/utils/lib/options.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/lib/options.mli,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- src/utils/lib/options.mli   15 Jan 2007 18:26:27 -0000      1.11
+++ src/utils/lib/options.mli   24 Jun 2007 18:38:29 -0000      1.12
@@ -190,7 +190,6 @@
 val set_simple_option : options_file -> string -> string -> unit
 val simple_options : string -> options_file -> bool -> option_info list
 val get_simple_option : options_file -> string -> string
-val set_option_hook : options_file -> string -> (unit -> unit) -> unit
 
 val set_string_wrappers : 'a option_class -> 
   ('a -> string) -> (string -> 'a) -> unit




reply via email to

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