/[mldonkey]/mldonkey/src/networks/bittorrent/bTInteractive.ml
ViewVC logotype

Diff of /mldonkey/src/networks/bittorrent/bTInteractive.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.51 by spiralvoice, Mon Aug 15 20:28:50 2005 UTC revision 1.52 by spiralvoice, Sun Aug 21 12:27:18 2005 UTC
# Line 751  let op_client_dprint_html c o file str = Line 751  let op_client_dprint_html c o file str =
751  let op_network_connected _ = true  let op_network_connected _ = true
752    
753    
754    let get_default_tracker () =
755      if !!BTTracker.default_tracker = "" then
756         Printf.sprintf "http://%s:%d/announce"
757          (Ip.to_string (CommonOptions.client_ip None))
758          !!BTTracker.tracker_port
759       else
760         !!BTTracker.default_tracker
761    
762    let compute_torrent filename announce comment =
763      let announce = if announce = "" then get_default_tracker () else announce in
764      if !verbose_torrent then lprintf_nl () "compute_torrent: [%s] [%s] [%s]"
765       filename announce comment;
766      let basename = Filename.basename filename in
767      let torrent = Filename.concat seeded_directory
768        (Printf.sprintf "%s.torrent" basename) in
769      let is_private = 0 in
770      BTTorrent.generate_torrent announce torrent comment (Int64.of_int is_private) filename;
771      try_share_file torrent
772    
773  let commands =  let commands =
774    
775      [      [
# Line 763  let commands = Line 782  let commands =
782            fname :: [comm] -> filename := fname; comment := comm            fname :: [comm] -> filename := fname; comment := comm
783          | [fname] -> filename := fname          | [fname] -> filename := fname
784          | _ -> raise Not_found);          | _ -> 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  
785    
786          let basename = Filename.basename !filename in          compute_torrent !filename "" !comment;
787          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;  
788          if o.conn_output = HTML then          if o.conn_output = HTML then
789            (* TODO: really htmlize it *)            (* TODO: really htmlize it *)
790            Printf.bprintf buf ".torrent file generated"            Printf.bprintf buf ".torrent file generated"
# Line 886  let commands = Line 893  let commands =
893    ]    ]
894    
895  open LittleEndian  open LittleEndian
896    open GuiDecoding
897    
898  let op_gui_message s =  let op_gui_message s =
899    match get_int16 s 0 with    match get_int16 s 0 with
# Line 894  let op_gui_message s = Line 902  let op_gui_message s =
902        if !verbose_torrent then lprintf_nl () "received torrent from gui...";        if !verbose_torrent then lprintf_nl () "received torrent from gui...";
903        let _ = load_torrent_string text in        let _ = load_torrent_string text in
904        ()        ()
905      | 1 -> (* 34+ *)
906          let n = get_int s 2 in
907          let a, pos = get_string s 6 in
908          let c, pos = get_string s pos in
909          let sf = CommonShared.shared_find n in
910          let f = shared_fullname sf in
911          compute_torrent f a c;
912    | opcode -> failwith (Printf.sprintf "[BT] Unknown message opcode %d" opcode)    | opcode -> failwith (Printf.sprintf "[BT] Unknown message opcode %d" opcode)
913    
914  let _ =  let _ =

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26