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: Sat, 23 Sep 2006 20:29:47 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       06/09/23 20:29:47

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonFile.ml commonFile.mli commonGlobals.ml 
                           commonInteractive.ml commonNetwork.ml 
                           commonOptions.ml commonServer.ml 
                           commonShared.ml commonStats.ml commonTypes.ml 
                           guiDecoding.ml guiEncoding.ml guiProto.ml 
                           guiTypes.ml 
        src/daemon/driver: driverCommands.ml driverInteractive.ml 
                           driverInterface.ml 
        src/networks/bittorrent: bTClients.ml bTGlobals.ml 
                                 bTInteractive.ml bTProtocol.ml 
                                 bTStats.ml bTTypes.ml 
        src/networks/donkey: donkeyClient.ml donkeyGlobals.ml 
                             donkeyInteractive.ml donkeyProtoClient.ml 
                             donkeyShare.ml donkeyStats.ml 
                             donkeyTypes.ml 

Log message:
        patch #5414

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1018&r2=1.1019
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.ml?cvsroot=mldonkey&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.mli?cvsroot=mldonkey&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonGlobals.ml?cvsroot=mldonkey&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonInteractive.ml?cvsroot=mldonkey&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonNetwork.ml?cvsroot=mldonkey&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.177&r2=1.178
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonServer.ml?cvsroot=mldonkey&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonShared.ml?cvsroot=mldonkey&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonStats.ml?cvsroot=mldonkey&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonTypes.ml?cvsroot=mldonkey&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiDecoding.ml?cvsroot=mldonkey&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiEncoding.ml?cvsroot=mldonkey&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiProto.ml?cvsroot=mldonkey&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiTypes.ml?cvsroot=mldonkey&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverCommands.ml?cvsroot=mldonkey&r1=1.176&r2=1.177
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverInteractive.ml?cvsroot=mldonkey&r1=1.102&r2=1.103
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverInterface.ml?cvsroot=mldonkey&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTClients.ml?cvsroot=mldonkey&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTGlobals.ml?cvsroot=mldonkey&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTInteractive.ml?cvsroot=mldonkey&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTProtocol.ml?cvsroot=mldonkey&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTStats.ml?cvsroot=mldonkey&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTTypes.ml?cvsroot=mldonkey&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyClient.ml?cvsroot=mldonkey&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyGlobals.ml?cvsroot=mldonkey&r1=1.97&r2=1.98
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyInteractive.ml?cvsroot=mldonkey&r1=1.124&r2=1.125
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyProtoClient.ml?cvsroot=mldonkey&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyShare.ml?cvsroot=mldonkey&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyStats.ml?cvsroot=mldonkey&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyTypes.ml?cvsroot=mldonkey&r1=1.47&r2=1.48

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1018
retrieving revision 1.1019
diff -u -b -r1.1018 -r1.1019
--- distrib/ChangeLog   22 Sep 2006 17:39:51 -0000      1.1018
+++ distrib/ChangeLog   23 Sep 2006 20:29:46 -0000      1.1019
@@ -14,6 +14,16 @@
 ChangeLog
 =========
 
+2006/09/23
+5414: Edonkey comments, update gui prot, some bt peer ids (zet)
+- Reimplement edonkey file comments with ratings (ro)
+  (fixes exploitable DOS introduced in patch #5371)
+- Add options "comments_filter", "max_comments_per_file", "max_comment_length"
+- GUI protocol updated for comments, stats, libmagic, users/groups
+- BT: Identify some more peer ids, as well as the reserved bits
+- Fix some html code and other bugs
+- Minor code cleanup
+
 2006/09/22
 5411: Portinfo: Rename gift_port to gift_port GUI
 

Index: src/daemon/common/commonFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.ml,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- src/daemon/common/commonFile.ml     19 Sep 2006 17:07:42 -0000      1.61
+++ src/daemon/common/commonFile.ml     23 Sep 2006 20:29:46 -0000      1.62
@@ -47,7 +47,7 @@
     mutable impl_file_update : int;
     mutable impl_file_state : file_state;
 
-    mutable impl_file_comment : string list;
+    mutable impl_file_comment : string;
     mutable impl_file_num : int;
     mutable impl_file_val : 'a;
     mutable impl_file_ops : 'a file_ops;
@@ -88,6 +88,7 @@
     mutable op_file_recover : ('a -> unit);
     mutable op_file_all_sources : ('a -> client list);
     mutable op_file_active_sources : ('a -> client list);
+    mutable op_file_comment : ('a -> string);
     mutable op_file_set_priority : ('a -> int -> unit);
     mutable op_file_print_html : ('a -> Buffer.t -> unit);
     mutable op_file_print_sources_html : ('a -> Buffer.t -> unit);
@@ -134,7 +135,7 @@
     impl_file_magic = None;
     impl_file_priority = 0;
     impl_file_last_seen = 0;
-    impl_file_comment = [];
+    impl_file_comment = "";
     impl_file_probable_name = None;
     impl_file_owner = admin_user;
     impl_file_group = Some system_user_default_group;
@@ -213,6 +214,10 @@
   let file = as_file_impl file in
   file.impl_file_ops.op_file_save_as file.impl_file_val name
 
+let file_comment (file : file) =
+  let file = as_file_impl file in
+  file.impl_file_ops.op_file_comment file.impl_file_val
+
 let file_network (file : file) =
   let file = as_file_impl file in
   file.impl_file_ops.op_file_network
@@ -227,11 +232,14 @@
 let file_group file =
   (as_file_impl file).impl_file_group
 
-let file_group_text file =
-  match (as_file_impl file).impl_file_group with
+let impl_group_text impl =
+  match impl.impl_file_group with
     Some group -> group
   | None -> "None"
 
+let file_group_text file =
+  impl_group_text (as_file_impl file)
+
 let user2_allow_file_admin file gui_user =
   user2_is_admin gui_user || file_owner file = gui_user
 
@@ -299,15 +307,12 @@
   update_file_state impl state
 
 let set_file_comment file comment =
-  if not (List.mem comment (as_file_impl file).impl_file_comment) then
-  (as_file_impl file).impl_file_comment <-
-    (as_file_impl file).impl_file_comment @ [(HashComments.merge file_comments 
comment)]
+  let impl = as_file_impl file in
+  impl.impl_file_comment <- comment
 
 let file_comment file =
-  (as_file_impl file).impl_file_comment
-
-let file_comment_length file =
-  List.length (as_file_impl file).impl_file_comment
+  let impl = as_file_impl file in
+  impl.impl_file_comment
 
 let file_best_name (file : file) =
   let file = as_file_impl file in
@@ -531,7 +536,9 @@
 let set_file_magic file magic =
   match magic with
     None -> ()
-  | Some magic -> (as_file_impl file).impl_file_magic <- Some (HashMagic.merge 
files_magic magic)
+  | Some magic -> 
+    (as_file_impl file).impl_file_magic <- Some (intern magic);
+    file_must_update file
 
 let check_magic file =
   let check file =
@@ -707,16 +714,19 @@
 }
 //--\\>
 \\</script\\>" (file_num file)
+   ^ "\\<table border=0 cellspacing=0 cellpadding=0\\>\\<tr\\>"
    ^ "\\<form name=\\\"chownForm1\\\" id=\\\"chownForm1\\\" 
action=\\\"javascript:submitChownForm(1);\\\"\\>"
+   ^ "\\<td\\>"
    ^ "\\<select name=\\\"newOwner\\\" id=\\\"newOwner\\\" "
    ^ "style=\\\"padding: 0px; font-size: 10px; font-family: verdana\\\" 
onchange=\\\"this.form.submit()\\\"\\>"
    ^ Printf.sprintf "\\<option value=\\\"%s\\\" selected\\>%s\\</option\\>\n" 
(file_owner file) (file_owner file)
-   ^ !optionlist ^ "\\</select\\>\\</form\\>\\</input\\>" ) ];
+   ^ !optionlist ^ "\\</select\\>\\</td\\>\\</form\\>\\</tr\\>\\</table\\>"
+    ) ];
 
       else
         html_mods_td buf [("File owner", "sr br", "User"); ("", "sr", 
(file_owner file))];
 
-      Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
+      Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" 
(html_mods_cntr ());
       if user2_allow_file_admin file o.conn_user.ui_user_name &&
          user2_user_groups_safe o.conn_user.ui_user_name <> [] then
         let optionlist =
@@ -741,11 +751,14 @@
 }
 //--\\>
 \\</script\\>" (file_num file)
+   ^ "\\<table border=0 cellspacing=0 cellpadding=0\\>\\<tr\\>"
    ^ "\\<form name=\\\"chgrpForm1\\\" id=\\\"chgrpForm1\\\" 
action=\\\"javascript:submitChgrpForm(1);\\\"\\>"
+   ^ "\\<td\\>"
    ^ "\\<select name=\\\"newGroup\\\" id=\\\"newGroup\\\" "
    ^ "style=\\\"padding: 0px; font-size: 10px; font-family: verdana\\\" 
onchange=\\\"this.form.submit()\\\"\\>"
    ^ Printf.sprintf "\\<option value=\\\"%s\\\" selected\\>%s\\</option\\>\n" 
(file_group_text file) (file_group_text file)
-   ^ !optionlist ^ "\\</select\\>\\</form\\>\\</input\\>" ) ];
+   ^ !optionlist ^ "\\</select\\>\\</td\\>\\</form\\>\\</tr\\>\\</table\\>"
+  ) ];
 
       else
         html_mods_td buf [("File group", "sr br", "Group");
@@ -753,7 +766,7 @@
           Some group -> Printf.sprintf "%s" group
         | None -> "None"))];
 
-      Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-2\\\"\\>";
+      Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" 
(html_mods_cntr ());
       html_mods_td buf [
         ("Number of file sources", "sr br", "Sources");
         ("", "sr", Printf.sprintf "%d" (List.length srcs)) ];
@@ -798,22 +811,6 @@
             ("", "sr", magic) ]
        | _ -> ());
 
-      (
-       if file_comment file <> [] then
-         begin
-           let list_header = ref true in
-           List.iter (fun s ->
-             Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" 
(html_mods_cntr ());
-             if !list_header then html_mods_td buf [
-               ("File comments", "sr br", "File comments");
-               ("", "sr", s) ]
-             else
-               html_mods_td buf [
-               ("", "sr br", "");
-               ("", "sr", s) ];
-           if !list_header then list_header := false) (file_comment file);
-         end);
-
       file_print_html file buf;
       
       Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>"; 
@@ -1012,6 +1009,7 @@
       op_file_set_format = (fun _ -> fni network "file_set_format");
       op_file_all_sources = (fun _ -> fni network "file_all_sources");
       op_file_active_sources = (fun _ -> fni network "file_active_sources");
+      op_file_comment = (fun _ -> ni_ok network "file_comment"; "");
       op_file_set_priority = (fun _ _ -> ni_ok network "file_set_priority");
       op_file_print_html = (fun _ _ -> ni_ok network "file_print_html");
       op_file_print_sources_html = (fun _ _ -> fni network 
"file_print_sources_html");
@@ -1080,12 +1078,6 @@
       ) files_by_num;
       Printf.bprintf buf "  files: %d\n" !counter;
       Printf.bprintf buf "  files_ops: %d\n" (List.length !files_ops);
-      let counter = ref 0 in
-      HashMagic.iter (fun _ -> incr counter) files_magic;
-      Printf.bprintf buf "  files_magic: %d\n" !counter;
-      let counter = ref 0 in
-      HashComments.iter (fun _ -> incr counter) file_comments;
-      Printf.bprintf buf "  files_comments: %d\n" !counter
   )
 
 
@@ -1203,7 +1195,7 @@
   let module T = GuiTypes in
   {
     T.file_fields = T.Fields_file_info.all;
-    T.file_comment = "";
+    T.file_comment = impl.impl_file_comment;
     T.file_name = impl.impl_file_best_name;
     T.file_names = impl.impl_file_filenames;
     T.file_num = impl.impl_file_num;
@@ -1226,4 +1218,8 @@
     T.file_chunks_age = [||];
     T.file_uids = [];
     T.file_sub_files = [];
+    T.file_magic = impl.impl_file_magic;
+    T.file_comments = [];
+    T.file_user = impl.impl_file_owner;
+    T.file_group = (impl_group_text impl);
   }

Index: src/daemon/common/commonFile.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.mli,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- src/daemon/common/commonFile.mli    19 Sep 2006 17:07:42 -0000      1.21
+++ src/daemon/common/commonFile.mli    23 Sep 2006 20:29:46 -0000      1.22
@@ -23,7 +23,7 @@
     mutable impl_file_update : int;
     mutable impl_file_state : CommonTypes.file_state;
     
-  mutable impl_file_comment : string list;
+    mutable impl_file_comment : string;
   mutable impl_file_num : int;
   mutable impl_file_val : 'a;
   mutable impl_file_ops : 'a file_ops;
@@ -55,6 +55,7 @@
   mutable op_file_recover : 'a -> unit;
   mutable op_file_all_sources : 'a -> CommonTypes.client list;
   mutable op_file_active_sources : 'a -> CommonTypes.client list;
+  mutable op_file_comment : 'a -> string;
   mutable op_file_set_priority : 'a -> int -> unit;
     mutable op_file_print_html: 'a -> Buffer.t -> unit;
     mutable op_file_print_sources_html : 'a -> Buffer.t -> unit;
@@ -77,6 +78,7 @@
 val update_file_state : 'a file_impl -> CommonTypes.file_state -> unit
 val file_to_option : CommonTypes.file -> (string * Options.option_value) list
 val file_save_as : CommonTypes.file -> string -> unit
+val file_comment : CommonTypes.file -> string
 val file_network : CommonTypes.file -> CommonTypes.network
 val file_info : CommonTypes.file -> GuiTypes.file_info
 val file_pause : CommonTypes.file -> string -> unit
@@ -120,8 +122,7 @@
 val set_file_last_seen : CommonTypes.file -> int -> unit
 val file_debug : CommonTypes.file -> string
 val set_file_comment : CommonTypes.file -> string -> unit
-val file_comment : CommonTypes.file -> string list
-val file_comment_length : CommonTypes.file -> int
+val file_comment : CommonTypes.file -> string
 val file_magic : CommonTypes.file -> string option
 val set_file_magic : CommonTypes.file -> string option -> unit
 val check_magic : CommonTypes.file -> unit  

Index: src/daemon/common/commonGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonGlobals.ml,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- src/daemon/common/commonGlobals.ml  16 Sep 2006 15:36:08 -0000      1.71
+++ src/daemon/common/commonGlobals.ml  23 Sep 2006 20:29:46 -0000      1.72
@@ -890,18 +890,30 @@
       activity := new_activity ()
   )
 
-module HashMagic = Weak.Make(struct
+module StringIntern = Weak.Make(struct
         type t = string
         let hash s = Hashtbl.hash s
         let equal x y = x = y
       end)
 
-let files_magic = HashMagic.create 100
+let intern_table = StringIntern.create 1000
+let intern s = StringIntern.merge intern_table s
 
-module HashComments = Weak.Make(struct
-        type t = string
-        let hash s = Hashtbl.hash s
-        let equal x y = x = y
-      end)
 
-let file_comments = HashComments.create 1000
+let _ =
+  Heap.add_memstat "CommonGlobals" (fun level buf ->
+      let counter = ref 0 in
+      StringIntern.iter (fun f -> incr counter;) intern_table;
+      Printf.bprintf buf "  intern_table: %d\n" !counter;
+      Printf.bprintf buf " core_gui_fifo: %d\n" (Fifo.length core_gui_fifo);
+      Printf.bprintf buf " gui_core_fifo: %d\n" (Fifo.length gui_core_fifo);
+      Printf.bprintf buf " chat_message_fifo: %d\n" (Fifo.length 
chat_message_fifo);
+      Printf.bprintf buf " upload_history: %d\n" (Fifo.length upload_history);
+      Printf.bprintf buf " download_history: %d\n" (Fifo.length 
download_history);
+      Printf.bprintf buf " upload_h_history: %d\n" (Fifo.length 
upload_h_history);
+      Printf.bprintf buf " download_h_history: %d\n" (Fifo.length 
download_h_history);
+      Printf.bprintf buf " bandwidth_samples: %d\n" (Fifo.length 
bandwidth_samples);
+      Printf.bprintf buf " short_delay_bandwidth_samples: %d\n" (Fifo.length 
short_delay_bandwidth_samples);
+      Printf.bprintf buf " dummy_sample: %d\n" (Array.length dummy_sample);
+      Printf.bprintf buf " activities: %d\n" (Fifo.length activities);
+  )

Index: src/daemon/common/commonInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonInteractive.ml,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- src/daemon/common/commonInteractive.ml      19 Sep 2006 17:07:42 -0000      
1.81
+++ src/daemon/common/commonInteractive.ml      23 Sep 2006 20:29:46 -0000      
1.82
@@ -327,11 +327,8 @@
       (let age = (BasicSocket.last_time ()) - info.G.file_age in 
Date.time_to_string age "verbose")
     in
 
-    let line3 = if (file_comment file) = [] then "" else
-       let buf = Buffer.create 1000 in
-        Printf.bprintf buf "\r\nComments:\r\n";
-       List.iter (fun s -> Printf.bprintf buf "%s\r\n" s;) (file_comment file);
-       Buffer.contents buf
+    let line3 = if (file_comment file) = "" then "" else
+        Printf.sprintf "\r\nComment: %s\r\n" (file_comment file)
     in
 
     let subject = if !!filename_in_subject then

Index: src/daemon/common/commonNetwork.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonNetwork.ml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- src/daemon/common/commonNetwork.ml  19 Sep 2006 17:07:42 -0000      1.30
+++ src/daemon/common/commonNetwork.ml  23 Sep 2006 20:29:46 -0000      1.31
@@ -99,6 +99,8 @@
         lprintf_nl "op_network_clean_servers";
       if c.op_network_display_stats == cc.op_network_display_stats then 
         lprintf_nl "op_network_display_stats";
+      if c.op_network_stat_info_list == cc.op_network_stat_info_list then
+        lprintf_nl "op_network_stat_info_list";
       if c.op_network_info == cc.op_network_info then 
         lprintf_nl "op_network_info";
       if c.op_network_clean_exit == cc.op_network_clean_exit then 
@@ -275,6 +277,7 @@
       op_network_gui_message = (fun _ _ -> ni_ok name "gui_message");
       op_network_download = (fun _ _ -> fni name "network_download");
       op_network_display_stats = (fun _ _ -> ni_ok name "display_stats");
+      op_network_stat_info_list = (fun _ -> []);
       op_network_clean_exit = (fun _ -> true);
       op_network_reset = (fun _ -> ni_ok name "reset");
       op_network_ports = (fun _ -> ni_ok name "ports"; []);

Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -b -r1.177 -r1.178
--- src/daemon/common/commonOptions.ml  19 Sep 2006 17:07:42 -0000      1.177
+++ src/daemon/common/commonOptions.ml  23 Sep 2006 20:29:46 -0000      1.178
@@ -357,6 +357,7 @@
   String2.tokens
 
 let is_not_spam = ref (fun _ -> true)
+let is_not_comment_spam = ref (fun _ -> true)
 
 
 
@@ -1296,6 +1297,10 @@
   "Regexp of messages to filter out, example: string1|string2|string3"
     string_option "Your client is connecting too fast"
 
+let comments_filter = define_option current_section ["comments_filter"]
+  "Regexp of comments to filter out, example: string1|string2|string3"
+    string_option "http://|https://|www\\."
+
 
 
 
@@ -1531,6 +1536,13 @@
     int_option 14
 
 
+let max_comments_per_file = define_expert_option current_section 
["max_comments_per_file"]
+  "Maximum number of comments per file"
+  int_option 100
+
+let max_comment_length = define_expert_option current_section 
["max_comment_length"]
+  "Maximum length of file comments"
+  int_option 256
 
 
 (*************************************************************************)
@@ -1904,14 +1916,25 @@
   in aux 0
       
 let _ =
-  option_hook messages_filter (fun _ ->
-      is_not_spam := if !!messages_filter <> "" then
-        let r = Str.regexp_case_fold (quote_unquote_bars !!messages_filter) in
-        (fun s -> try
+  let regex_fun str = 
+    if str <> "" then
+      let r = Str.regexp_case_fold (quote_unquote_bars str) in
+      (fun s -> 
+        try
               ignore (Str.search_forward r s 0);
               false
-            with Not_found -> true)
-      else (fun _ -> true))
+        with Not_found -> true
+      )
+    else (fun _ -> true)
+  in
+
+  option_hook messages_filter (fun _ ->
+      is_not_spam := regex_fun !!messages_filter
+  );
+
+  option_hook comments_filter (fun _ ->
+      is_not_comment_spam := regex_fun !!comments_filter
+  )
 
 let http_proxy = ref None
 

Index: src/daemon/common/commonServer.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonServer.ml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- src/daemon/common/commonServer.ml   6 Aug 2006 13:59:05 -0000       1.33
+++ src/daemon/common/commonServer.ml   23 Sep 2006 20:29:46 -0000      1.34
@@ -370,8 +370,8 @@
     ( "0", "srh", "[Hi]gh or [Lo]w ID", "ID" ) ;
     ( "0", "srh", "Network name", "Network" ) ;
     ( "0", "srh", "Connection status", "Status" ) ;
-    ] @ (if !Geoip.active then [( "0", "srh", "Country Code/Name", "CC" )] 
else []) @ [
     ( "0", "srh br", "IP address", "IP address" ) ;
+    ] @ (if !Geoip.active then [( "0", "srh br", "Country Code/Name", "CC" )] 
else []) @ [
     ( "1", "srh ar", "Number of connected users", "Users" ) ;
     ( "1", "srh ar br", "Max number of users", "MaxUsers" ) ;
     ( "1", "srh ar br", "LowID users", "LowID" ) ;
@@ -399,50 +399,34 @@
   if use_html_mods o then begin
   let snum = (server_num s) in
 
-    Printf.bprintf buf "
-    \\<tr class=\\\"dl-%d\\\"\\>
+    Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>
     \\<td class=\\\"srb\\\" %s \\>%d\\</td\\>
-    %s
-    %s
-    %s
-    \\<td class=\\\"sr\\\" %s\\</td\\>
-    \\<td class=\\\"sr\\\"\\>%s\\</td\\>
-    \\<td class=\\\"sr\\\"\\>%s\\</td\\>
-    %s
-    \\<td class=\\\"sr br\\\"\\>%s:%s\\</td\\>
-    \\<td class=\\\"sr ar\\\"\\>%Ld\\</td\\>
-    \\<td class=\\\"sr ar br\\\"\\>%Ld\\</td\\>
-    \\<td class=\\\"sr ar br\\\"\\>%Ld\\</td\\>
-    \\<td class=\\\"sr ar br\\\"\\>%Ld\\</td\\>
-    \\<td class=\\\"sr ar\\\"\\>%Ld\\</td\\>
-    \\<td class=\\\"sr ar br\\\"\\>%Ld\\</td\\>
-    \\<td class=\\\"sr ar br\\\"\\>%d\\</td\\>
-    \\<td class=\\\"sr br\\\"\\>%s\\</td\\>
-    \\<td class=\\\"sr\\\"\\>%s\\</td\\>
-    \\<td width=\\\"100%%\\\" class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>\n"
+      %s %s %s"
     (html_mods_cntr ())
     (match impl.impl_server_state with
-        Connected _ -> Printf.sprintf "title=\\\"Server Banner\\\"
+        Connected _ -> 
+            Printf.sprintf "title=\\\"Server Banner\\\"
             onMouseOver=\\\"mOvr(this);\\\"
             onMouseOut=\\\"mOut(this);\\\"
-            onClick=\\\"location.href='submit?q=server_banner+%d'\\\"" snum
+            onClick=\\\"location.href='submit?q=server_banner+%d'\\\"" 
+            snum
         | _ -> "")
     snum
       (
-        if server_blocked s && (match impl.impl_server_state with
-         NotConnected _ -> true
-             | _ -> false) then "\\<td class=\\\"srb\\\"\\>blk\\</td\\>" else
-        Printf.sprintf
+     let not_connected =
+        match impl.impl_server_state with
+        | NotConnected _ -> true
+        | _ -> false 
+      in 
+      if server_blocked s && not_connected 
+        then "\\<td class=\\\"srb\\\"\\>blk\\</td\\>" 
+        else Printf.sprintf
         "\\<TD class=\\\"srb\\\" onMouseOver=\\\"mOvr(this);\\\"
         onMouseOut=\\\"mOut(this);\\\" title=\\\"Connect|Disconnect\\\"
         
onClick=\\\"parent.fstatus.location.href='submit?q=%s+%d'\\\"\\>%s\\</TD\\>"
-        (match impl.impl_server_state with
-           NotConnected _ -> "c"
-         | _ -> "x")
+              (if not_connected then "c" else "x")
         snum
-        (match impl.impl_server_state with
-           NotConnected _ -> "Conn"
-         | _ -> "Disc")
+              (if not_connected then "Conn" else "Disc")
       )
       (
         Printf.sprintf
@@ -465,12 +449,13 @@
         
onClick=\\\"parent.fstatus.location.href='submit?q=preferred+true+%s'\\\"\\>F\\</TD\\>"
         (Ip.string_of_addr info.G.server_addr)
         end
-      )
-      (if n.network_name = "Donkey" then
-         begin
+      );
+
+      let id_title, id_text = 
+        match n.network_name with
+          "Donkey" -> begin
            match impl.impl_server_state with
-           | Connected _ ->
-               begin
+                Connected _ -> begin
                  let cid = (server_cid s) in
                  let (label,shortlabel,our_ip) =
                    if not (server_low_id s) then
@@ -478,49 +463,57 @@
                       (if !!set_client_ip <> cid then
                          Printf.sprintf "(clientIP: %s)"
                            (Ip.to_string !!set_client_ip)
-                       else ""
-                      )
-                     )
-                   else
-                     ("LowID","Lo","")
+                       else ""))
+                    else ("LowID","Lo","")
                  in
-                 Printf.sprintf
-                    "title=\\\"%s: %s = %s %s\\\" \\>%s"
+                   Printf.sprintf "%s: %s = %s %s"
                       label
                       (Int64.to_string (Ip.to_int64 (Ip.rev cid)))
                       (Ip.to_string cid)
                       our_ip
-                      shortlabel
+                 ,shortlabel
                end
-           | _ -> "\\>"
+               | _ -> "",""
          end
-       else "\\>"
-      )
-      n.network_name
-      (match impl.impl_server_state with
-        NotConnected _ -> if server_blocked s then "IP blocked"
-        else (string_of_connection_state impl.impl_server_state)
-      | _ -> (string_of_connection_state impl.impl_server_state))
-      (if !Geoip.active then 
-        Printf.sprintf "\\<td class=\\\"sr\\\" title=\\\"%s\\\" 
\\>%s\\</td\\>" cn cc
-       else "")
+      | _ -> "",""
+    in
+
+    let server_state_string = 
+      match impl.impl_server_state with
+        NotConnected _ when server_blocked s -> "IP blocked"
+      | _ -> string_of_connection_state impl.impl_server_state
+    in
+
+    let ip_port_string = 
+      Printf.sprintf "%s:%s%s" 
       (Ip.string_of_addr info.G.server_addr)
-      (Printf.sprintf "%s%s"
        (string_of_int info.G.server_port)
        (if info.G.server_realport <> 0 
           then "(" ^ (string_of_int info.G.server_realport) ^ ")" 
-          else ""))
-      info.G.server_nusers
-      info.G.server_max_users
-      info.G.server_lowid_users
-      info.G.server_nfiles
-      info.G.server_soft_limit
-      info.G.server_hard_limit
-      info.G.server_ping
-      info.G.server_version
-      info.G.server_name
-      info.G.server_description
+            else ""
+        )
+    in
+
+    let cc,cn = Geoip.get_country (Ip.ip_of_addr info.G.server_addr) in
+    html_mods_td buf ([
+      (id_title, "sr", id_text);
+      ("", "sr", n.network_name);
+      ("", "sr", server_state_string);
+      ("", "sr br", ip_port_string);
+      ] @ (if !Geoip.active then [(cn, "sr br", cc)] else []) @ [
+      ("", "sr ar", Printf.sprintf "%Ld" info.G.server_nusers);
+      ("", "sr ar br", Printf.sprintf "%Ld" info.G.server_max_users);
+      ("", "sr ar br", Printf.sprintf "%Ld" info.G.server_lowid_users);
+      ("", "sr ar br", Printf.sprintf "%Ld" info.G.server_nfiles);
+      ("", "sr ar", Printf.sprintf "%Ld" info.G.server_soft_limit);
+      ("", "sr ar br", Printf.sprintf "%Ld" info.G.server_hard_limit);
+      ("", "sr ar br", Printf.sprintf "%d" info.G.server_ping);
+      ("", "sr br", info.G.server_version);
+      ("", "sr", info.G.server_name);
+    ]);
 
+    Printf.bprintf buf "\\<td width=\\\"100%%\\\" 
class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>\n"
+      info.G.server_description;
   end
    else
   begin

Index: src/daemon/common/commonShared.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonShared.ml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- src/daemon/common/commonShared.ml   12 Jun 2006 20:47:21 -0000      1.33
+++ src/daemon/common/commonShared.ml   23 Sep 2006 20:29:46 -0000      1.34
@@ -352,6 +352,7 @@
     T.shared_requests = impl.impl_shared_requests; 
     T.shared_uids = [];
     T.shared_sub_files = [];
+    T.shared_magic = impl.impl_shared_magic;
   }
   
 let shared_info s =

Index: src/daemon/common/commonStats.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonStats.ml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/daemon/common/commonStats.ml    26 Aug 2006 12:05:53 -0000      1.3
+++ src/daemon/common/commonStats.ml    23 Sep 2006 20:29:46 -0000      1.4
@@ -87,12 +87,16 @@
   done;
   s
 
-let brandlist_int_to_string l i =
+let brandlist_int_to_2string l i =
   if List.length l > i then
-    let (_,ls,_) = List.nth l i in
-    ls
+    let (_,ls,ss) = List.nth l i in
+    ls,ss
   else
-    "Total"
+    "Total","Ttl"
+
+let brandlist_int_to_string l i =
+  let (ls,_) = brandlist_int_to_2string l i in 
+  ls
 
 let print_stats_old buf arr l tl uptime =
 
@@ -234,6 +238,26 @@
    ( "1", "srh", "Total uploads:downloads ratio", "U:DL" );
   ]
 
+let stats_list l arr = 
+  let sl = ref [] in
+  for i = 0 to (Array.length arr) - 1 do
+    let r = arr.(i) in
+    if r.brand_seen > 0 then begin
+      let ls,ss = brandlist_int_to_2string l i in
+      let s = {
+        string_long = ls;
+        string_short = ss;
+        seen = r.brand_seen;
+        banned = r.brand_banned;
+        filerequest = r.brand_filerequest;
+        download = r.brand_download;
+        upload = r.brand_upload;
+      } in
+      sl := s :: !sl
+    end
+  done;
+  !sl
+
 let print_stats_html_mods buf arr l tl uptime =
 
   let stats_all = build_all arr in

Index: src/daemon/common/commonTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonTypes.ml,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- src/daemon/common/commonTypes.ml    19 Sep 2006 17:07:42 -0000      1.56
+++ src/daemon/common/commonTypes.ml    23 Sep 2006 20:29:46 -0000      1.57
@@ -452,6 +452,16 @@
   ExtendSearchLocally
 | ExtendSearchRemotely
   
+type network_stat_info  = {
+  mutable string_long : string;
+  mutable string_short : string;
+  mutable seen : int;
+  mutable banned : int;
+  mutable filerequest : int;
+  mutable download : Int64.t;
+  mutable upload : Int64.t;
+}
+  
 type network = {
     network_name : string;
     network_num : int;
@@ -496,6 +506,7 @@
     
     mutable op_network_download : (result_info -> string -> file);
     mutable op_network_display_stats : (Buffer.t -> ui_conn -> unit);
+    mutable op_network_stat_info_list : unit -> (string * int * 
(network_stat_info list)) list;
     mutable op_network_clean_exit : (unit -> bool);
     mutable op_network_reset : (unit -> unit);
     mutable op_network_ports : (unit -> (int * string) list);

Index: src/daemon/common/guiDecoding.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiDecoding.ml,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- src/daemon/common/guiDecoding.ml    1 Sep 2006 16:22:14 -0000       1.59
+++ src/daemon/common/guiDecoding.ml    23 Sep 2006 20:29:46 -0000      1.60
@@ -506,13 +506,29 @@
 let get_int_pos s pos =
   get_int s pos, pos + 4
   
-let get_sub_files s pos =
+let get_sub_files proto s pos =
   get_list (fun s pos ->
     let name, pos = get_string s pos in
     let size, pos = get_int64 s pos, pos+8 in
-    (name, size, Some ""), pos
+    let magic, pos = 
+      if proto > 40 then
+        get_string s pos
+      else
+        "", pos
+    in
+    (name, size, Some magic), pos
   ) s pos
   
+let get_file_comments proto s pos = 
+  get_list (fun s pos ->
+     let ip, pos = get_ip2 proto s pos in
+     let name, pos = get_string s pos in
+     let rating, pos = get_uint8 s pos, pos+1 in
+     let comment, pos = get_string s pos in
+     (ip, name, rating, comment), pos
+  ) s pos
+
+  
 let get_file proto s pos = 
   let num = get_int s pos in
   let net = get_int s (pos+4) in
@@ -557,10 +573,31 @@
   in
   let sub_files, pos =
     if proto > 35 then
-      get_sub_files s pos
+      get_sub_files proto s pos
     else [], pos
   in
-
+  let magic, pos = 
+    if proto > 40 then
+      let ms, pos = get_string s pos
+      in Some ms, pos 
+    else
+      Some "", pos
+  in
+  let comments, pos = 
+    if proto > 40 then
+      get_file_comments proto s pos
+    else [], pos
+  in
+  let user, pos = 
+    if proto > 40 
+      then get_string s pos
+      else "", pos
+  in
+  let group, pos = 
+    if proto > 40 
+      then get_string s pos
+      else "", pos
+  in
   (*
   assert (num = file_info_test.file_num);
   assert (net = file_info_test.file_network);
@@ -609,6 +646,10 @@
     file_priority = priority;
     file_uids = uids;
     file_sub_files = sub_files;
+    file_magic = magic;
+    file_comments = comments;
+    file_user = user;
+    file_group = group;
   }, pos
 
 let get_host_state proto s pos =
@@ -940,6 +981,7 @@
     shared_requests = requests;
     shared_uids = [];
     shared_sub_files = [];
+    shared_magic = Some "";
   }
 
 let get_shared_info_version_10 proto s pos =
@@ -957,9 +999,16 @@
   in
   let sub_files, pos =
     if proto > 36 then
-      get_sub_files s pos
+      get_sub_files proto s pos
     else [], pos
   in
+  let magic, pos = 
+    if proto > 40 then
+      let ms, pos = get_string s (pos) in
+      Some ms, pos
+    else
+      Some "", pos
+  in
   {
     shared_num = num;
     shared_network = network;
@@ -969,6 +1018,7 @@
     shared_requests = requests;
     shared_uids = uids;
     shared_sub_files = sub_files;
+    shared_magic = magic;
   }
 
 
@@ -1262,6 +1312,10 @@
          let b = get_bool s 6 in
          ServerSetPreferred (num, b)
 
+    | 68 ->
+         let num = get_int s 2 in
+         GetStats num
+
     | _ -> 
         lprintf_nl "FROM GUI:Unknown message %d" opcode; 
         raise FromGuiMessageNotImplemented

Index: src/daemon/common/guiEncoding.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiEncoding.ml,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- src/daemon/common/guiEncoding.ml    1 Sep 2006 16:22:14 -0000       1.57
+++ src/daemon/common/guiEncoding.ml    23 Sep 2006 20:29:46 -0000      1.58
@@ -542,10 +542,25 @@
       buf_int8 buf 18;
       buf_string buf x
     
-let buf_sub_files buf l =
-  buf_list buf (fun buf (name, size, _) ->
+let magic_string m =
+  match m with
+     Some s -> s
+   | None -> ""
+    
+let buf_sub_files proto buf l =
+  buf_list buf (fun buf (name, size, magic) ->
+    buf_string buf name;
+    buf_int64 buf size;
+    if proto > 40 then
+      buf_string buf (magic_string magic)
+  ) l
+
+let buf_file_comments proto buf l =
+  buf_list buf (fun buf (ip, name, rating, comment) ->
+    buf_ip2 proto buf ip;
     buf_string buf name;
-    buf_int64 buf size
+    buf_int8 buf rating;
+    buf_string buf comment;
   ) l
     
 let buf_file proto buf f =
@@ -587,7 +602,13 @@
     if proto > 30 then
       buf_list buf buf_uid f.file_uids;
     if proto > 35 then
-      buf_sub_files buf f.file_sub_files
+      buf_sub_files proto buf f.file_sub_files;
+    if proto > 40 then begin
+      buf_string buf (magic_string f.file_magic);
+      buf_file_comments proto buf f.file_comments;
+      buf_string buf f.file_user;
+      buf_string buf f.file_group;
+    end
       
 let buf_addr proto buf addr =
   (match addr with
@@ -727,8 +748,23 @@
     else
       buf_list buf buf_uid s.shared_uids;
   if proto > 36 then
-    buf_sub_files buf s.shared_sub_files
-
+    buf_sub_files proto buf s.shared_sub_files;
+  if proto > 40 then
+    buf_string buf (magic_string s.shared_magic)
+
+let buf_stat_info proto buf n =
+  buf_string buf n.string_long;
+  buf_string buf n.string_short;
+  buf_int buf n.seen;
+  buf_int buf n.banned;
+  buf_int buf n.filerequest;
+  buf_int64 buf n.download;
+  buf_int64 buf n.upload
+
+let buf_stat_info_list proto buf (s,i,l) =
+  buf_string buf s;
+  buf_int buf i;
+  buf_list2 proto buf buf_stat_info l
 
 (***************
 
@@ -1004,6 +1040,13 @@
     
     | GiftServerAttach _ -> assert false
     | GiftServerStats _ -> assert false
+
+    | Stats (num, l) ->
+        let proto = proto.(59) in
+        buf_opcode buf 59;
+        buf_int buf num;
+        buf_list2 proto buf buf_stat_info_list l
+
   with e ->
       lprintf "GuiEncoding.to_gui: Exception %s\n"
         (Printexc2.to_string e)
@@ -1217,6 +1260,9 @@
         buf_opcode buf 67;
         buf_int buf num;
         buf_bool buf preferred
+    | GetStats n ->
+        buf_opcode buf 68;
+        buf_int buf n
 
   with e ->
       lprintf "GuiEncoding.from_gui: Exception %s\n"

Index: src/daemon/common/guiProto.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiProto.ml,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- src/daemon/common/guiProto.ml       16 Jan 2006 16:05:14 -0000      1.24
+++ src/daemon/common/guiProto.ml       23 Sep 2006 20:29:46 -0000      1.25
@@ -29,9 +29,9 @@
   
 let gui_extension_poll = 1
   
-let to_gui_last_opcode = 58
-let from_gui_last_opcode = 67
-let best_gui_version = 40
+let to_gui_last_opcode = 59
+let from_gui_last_opcode = 68
+let best_gui_version = 41
   
 (* I will try to report all changes to the protocol here: send me patches
 if I don't !
@@ -166,6 +166,7 @@
 (* Understood by core protocol 32 *)
 | ServerRename of (int * string)
 | ServerSetPreferred of (int * bool)
+| GetStats of int
 
 type to_gui =
 (* This message is the first message sent by the core *)
@@ -233,6 +234,7 @@
   
 | GiftServerAttach of string * string
 | GiftServerStats of (string * string * string * string) list
+| Stats of int * (string * int * network_stat_info list) list  
   
   
 let string_of_from_gui t = 
@@ -311,6 +313,7 @@
 
   | ServerRename _ -> "ServerRename"
   | ServerSetPreferred _ -> "ServerSetPreferred"
+  | GetStats _ -> "GetStats"
 
 let string_of_to_gui t =
   match t with
@@ -380,6 +383,7 @@
       
   | GiftServerAttach _ -> "GiftServerAttach"
   | GiftServerStats _ -> "GiftServerStats"
+  | Stats _ -> "Stats"
       
 type gui_record = {
     mutable gui_num : int;

Index: src/daemon/common/guiTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiTypes.ml,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- src/daemon/common/guiTypes.ml       1 Sep 2006 16:22:14 -0000       1.29
+++ src/daemon/common/guiTypes.ml       23 Sep 2006 20:29:46 -0000      1.30
@@ -136,6 +136,10 @@
     mutable file_priority : int;
     mutable file_uids : Uid.t list;
     mutable file_sub_files : (string * int64 * string option) list;
+    mutable file_magic : string option;
+    mutable file_comments : (Ip.t * string * int * string) list;
+    mutable file_user : string;
+    mutable file_group : string;
   }
   
 type user_info = {
@@ -240,6 +244,7 @@
     mutable shared_requests : int;
     mutable shared_uids : Uid.t list; (* net file UID *)
     mutable shared_sub_files : (string * int64 * string option) list;
+    mutable shared_magic : string option;
   }
   
   
@@ -326,5 +331,9 @@
     file_priority = 0;
    file_uids = [];
     file_sub_files = [];
+    file_magic = Some "";
+    file_comments = [];
+    file_user = "";
+    file_group = "";
  } 
   

Index: src/daemon/driver/driverCommands.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -b -r1.176 -r1.177
--- src/daemon/driver/driverCommands.ml 19 Sep 2006 17:07:43 -0000      1.176
+++ src/daemon/driver/driverCommands.ml 23 Sep 2006 20:29:47 -0000      1.177
@@ -1560,7 +1560,6 @@
                        strings_of_option html_mods_use_relative_availability;
                        strings_of_option html_mods_human_readable;
                        strings_of_option html_mods_vd_network;
-                       strings_of_option html_mods_vd_comments;
                        strings_of_option html_mods_vd_active_sources;
                        strings_of_option html_mods_vd_age;
                        strings_of_option html_mods_vd_last;
@@ -1703,6 +1702,7 @@
                       [
                        strings_of_option term_ansi;
                        strings_of_option messages_filter;
+      strings_of_option comments_filter;
                        strings_of_option max_displayed_results;
                        strings_of_option max_name_len;
                        strings_of_option max_filenames;
@@ -2922,6 +2922,7 @@
        _s ""
     ), "<group> <admin: true | false> [<mail>] :\t\tadd new mldonkey group";
 
+(* This does nothing, why is it here?
     "groupdel", Arg_one (fun group o ->
         let buf = o.conn_buf in
 (*        if user2_is_admin o.conn_user.ui_user_name then _s ""
@@ -2929,6 +2930,7 @@
           print_command_result o buf "You are not allowed to remove users"; *)
        _s ""
     ), "<group> :\t\t\tremove an unused mldonkey group";
+*)
 
     "users", Arg_none (fun o ->
         let buf = o.conn_buf in

Index: src/daemon/driver/driverInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -b -r1.102 -r1.103
--- src/daemon/driver/driverInteractive.ml      19 Sep 2006 17:07:43 -0000      
1.102
+++ src/daemon/driver/driverInteractive.ml      23 Sep 2006 20:29:47 -0000      
1.103
@@ -230,6 +230,8 @@
        then file_availability f
        else string_availability f.file_availability
 
+let number_of_comments f =
+  List.length f.file_comments
 
 (* WARNING: these computations are much more expensive as they seem.
 We use the ShortLazy to avoid recomputing the result too many times,
@@ -671,7 +673,6 @@
 \\<td title=\\\"Sort by size\\\" class=dlheader\\>\\<input class=headbutton 
type=submit value=Size name=sortby\\>\\</td\\>
 \\<td title=\\\"Sort by size downloaded\\\" class=dlheader\\>\\<input 
class=\\\"headbutton ar\\\" type=submit value=DLed name=sortby\\>\\</td\\>
 \\<td title=\\\"Sort by percent\\\" class=dlheader\\>\\<input class=headbutton 
type=submit value=%% name=sortby\\>\\</td\\>";
-
 if !!html_mods_vd_comments then Printf.bprintf buf
 "\\<td title=\\\"Sort by comments\\\" class=dlheader\\>\\<input 
style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton 
type=submit value=Cm name=sortby\\>\\</td\\>";
 
@@ -713,19 +714,21 @@
                         | Some magic -> "File type: " ^ 
(Http_server.html_real_escaped magic) ^ "<br>")
                        file.file_num
                         (net_name file)
-                       (let comments = file_comment (file_find file.file_num) 
in
-                          if comments = [] then "" else
+
+      (if file.file_comments = [] then "" else
                            begin
-                             let buf1 = Buffer.create 100 in
-                             Printf.bprintf buf1 "<br><br>Comments:<br>";
-                             List.iter (fun s -> Printf.bprintf buf1 "%s<br>" 
(Http_server.html_real_escaped s)) comments;
+           let num_comments = number_of_comments file in
+           let buf1 = Buffer.create (100 * num_comments) in
+           Printf.bprintf buf1 "<br><br>Comments(%d):<br>" (num_comments);
+           (* What if there are 100 comments? big tooltip... *)
+           List.iter (fun (_,_,_,s) -> Printf.bprintf buf1 "%s<br>" 
(Http_server.html_real_escaped s)) file.file_comments;
                              Buffer.contents buf1
                            end)
+
                        !!html_mods_js_tooltips_wait
                        !!html_mods_js_tooltips_timeout
                        !!html_mods_js_tooltips_wait
-                        else Printf.sprintf "
-                               onMouseOver=\\\"mOvr(this);return true;\\\" 
onMouseOut=\\\"mOut(this);\\\"\\>");
+       else Printf.sprintf " onMouseOver=\\\"mOvr(this);return true;\\\" 
onMouseOut=\\\"mOut(this);\\\"\\>");
 
        (if downloading file then
               Printf.sprintf "\\<td class=\\\"dl al np\\\"\\>\\<input 
class=checkbox name=pause type=checkbox value=%d\\>\\</td\\>
@@ -763,14 +766,14 @@
             (truncate ( (1. -. downloaded /. size) *. 100.))
         else
             Printf.sprintf "\\<TD 
onClick=\\\"location.href='submit?q=vd+%d';return true;\\\"
-                        title=\\\"[File#: %d] [Net: %s]%s\\\" class=\\\"dl 
al\\\"\\>%s\\<br\\>
+                        title=\\\"[File#: %d] [Net: %s] [Comments: %d]%s\\\" 
class=\\\"dl al\\\"\\>%s\\<br\\>
                         \\<table cellpadding=0 cellspacing=0 
width=100%%\\>\\<tr\\>
                         \\<td class=\\\"loaded\\\" style=\\\"height:%dpx\\\" 
width=\\\"%d%%\\\"\\> \\</td\\>
                         \\<td class=\\\"remain\\\" style=\\\"height:%dpx\\\" 
width=\\\"%d%%\\\"\\> \\</td\\>
                         \\</tr\\>\\</table\\>\\</td\\>"
             file.file_num
             file.file_num
-                        (net_name file)
+                        (net_name file) (number_of_comments file)
                         (if !!max_name_len < String.length file.file_name then 
" " ^ file.file_name else "")
             (short_name file)
             (!!html_vd_barheight)
@@ -784,9 +787,8 @@
           (ctd file.file_num (Printf.sprintf "%.1f" (percent file)));
 
           (if !!html_mods_vd_comments then
-                       Printf.sprintf "\\<td 
onClick=\\\"location.href='submit?q=vd+%d';return true;\\\"
-                       class=\\\"dl al\\\"\\>%d\\</td\\>"
-                       file.file_num (file_comment_length (file_find 
file.file_num)) else "");
+            ctd file.file_num (Printf.sprintf "%d" (number_of_comments file))
+            else "");
 
           (ctd file.file_num (Printf.sprintf "%d" (number_of_sources file)));
 
@@ -1103,7 +1105,7 @@
         | ByLast -> (fun f1 f2 -> f1.file_last_seen >= f2.file_last_seen)
         | ByNet -> (fun f1 f2 -> net_name f1 <= net_name f2)
         | ByAvail -> (fun f1 f2 -> get_file_availability f1 >= 
get_file_availability f2)
-        | ByComments -> (fun f1 f2 -> file_comment_length (file_find 
f1.file_num) >= file_comment_length (file_find f2.file_num))
+        | ByComments -> (fun f1 f2 -> (number_of_comments f1) >= 
(number_of_comments f2))
         | NotSorted -> raise Not_found
       in
       Sort.list sorter list

Index: src/daemon/driver/driverInterface.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverInterface.ml,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- src/daemon/driver/driverInterface.ml        19 Sep 2006 17:07:43 -0000      
1.53
+++ src/daemon/driver/driverInterface.ml        23 Sep 2006 20:29:47 -0000      
1.54
@@ -1058,6 +1058,11 @@
           | P.GetVersion ->
               gui_send gui (P.Version Autoconf.current_version)
 
+          | P.GetStats num ->
+              let n = network_find_by_num num in
+              let l = n.op_network_stat_info_list () in
+              gui_send gui (P.Stats (num, l))
+
           | P.GiftAttach (profile, version, client) ->
              let user, pass =
                try

Index: src/networks/bittorrent/bTClients.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTClients.ml,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- src/networks/bittorrent/bTClients.ml        16 Sep 2006 09:47:17 -0000      
1.77
+++ src/networks/bittorrent/bTClients.ml        23 Sep 2006 20:29:47 -0000      
1.78
@@ -414,6 +414,17 @@
 
 let counter = ref 0
 
+let parse_reserved rbits c =
+  let has_bit pos h = Char.code rbits.[pos] land h <> 0 in
+  
+  c.client_dht <- has_bit 7 0x01;
+  c.client_cache_extension <- has_bit 7 0x02;
+  c.client_fast_extension <- has_bit 7 0x04;
+
+  c.client_utorrent_extension <- has_bit 5 0x10;
+
+  c.client_azureus_messaging_protocol <- has_bit 0 0x80
+
 
 (** This function is called to parse the first message that
   a client send.
@@ -428,7 +439,7 @@
 (* removed: @param peer_id The hash (sha1) of the client. (Should be checked)
 *)
 let rec client_parse_header counter cc init_sent gconn sock
-    (proto, file_id) =
+    (proto, rbits, file_id) =
   try
     set_lifetime sock 600.;
     if !verbose_msg_clients then
@@ -482,6 +493,8 @@
             (Ip.to_string ip) port;
       end;
 
+    parse_reserved rbits c;
+
     (match c.client_sock with
         NoConnection ->
           if !verbose_msg_clients then begin

Index: src/networks/bittorrent/bTGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTGlobals.ml,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- src/networks/bittorrent/bTGlobals.ml        19 Sep 2006 17:07:43 -0000      
1.64
+++ src/networks/bittorrent/bTGlobals.ml        23 Sep 2006 20:29:47 -0000      
1.65
@@ -423,6 +423,11 @@
       | "TR" -> Brand_transmission
       | "HN" -> Brand_hydranode
       | "RT" -> Brand_retriever
+      | "PC" -> Brand_cachelogic
+      | "ES" -> Brand_electricsheep
+      | "qB" -> Brand_qbittorrent
+      | "QT" -> Brand_qt4
+      | "UL" -> Brand_uleecher
       | _ -> Brand_unknown
     in
     if brand = Brand_unknown then None else
@@ -454,6 +459,7 @@
      | "A" -> Brand_abc
      | "U" -> Brand_upnp
      | "O" -> Brand_osprey
+     | "R" -> Brand_tribler
      | _ -> Brand_unknown
     in
     let bv = ref None in
@@ -757,6 +763,11 @@
           client_incoming = false;
           client_registered_bitfield = false;
           client_last_optimist = 0;
+          client_dht = false;
+          client_cache_extension = false;
+          client_fast_extension = false;
+          client_utorrent_extension = false;
+          client_azureus_messaging_protocol = false;
         } and impl = {
           dummy_client_impl with
           impl_client_val = c;

Index: src/networks/bittorrent/bTInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTInteractive.ml,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- src/networks/bittorrent/bTInteractive.ml    19 Sep 2006 17:07:43 -0000      
1.109
+++ src/networks/bittorrent/bTInteractive.ml    23 Sep 2006 20:29:47 -0000      
1.110
@@ -127,8 +127,6 @@
 
 let op_file_print_html file buf =
 
-  html_mods_cntr_init ();
-
   Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr 
());
   html_mods_td buf [
     ("Filename", "sr br", "Filename");
@@ -262,24 +260,42 @@
          end in
   print_first_tracker file.file_trackers;
 
+  (* This is bad.  Magic info should be automatically filled in when 
+     the corresponding chunks complete. (see CommonSwarming)
+
+     This code only fills in the magic info for subfiles when a user 
+     manually performs a "vd #".  (interfaces out of sync)
+  
+     Magic info for shared files with subfiles is missing as well?
+  *)
+  if !Autoconf.magic_works then begin
   let check_magic file =
     match Magic.M.magic_fileinfo file false with
       None -> None
-    | Some s -> Some (HashMagic.merge CommonGlobals.files_magic s)
+    | Some s -> Some (intern s)
   in
+    let fdn = file_disk_name file in
+    let new_file_files = ref [] in
+  
+    List.iter (fun (f, s, m) -> 
+      let subfile = Filename.concat fdn f in
+      new_file_files := (f,s, check_magic subfile) :: !new_file_files;
+    ) file.file_files;
+
+    file.file_files <- List.rev !new_file_files;
+    file_must_update file; (* Send update to guis *)
+
+  end;
+  (* -- End bad -- *)
+
   let cntr = ref 0 in
-  List.iter (fun (filename, size, _) ->
+  List.iter (fun (filename, size, magic) ->
     Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr 
());
     let fs = Printf.sprintf "File %d" !cntr in
     let magic_string =
-      if !Autoconf.magic_works then
-       begin
-          let subfile = Filename.concat (file_disk_name file) filename in
-          match check_magic subfile with
+      match magic with 
             None -> ""
-          | Some magic -> Printf.sprintf " / %s" magic
-       end
-      else ""
+      | Some m -> Printf.sprintf " / %s" m;
     in
     html_mods_td buf [
       (fs, "sr br", fs);
@@ -316,6 +332,11 @@
         ( "0", "srh ar", "Last optimist", "L.Opt" );
         ( "0", "srh br ar", "Num try", "N" );
 
+        ( "0", "srh", "DHT [T]rue, [F]alse", "D" );
+        ( "0", "srh", "Cache extensions [T]rue, [F]alse", "C" );
+        ( "0", "srh", "Fast extensions [T]rue, [F]alse", "F" );
+        ( "0", "srh", "uTorrent extensions [T]rue, [F]alse", "U" );
+        ( "0", "srh br", "Azureus messaging protocol [T]rue, [F]alse", "A" );
 (*
         ( "0", "srh", "Bitmap (absent|partial|present|verified)", 
(colored_chunks
         (Array.init (String.length info.G.file_chunks)
@@ -336,6 +357,7 @@
       Hashtbl.iter (fun _ c ->
           Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr());
 
+          let btos b = if b then "T" else "F" in
           let cc,cn = Geoip.get_country (fst c.client_host) in
           let td_list = [
             ("", "sr br ar", Printf.sprintf "%d" (client_num c));
@@ -346,25 +368,31 @@
             ] @ (if !Geoip.active then [( cn, "sr br", cc)] else []) @ [
             ("", "sr ar", (size_of_int64 c.client_uploaded));
             ("", "sr ar br", (size_of_int64 c.client_downloaded));
-            ("", "sr", (if c.client_interested then "T" else "F"));
-            ("", "sr", (if c.client_choked then "T" else "F"));
+            ("", "sr", (btos c.client_interested));
+            ("", "sr", (btos c.client_choked));
             ("", "sr br ar", (Int64.to_string c.client_allowed_to_write));
 (* This is way too slow for 1000's of chunks on a page with 100's of sources
     ("", "sr", (CommonFile.colored_chunks (Array.init (String.length 
c.client_bitmap)
        (fun i -> (if c.client_bitmap.[i] = '1' then 2 else 0)) )) );
 *)
-            ("", "sr", (if c.client_interesting then "T" else "F"));
-            ("", "sr", (if c.client_alrd_sent_interested then "T" else "F"));
-            ("", "br sr", (if c.client_alrd_sent_notinterested then "T" else 
"F"));
-
-            ("", "sr", (if c.client_good then "T" else "F"));
-            ("", "sr", (if c.client_incoming then "T" else "F"));
-            ("", "br sr", (if c.client_registered_bitfield then "T" else "F"));
+            ("", "sr", (btos c.client_interesting));
+            ("", "sr", (btos c.client_alrd_sent_interested));
+            ("", "br sr", (btos c.client_alrd_sent_notinterested));
+
+            ("", "sr", (btos c.client_good));
+            ("", "sr", (btos c.client_incoming));
+            ("", "br sr", (btos c.client_registered_bitfield));
 
             ("", "sr", Printf.sprintf "%d" c.client_optimist_time);
             ("", "ar sr", string_of_date c.client_last_optimist);
             ("", "br sr", Printf.sprintf "%d" c.client_num_try);
 
+            ("", "sr", (btos c.client_dht)); 
+            ("", "sr", (btos c.client_cache_extension)); 
+            ("", "sr", (btos c.client_fast_extension)); 
+            ("", "sr", (btos c.client_utorrent_extension)); 
+            ("", "br sr", (btos c.client_azureus_messaging_protocol)); 
+
             ("", "sr ar", (let fc = ref 0 in
                 (match c.client_bitmap with
                     None -> ()
@@ -434,6 +462,7 @@
     P.file_sub_files = file.file_files;
     P.file_active_sources = List.length (op_file_active_sources file);
     P.file_all_sources = (Hashtbl.length file.file_clients);
+    P.file_comment = file.file_comment;
   }
 
 let op_ft_info ft =
@@ -443,7 +472,7 @@
   {
     P.file_fields = P.Fields_file_info.all;
 
-    P.file_comment = "";
+    P.file_comment = file_comment (as_ft ft);
     P.file_name = ft.ft_filename;
     P.file_num = ft_num ft;
     P.file_network = network.network_num;
@@ -465,6 +494,10 @@
     P.file_priority = 0;
     P.file_uids = [];
     P.file_sub_files = [];
+    P.file_magic = None;
+    P.file_comments = [];
+    P.file_user = "";
+    P.file_group = "";
   }
 
 

Index: src/networks/bittorrent/bTProtocol.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTProtocol.ml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- src/networks/bittorrent/bTProtocol.ml       15 Dec 2005 19:41:46 -0000      
1.25
+++ src/networks/bittorrent/bTProtocol.ml       23 Sep 2006 20:29:47 -0000      
1.26
@@ -233,7 +233,7 @@
 
 type ghandler =
   BTHeader of (gconn -> TcpBufferedSocket.t ->
-  (string * Sha1.t) -> unit)
+  (string * string * Sha1.t) -> unit)
 | Reader of (gconn -> TcpBufferedSocket.t -> unit)
 
 and gconn = {
@@ -538,8 +538,9 @@
               let file_id = Sha1.direct_of_string
                 (String.sub b.buf (b.pos+9+slen) 20) in
               let proto,pos = get_string8 b.buf b.pos in
+              let rbits = (String.sub b.buf (b.pos+pos) 8) in
               buf_used b (slen+29);
-              h gconn sock (proto, file_id);
+              h gconn sock (proto, rbits, file_id);
             end
           else if (TcpBufferedSocket.closed sock) then
               let (ip,port) = (TcpBufferedSocket.peer_addr sock) in

Index: src/networks/bittorrent/bTStats.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTStats.ml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- src/networks/bittorrent/bTStats.ml  26 Jan 2006 10:34:53 -0000      1.7
+++ src/networks/bittorrent/bTStats.ml  23 Sep 2006 20:29:47 -0000      1.8
@@ -93,6 +93,14 @@
 let _ =
   network.op_network_display_stats <- (fun buf o -> print_stats o New);
 
+  network.op_network_stat_info_list <- (fun _ ->
+    let l1 = stats_list brand_list stats_array in
+    let l2 = stats_list brand_list !!gstats_array in
+    let u1 = BasicSocket.last_time () - BasicSocket.start_time in
+    let u2 = (guptime() + u1) in
+    [("Session clients", u1, l1); ("Global clients", u2, l2)]
+  );
+
   register_commands
     [
     "client_stats_bt", "Network/Bittorrent",Arg_none (fun o ->

Index: src/networks/bittorrent/bTTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTTypes.ml,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- src/networks/bittorrent/bTTypes.ml  12 Sep 2006 22:44:52 -0000      1.36
+++ src/networks/bittorrent/bTTypes.ml  23 Sep 2006 20:29:47 -0000      1.37
@@ -104,6 +104,14 @@
 | Brand_retriever
 | Brand_osprey
 | Brand_rufus
+| Brand_tribler
+| Brand_cachelogic
+| Brand_electricsheep
+| Brand_qbittorrent
+| Brand_qt4
+| Brand_uleecher
+
+
 
 let brand_list = [ 
    ( Brand_unknown          , "unknown"                , "unk" ) ;
@@ -163,6 +171,12 @@
    ( Brand_retriever        , "Retriever"              , "ret" ) ;
    ( Brand_osprey           , "Osprey permaseed"       , "osp" ) ;
    ( Brand_rufus            , "Rufus"                  , "ruf" ) ;
+   ( Brand_tribler          , "Tribler"                , "trb" ) ;
+   ( Brand_cachelogic       , "CacheLogic"             , "cl"  ) ;
+   ( Brand_electricsheep    , "Electric sheep"         , "els" ) ;
+   ( Brand_qbittorrent      , "qBittorrent"            , "qbt" ) ;
+   ( Brand_qt4              , "QT4"                    , "qt4" ) ;
+   ( Brand_uleecher         , "uLeecher!"              , "ul!" ) ;
   ] 
 
 let brand_count = List.length brand_list
@@ -218,6 +232,13 @@
     mutable client_incoming : bool;
     mutable client_registered_bitfield : bool;
     mutable client_last_optimist : int;
+
+    mutable client_dht : bool;
+    mutable client_cache_extension : bool;
+    mutable client_fast_extension : bool;
+    mutable client_utorrent_extension : bool;
+    mutable client_azureus_messaging_protocol : bool;
+
   }
 
 and tracker_info = {

Index: src/networks/donkey/donkeyClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- src/networks/donkey/donkeyClient.ml 5 Sep 2006 14:18:24 -0000       1.99
+++ src/networks/donkey/donkeyClient.ml 23 Sep 2006 20:29:47 -0000      1.100
@@ -1272,9 +1272,6 @@
               (Printexc2.to_string e); 
       end;
 
-  | M.EmuleFileDescReq (rate, comment) ->
-      if comment <> "" then set_file_comment c.client_last_asked_file comment
-  
   | M.AvailableSlotReq _ ->
       set_lifetime sock active_lifetime;
       set_rtimeout sock !!queued_timeout; 
@@ -1424,6 +1421,28 @@
         with _ -> ()
       end  
   
+  | M.EmuleFileDescReq t ->
+      begin
+        match c.client_last_file_req_md4 with
+          Some md4 -> 
+            begin
+              try 
+                let file = find_file md4 in
+                let module Q = M.EmuleFileDesc in
+                let slen = String.length t.Q.comment in
+                if slen > 0 && slen <= !!max_comment_length && 
(!is_not_comment_spam) t.Q.comment then begin
+                  (* Disallow dups from single IP, but allow comment updates *)
+                  file.file_comments <- List.filter (fun (i,_,_,_) -> i <> 
c.client_ip) file.file_comments;
+                  if List.length file.file_comments < !!max_comments_per_file 
then begin
+                    file.file_comments <- (c.client_ip, c.client_name, 
t.Q.rating, (intern t.Q.comment)) :: file.file_comments;
+                    file_must_update file;
+                  end;
+                end
+              with _ -> ()
+            end
+         | None -> ()
+      end
+
   | M.QueryChunksReplyReq t ->
       let module Q = M.QueryChunksReply in
       begin
@@ -2510,7 +2529,6 @@
       try
         let c = find_client_by_key s_uid in
         let file = find_file (Md4.of_string file_uid) in
-       c.client_last_asked_file <- (as_file file);
         c.client_requests_sent <- c.client_requests_sent + 1;
         let module M = DonkeyProtoClient in
         
@@ -2538,6 +2556,7 @@
 (* TODO build the extension if needed *)
             M.QueryFile.emule_extension = emule_extension;
           });
+          c.client_last_file_req_md4 <- Some file.file_md4;
             let know_file_chunks = List.exists (fun (f,_,_) -> f == file) 
c.client_file_queue in
             if not know_file_chunks then
               DonkeyProtoCom.client_send c (

Index: src/networks/donkey/donkeyGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyGlobals.ml,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -b -r1.97 -r1.98
--- src/networks/donkey/donkeyGlobals.ml        19 Sep 2006 17:07:43 -0000      
1.97
+++ src/networks/donkey/donkeyGlobals.ml        23 Sep 2006 20:29:47 -0000      
1.98
@@ -398,7 +398,8 @@
           file_computed_md4s = Array.of_list md4s;
           file_format = FormatNotComputed 0;
           file_sources = DonkeySources.create_file_sources_manager
-            (Md4.to_string md4)
+            (Md4.to_string md4);
+          file_comments = [];
         }
       and file_impl = {
           dummy_file_impl with
@@ -567,7 +568,6 @@
       client_file_queue = [];
       client_tags = [];
       client_name = "";
-      client_last_asked_file = dummy_file;
       client_all_files = None;
       client_rating = 0;
       client_brand = Brand_unknown;
@@ -594,6 +594,7 @@
       client_sent_challenge = Int64.zero;
       client_public_key = None;
       client_sui_verified = None;
+      client_last_file_req_md4 = None;
       } and
     client_impl = {
       dummy_client_impl with
@@ -618,7 +619,6 @@
       client_file_queue = [];
       client_tags = [];
       client_name = "";
-      client_last_asked_file = dummy_file;
       client_all_files = None;
       client_rating = 0;
       client_brand = Brand_unknown;
@@ -645,6 +645,7 @@
       client_sent_challenge = Int64.zero;
       client_public_key = None;
       client_sui_verified = None;
+      client_last_file_req_md4 = None;
       } and    client_impl = {
       dummy_client_impl with
       impl_client_val = c;

Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -b -r1.124 -r1.125
--- src/networks/donkey/donkeyInteractive.ml    19 Sep 2006 18:45:53 -0000      
1.124
+++ src/networks/donkey/donkeyInteractive.ml    23 Sep 2006 20:29:47 -0000      
1.125
@@ -1046,6 +1046,7 @@
             P.file_format = file.file_format;
             P.file_chunks_age = last_seen;
             P.file_uids = [Uid.create (Ed2k file.file_md4)];
+            P.file_comments = file.file_comments
           } in
         v
       with e ->
@@ -1214,8 +1215,6 @@
   );
   file_ops.op_file_print_html <- (fun file buf ->
 
-     html_mods_cntr_init ();
-
      let tr () =
       Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" 
(html_mods_cntr ())
      in
@@ -1227,6 +1226,16 @@
             (Md4.to_string file.file_md4) (Md4.to_string file.file_md4)
         ) ];
 
+      let cntr = ref 0 in
+      List.iter (fun (ip, n, r, c) -> 
+        tr ();
+        html_mods_td buf [
+          ("Comment", "sr br", Printf.sprintf "Comment %d" !cntr);
+          ("User rating and comment", "sr", Printf.sprintf "Rating(%d): %s 
(%s/%s)" r c n (Ip.to_string ip));
+        ];
+        incr cntr;
+      ) file.file_comments;
+
       tr ();
       html_mods_td buf [
         ("File History Links", "sr br", "File History");
@@ -1261,13 +1270,15 @@
 //--\\>
 \\</script\\>" (file_num file)
 
-   ^ "\\<table border=0 cellspacing=0 cellpadding=0\\>\\<tr\\>\\<td\\>"
+   ^ "\\<table border=0 cellspacing=0 cellpadding=0\\>\\<tr\\>"
    ^ "\\<form name=\\\"renameForm1\\\" id=\\\"renameForm1\\\" 
action=\\\"javascript:submitRenameForm(1);\\\"\\>"
+   ^ "\\<td\\>"
    ^ "\\<select name=\\\"newName\\\" id=\\\"newName\\\" 
onchange=\\\"javascript:renameForm2.newName.value=renameForm1.newName.options[renameForm1.newName.selectedIndex].value;this.form.submit();\\\"\\>"
    ^ Printf.sprintf "\\<option value=\\\"%s\\\" selected\\>%s\n" 
(file_best_name file) (file_best_name file)
    ^ !optionlist
-   ^ "\\</select\\>\\</td\\>\\</tr\\>\\</form\\>\\<tr\\>\\<td\\>\\<form 
name=\\\"renameForm2\\\" id=\\\"renameForm2\\\" 
action=\\\"javascript:submitRenameForm(2);\\\"\\>"
-   ^ "\\<input name=\\\"newName\\\" type=text size=" ^ input_size ^ " 
value=\\\"" ^ (file_best_name file) ^ 
"\\\"\\>\\</input\\>\\</td\\>\\</tr\\>\\</form\\>\\</table\\>"
+   ^ "\\</select\\>\\</td\\>\\</form\\>\\</tr\\>\\<tr\\>\\<form 
name=\\\"renameForm2\\\" id=\\\"renameForm2\\\" 
action=\\\"javascript:submitRenameForm(2);\\\"\\>"
+   ^ "\\<td\\>"
+   ^ "\\<input name=\\\"newName\\\" type=text size=" ^ input_size ^ " 
value=\\\"" ^ (file_best_name file) ^ 
"\\\"\\>\\</input\\>\\</td\\>\\</form\\>\\</tr\\>\\</table\\>"
     ) ];
 
 

Index: src/networks/donkey/donkeyProtoClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoClient.ml,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- src/networks/donkey/donkeyProtoClient.ml    5 Sep 2006 14:18:24 -0000       
1.36
+++ src/networks/donkey/donkeyProtoClient.ml    23 Sep 2006 20:29:47 -0000      
1.37
@@ -1044,6 +1044,29 @@
       done
 
   end
+module EmuleFileDesc = struct
+
+    type t = {
+        rating : int;
+        comment : string;
+      }
+
+    let parse len s =
+      let rating = get_uint8 s 1 in
+      let (comment, _) = get_string32 s 2 in
+      {
+        rating = rating;
+        comment = comment;
+      }
+
+    let print t =
+      lprintf_nl "EmuleFileDesc [%d][%s]" t.rating t.comment
+
+    let write buf t =
+      buf_int8 buf t.rating;
+      buf_string buf t.comment
+  end
+
 
 type t =
 | ConnectReq of Connect.t
@@ -1081,7 +1104,7 @@
 | EmuleQueueRankingReq of EmuleQueueRanking.t
 | EmuleRequestSourcesReq of EmuleRequestSources.t
 | EmuleRequestSourcesReplyReq of EmuleRequestSourcesReply.t
-| EmuleFileDescReq of int * string
+| EmuleFileDescReq of EmuleFileDesc.t 
 | EmulePublicKeyReq of EmulePublicKeyReq.t
 | EmuleSignatureReq of EmuleSignatureReq.t
 | EmuleSecIdentStateReq  of EmuleSecIdentStateReq.t
@@ -1133,8 +1156,8 @@
     | EmuleRequestSourcesReplyReq t ->
         EmuleRequestSourcesReply.print t
 
-    | EmuleFileDescReq (rating, comment) ->
-        lprintf "EMULE FILE DESC %s" comment
+    | EmuleFileDescReq t ->
+        EmuleFileDesc.print t
 
     | EmuleMultiPacketReq (md4, list) ->
         lprintf_nl "EmuleMultiPacket for %s:" (Md4.to_string md4);
@@ -1195,10 +1218,7 @@
 
     | 0x60 (* 96 *) -> EmuleQueueRankingReq (EmuleQueueRanking.parse len s)
 
-    | 0x61 (* 97 *) ->
-        let rating = get_uint8 s 1 in
-        let (comment,_) = get_string32 s 2 in
-        EmuleFileDescReq (rating, comment)
+    | 0x61 (* 97 *) -> EmuleFileDescReq (EmuleFileDesc.parse len s)
 
     | 0x81 (* 129 *) -> EmuleRequestSourcesReq (EmuleRequestSources.parse len 
s)
     | 0x82 (* 130 *) ->
@@ -1514,11 +1534,9 @@
     | EmuleRequestSourcesReplyReq t ->
         buf_int8 buf 0x82;
         EmuleRequestSourcesReply.write emule buf t
-    | EmuleFileDescReq (rating, comment) ->
+    | EmuleFileDescReq t ->
         buf_int8 buf 0x61;
-        buf_int8 buf rating;
-        buf_string buf comment
-
+        EmuleFileDesc.write buf t
     | EmuleCompressedPart (md4, statpos, newsize, bloc) ->
         buf_int8 buf 0x40;
         buf_md4 buf md4;

Index: src/networks/donkey/donkeyShare.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyShare.ml,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- src/networks/donkey/donkeyShare.ml  19 Sep 2006 17:07:43 -0000      1.51
+++ src/networks/donkey/donkeyShare.ml  23 Sep 2006 20:29:47 -0000      1.52
@@ -50,7 +50,7 @@
       let magic =
         match Magic.M.magic_fileinfo full_name false with
           None -> None
-        | Some magic -> Some (HashMagic.merge files_magic magic)
+        | Some magic -> Some (intern magic)
       in
 
       let impl = {
@@ -307,7 +307,7 @@
         let magic =
           match Magic.M.magic_fileinfo fullname false with
             None -> None
-          | Some magic -> Some (HashMagic.merge files_magic magic)
+          | Some magic -> Some (intern magic)
         in
 
           let rec impl = {

Index: src/networks/donkey/donkeyStats.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyStats.ml,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- src/networks/donkey/donkeyStats.ml  26 Jan 2006 10:34:53 -0000      1.24
+++ src/networks/donkey/donkeyStats.ml  23 Sep 2006 20:29:47 -0000      1.25
@@ -170,6 +170,21 @@
 let _ =
   network.op_network_display_stats <- (fun buf o -> print_stats o New false);
 
+  network.op_network_stat_info_list <- (fun _ ->
+    let r = ref [] in
+    let l1 = stats_list brand_list stats_array in
+    let l2 = stats_list brand_list !!gstats_array in
+    let u1 = BasicSocket.last_time () - !start_session in
+    let u2 = (guptime() + u1) in
+    r := [("Session clients", u1, l1); ("Global clients", u2, l2)];
+    if !!emule_mods_count then begin
+      let l3 = stats_list brand_mod_list stats_mod_array in
+      let l4 = stats_list brand_mod_list !!gstats_mod_array in
+      r := !r @ [ ("Session mods", u1, l3); ("Global mods", u2, l4)]
+    end;
+    !r
+  );
+
   register_commands
     [
     "client_stats", "Network/Donkey",Arg_none (fun o ->

Index: src/networks/donkey/donkeyTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyTypes.ml,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- src/networks/donkey/donkeyTypes.ml  5 Sep 2006 14:18:24 -0000       1.47
+++ src/networks/donkey/donkeyTypes.ml  23 Sep 2006 20:29:47 -0000      1.48
@@ -519,7 +519,6 @@
       CommonSwarming.uploader
       ) list;
     mutable client_all_files : result list option;
-    mutable client_last_asked_file : CommonTypes.file;
     mutable client_tags: CommonTypes.tag list;
     mutable client_name : string;
     mutable client_rating : int ;
@@ -549,6 +548,7 @@
     mutable client_req_challenge : Int64.t;
     mutable client_public_key : string option;
     mutable client_sui_verified : bool option;
+    mutable client_last_file_req_md4 : Md4.t option;
   }
 
 and compressed_parts = {
@@ -590,6 +590,7 @@
     mutable file_format : format;
     mutable file_shared : file CommonShared.shared_impl option;
     mutable file_sources : DonkeySources.file_sources_manager;
+    mutable file_comments : (Ip.t * string * int * string) list;
   }
 
 and file_to_share = {




reply via email to

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