tornado
tornado copied to clipboard
Support for OCaml 4.x
@fraidev Hi, could we make eio_main optional? If I get it right, the earliest version of it is 0.9: https://opam.ocaml.org/packages/eio_main/eio_main.0.9 – however the last version of eio itself to support OCaml 4.x is 0.3: https://opam.ocaml.org/packages/eio/eio.0.3
eio_main is a sub-package of eio, so it just won’t exist with 0.3.
Oh, it’s worse than I thought :( https://github.com/fraidev/tornado/commit/d896911dcfddec49aa3acf53e43c03c7744a2721 https://github.com/fraidev/tornado/commit/fa54742b38db9c4827a1b554c579ff40bd64ed02
If it was C++, I could have reverted those, but OCaml I won’t be able to handle.
It is probably worth explicitly stating the requirement of OCaml 5 (in README and/or dune/opam project files), may save someone several hours of dealing with dependencies just to find out it cannot build at all LOL
@fraidev The version from 5a0c67ba96bb8c85510692be2e2fd3f44c9689d6 builds, but does not appear to be usable:
% tornado_cli.exe --help
tornado [-verbose] <torrent_file> -o <output>
-verbose Output debug information
-o Set output file name
-help Display this list of options
--help Display this list of options
% tornado_cli.exe -verbose ${some_torrent}.torrent -o ${file_name}
Fatal error: exception Invalid_argument("option is None")
% tornado_cli.exe ${some_torrent}.torrent
Fatal error: exception Invalid_argument("option is None")
Hi @barracuda156, thanks for opening the issue! This repository is a bit deprecated, as I’m focusing more on https://github.com/fraidev/bitrev.
Is there a specific reason you need this repository?
Btw, I added a warning in the README saying it
@fraidev Bittorrent client in OCaml sounded interesting, I wanted to try it. Rust doesn’t work for my case (broken for the target platform), but after all there are options in C++/Python. OCaml 5 might work, just MacPorts doesn’t have it and I am reluctant to write the port myself (last time I tried there was some issue).
@fraidev If you could suggest what goes wrong with 8b484d20a5ab6ee55334920d78e3b41d65783f3a version, it would be nice. Given that I have already added ports for all dependencies, it is worth trying it out. (I do not ask to restore OCaml 4.x compat now, since the app is no longer actively maintained, and dealing with this would be a big effort.)
BTW, looks like FreeBSD also has OCaml 4 only at the moment: https://github.com/freebsd/freebsd-ports/blob/e51f0a609c606e82898679925bb7d761bd5e3fbc/lang/ocaml/Makefile#L4
@fraidev Oh wow, the error comes from Apple’s groff. Installing MacPorts’s one fixed that, however attempt to download a torrent still fails:
Sending request...
tornado_cli.exe: [DEBUG] TCP_NODELAY set
piaf.client: [DEBUG] Trying connection to jpopsuki.eu (65.21.170.150:7531)
piaf.client: [INFO] Connected to jpopsuki.eu (65.21.170.150:7531)
piaf.http: [INFO] Sending request:
GET /zp4ccmd8b30ajvfk2hbl28exr2t14i3i/announce?info_hash=%F1UX%189h%D8%E7%B2%7B%9F%D9%DA%0F%19NM%A9%86%92&peer_id=%C0%BA%8D%05%01%00%00%00%A0%BA%8D%05%01%00%00%00%00%00%00%00&port=6881&uploaded=0&downloaded=0&compact=1&left=880570148 HTTP/1.1
Host: jpopsuki.eu
content-length: 0
Error: Malformed Response: : char ' '
Fatal error: exception Invalid_argument("result is Error _")
Upd. Hmm, not really, groff screws up help with some OCaml packages, but I still get Fatal error: exception Invalid_argument("option is None") error with most of torrents. I tried a few, and only one went a bit further (as documented above), most fail immediately.
Some other random torrent file:
Sending request...
tornado_cli.exe: [DEBUG] TCP_NODELAY set
piaf.client: [DEBUG] Trying connection to sukebei.tracker.wf (195.16.73.66:8888)
piaf.client: [INFO] Connected to sukebei.tracker.wf (195.16.73.66:8888)
piaf.http: [INFO] Sending request:
GET /announce?info_hash=%E1%C4%E7t%BEb%AC%D4)%26%26%980%99X5M%E3%81%B6&peer_id=%5D%C2bl%00%00%00%00?%9B%9F7%00%00%00%00%00%00%00%00&port=6881&uploaded=0&downloaded=0&compact=1&left=10790580312 HTTP/1.1
Host: sukebei.tracker.wf
content-length: 0
piaf.http: [INFO] Received response:
HTTP/1.1 200 OK
Date: Wed, 15 Oct 2025 04:55:07 GMT
Content-Length: 110
piaf.client: [INFO] Tearing down HTTP connection to sukebei.tracker.wf (195.16.73.66:8888)
tornado_cli.exe: [DEBUG] Connecting to { Peers.ip = 101.3.108.17; port = 6881 }
bos: [EXEC:19839] ['uname' '-s']
bos: [EXEC:19843] ['security' 'find-certificate' '-a' '-p'
'/System/Library/Keychains/SystemRootCertificates.keychain']
bos: [EXEC:19847] ['security' 'find-certificate' '-a' '-p'
'/Library/Keychains/System.keychain']
ca-certs: [DEBUG] Ignoring undecodable trust anchor: serial exceeds 20 octets.
ca-certs: [WARNING] Ignored 1 trust anchors.
tornado_cli.exe: [ERROR] Error: ("Unix.Unix_error(Unix.ECONNREFUSED, \"connect\", \"\")")
Fatal error: exception File "lib/torrent.ml", line 229, characters 12-18: Assertion failed