diff --git a/_oasis b/_oasis index 72df557..188bdec 100644 --- a/_oasis +++ b/_oasis @@ -17,15 +17,6 @@ Library bt Client, Rate, Addr, Tcp, Log, Udp, Wire BuildDepends: lwt, uri, cohttp, cohttp.lwt, lwt.unix, cryptokit, zarith, qcheck, bitstring, bitstring.syntax - -Executable find_ih - Path: examples - MainIs: find_ih.ml - Build$: false - Custom: true - CompiledObject: best - Install: false - BuildDepends: bt.dht Executable otorrent Path: otorrent diff --git a/_tags b/_tags index 0d78fe6..f0a565f 100644 --- a/_tags +++ b/_tags @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: d5079b5b311f66616c0a23f593b277e2) +# DO NOT EDIT (digest: f179b6d24145f7173ee7f547efe74cf8) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -43,10 +43,6 @@ : pkg_qcheck : pkg_uri : pkg_zarith -# Executable find_ih -: pkg_bt.dht -: pkg_bt.dht -: custom # Executable otorrent : pkg_bitstring : pkg_bitstring.syntax diff --git a/bt/addr.ml b/bt/addr.ml index 301fd17..df066e0 100644 --- a/bt/addr.ml +++ b/bt/addr.ml @@ -57,7 +57,7 @@ let port (_, p) = p let ip (ip, _) = ip -let to_string (ip, p) = Printf.sprintf "%s:%d" (Unix.string_of_inet_addr ip) p +let to_string (ip, p) = Printf.sprintf "[%s]:%d" (Unix.string_of_inet_addr ip) p let to_string_compact (ip, p) = let (a, b, c, d) = Ip.to_ints ip in diff --git a/bt/client.ml b/bt/client.ml index 0d6fb41..bb3f8d1 100644 --- a/bt/client.ml +++ b/bt/client.ml @@ -405,7 +405,9 @@ let handle_peer_event bt p = function | Peer.BlockReceived (idx, off, s) -> begin match bt.stage with | Leeching (meta, t) -> - Log.success "received block (idx=%d,off=%d,len=%d)" idx off (String.length s); + Log.success "received block (idx=%d,off=%d,len=%d) from %s (%s/s)" + idx off (String.length s) (Addr.to_string (Peer.addr p)) + (Util.string_of_file_size (Int64.of_float (Peer.download_rate p))); let aux () = Torrent.got_block t idx off s >|= function | `Verified -> @@ -494,7 +496,7 @@ let handle_event bt = function let wakeup_peer _ p = Peer.send_have_bitfield p bits; if Torrent.got_bitfield t (Peer.have p) then begin - Log.success "we should be interested in %s" (Addr.to_string (Peer.addr p)); + (* Log.success "we should be interested in %s" (Addr.to_string (Peer.addr p)); *) Peer.send_interested p; if not (Peer.peer_choking p) then for i = 1 to max_requests do request_block bt p done diff --git a/bt/log.ml b/bt/log.ml index f18dd75..25520d7 100644 --- a/bt/log.ml +++ b/bt/log.ml @@ -12,7 +12,7 @@ type level = | ERROR | FATAL -let current_level = ref INFO +let current_level = ref FATAL type color = | NONE diff --git a/otorrent/otorrent.ml b/otorrent/otorrent.ml index 43ee74a..75e0e31 100644 --- a/otorrent/otorrent.ml +++ b/otorrent/otorrent.ml @@ -1,5 +1,9 @@ open Cmdliner +let debug = + let doc = "Enable debug output (note: this generates a LOT of output)" in + Arg.(value & flag & info ["d"; "debug"] ~doc) + let magnets = let doc = "Magnet link of the torrent(s) to download" in Arg.(value & pos_all string [] & info [] ~docv:"MAGNET" ~doc) @@ -10,8 +14,12 @@ let download magnet = (fun () -> Bt.Client.start bt) (fun e -> Bt.Log.error ~exn:e "fatal error during download"; Lwt.return ()) +let download_all debug magnets = + if debug then Bt.Log.current_level := Bt.Log.INFO; + Lwt_main.run (Lwt_list.iter_p download magnets) + let download_t = - Term.(pure (fun xs -> Lwt_main.run (Lwt_list.iter_p download xs)) $ magnets) + Term.(pure download_all $ debug $ magnets) let info = let doc = "download torrent(s)" in diff --git a/setup.ml b/setup.ml index c36d4ea..065c916 100644 --- a/setup.ml +++ b/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.4.2 *) (* OASIS_START *) -(* DO NOT EDIT (digest: f1c2e98c760f780566416986e823c6d7) *) +(* DO NOT EDIT (digest: ce15de05ca1ee09a58b46b5aa509c4f2) *) (* Regenerated by OASIS v0.4.4 Visit http://oasis.forge.ocamlcore.org for more information and @@ -6753,33 +6753,6 @@ let setup_t = lib_findlib_name = Some "bt"; lib_findlib_containers = [] }); - Executable - ({ - cs_name = "find_ih"; - cs_data = PropList.Data.create (); - cs_plugin_data = [] - }, - { - bs_build = - [ - (OASISExpr.EBool true, false); - (OASISExpr.EBool false, true) - ]; - bs_install = [(OASISExpr.EBool true, false)]; - bs_path = "examples"; - bs_compiled_object = Best; - bs_build_depends = [FindlibPackage ("bt.dht", None)]; - bs_build_tools = [ExternalTool "ocamlbuild"]; - bs_c_sources = []; - bs_data_files = []; - bs_ccopt = [(OASISExpr.EBool true, [])]; - bs_cclib = [(OASISExpr.EBool true, [])]; - bs_dlllib = [(OASISExpr.EBool true, [])]; - bs_dllpath = [(OASISExpr.EBool true, [])]; - bs_byteopt = [(OASISExpr.EBool true, [])]; - bs_nativeopt = [(OASISExpr.EBool true, [])] - }, - {exec_custom = true; exec_main_is = "find_ih.ml"}); Executable ({ cs_name = "otorrent"; @@ -6816,7 +6789,7 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.4.4"; - oasis_digest = Some "\133aÝøkï(z/\1385·\130ÍDy"; + oasis_digest = Some "-´¤÷##\130@®ÂÚp&Uèz"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -6824,6 +6797,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 6828 "setup.ml" +# 6801 "setup.ml" (* OASIS_STOP *) let () = setup ();;