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 |
[ |
[ |
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" |
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 |
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 _ = |