mldonkey-commits
[Top][All Lists]
Advanced

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

[Mldonkey-commits] Changes to mldonkey/src/networks/bittorrent/bTInterac


From: mldonkey-commits
Subject: [Mldonkey-commits] Changes to mldonkey/src/networks/bittorrent/bTInteractive.ml
Date: Sun, 21 Aug 2005 08:27:20 -0400

Index: mldonkey/src/networks/bittorrent/bTInteractive.ml
diff -u mldonkey/src/networks/bittorrent/bTInteractive.ml:1.51 
mldonkey/src/networks/bittorrent/bTInteractive.ml:1.52
--- mldonkey/src/networks/bittorrent/bTInteractive.ml:1.51      Mon Aug 15 
20:28:50 2005
+++ mldonkey/src/networks/bittorrent/bTInteractive.ml   Sun Aug 21 12:27:18 2005
@@ -751,6 +751,25 @@
 let op_network_connected _ = true
 
 
+let get_default_tracker () = 
+  if !!BTTracker.default_tracker = "" then
+     Printf.sprintf "http://%s:%d/announce";
+      (Ip.to_string (CommonOptions.client_ip None))
+      !!BTTracker.tracker_port 
+   else
+     !!BTTracker.default_tracker
+
+let compute_torrent filename announce comment = 
+  let announce = if announce = "" then get_default_tracker () else announce in
+  if !verbose_torrent then lprintf_nl () "compute_torrent: [%s] [%s] [%s]"
+   filename announce comment;
+  let basename = Filename.basename filename in
+  let torrent = Filename.concat seeded_directory
+    (Printf.sprintf "%s.torrent" basename) in
+  let is_private = 0 in
+  BTTorrent.generate_torrent announce torrent comment (Int64.of_int 
is_private) filename;
+  try_share_file torrent
+
 let commands =
 
     [
@@ -763,21 +782,9 @@
           fname :: [comm] -> filename := fname; comment := comm
         | [fname] -> filename := fname
         | _ -> raise Not_found);
-        let announce = 
-          if !!BTTracker.default_tracker = "" then
-            Printf.sprintf "http://%s:%d/announce";
-              (Ip.to_string (CommonOptions.client_ip None))
-              !!BTTracker.tracker_port 
-          else
-            !!BTTracker.default_tracker
-        in
 
-        let basename = Filename.basename !filename in
-        let torrent = Filename.concat seeded_directory
-          (Printf.sprintf "%s.torrent" basename) in
-        let is_private = 0 in
-        BTTorrent.generate_torrent announce torrent !comment (Int64.of_int 
is_private) !filename;
-        try_share_file torrent;
+        compute_torrent !filename "" !comment;
+
         if o.conn_output = HTML then
           (* TODO: really htmlize it *)
           Printf.bprintf buf ".torrent file generated"
@@ -886,6 +893,7 @@
   ]
 
 open LittleEndian
+open GuiDecoding
 
 let op_gui_message s =
   match get_int16 s 0 with
@@ -894,6 +902,13 @@
       if !verbose_torrent then lprintf_nl () "received torrent from gui...";
       let _ = load_torrent_string text in
       ()
+  | 1 -> (* 34+ *)
+      let n = get_int s 2 in
+      let a, pos = get_string s 6 in
+      let c, pos = get_string s pos in
+      let sf = CommonShared.shared_find n in
+      let f = shared_fullname sf in
+      compute_torrent f a c;
   | opcode -> failwith (Printf.sprintf "[BT] Unknown message opcode %d" opcode)
 
 let _ =




reply via email to

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