{ "name": "rtorrent", "version": "0.16.25", "summary": "rTorrent: the BitTorrent client in a terminal or as a daemon, with XML-RPC and JSON-RPC over SCGI", "category": "network", "license": "GPL-2.0-or-later", "homepage": "https://github.com/rakshasa/rtorrent", "source": { "url": "https://github.com/rakshasa/rtorrent/releases/download/v0.16.25/rtorrent-0.16.25.tar.gz", "sha256": "d9c17e0fae59f0cb7533966f3ed778e9df701ad84d5dd50e9bae2aefe0f00a2a" }, "watch": {"kind": "github-release", "repo": "rakshasa/rtorrent", "tag_regex": "^v([0-9]+\\.[0-9]+\\.[0-9]+)$"}, "deps": [ "libtorrent", "ncurses", "curl", "openssl", "zlib" ], "env_packages": [], "static": true, "nss": true, "check": "t=$(mktemp -d) && mkdir \"$t/data\" \"$t/session\" && bin/rtorrent -h | has 'version 0.16.25' > /dev/null && printf '%s\\n' 'import hashlib, os, socket, sys, time, xmlrpc.client' 't = sys.argv[1]' 'sock = t + \"/rpc.sock\"' 'data = b\"\".join(b\"%06d bvs rtorrent\\n\" % i for i in range(20000))' 'open(t + \"/data/bvs.bin\", \"wb\").write(data)' 'pl = 32768' 'pieces = b\"\".join(hashlib.sha1(data[i:i + pl]).digest() for i in range(0, len(data), pl))' 'def be(o):' ' if isinstance(o, int):' ' return b\"i%de\" % o' ' if isinstance(o, bytes):' ' return b\"%d:%s\" % (len(o), o)' ' return b\"d\" + b\"\".join(be(k) + be(o[k]) for k in sorted(o)) + b\"e\"' 'info = {b\"name\": b\"bvs.bin\", b\"length\": len(data), b\"piece length\": pl, b\"pieces\": pieces}' 'open(t + \"/bvs.torrent\", \"wb\").write(be({b\"announce\": b\"http://127.0.0.1:9/announce\", b\"info\": info}))' 'ih = hashlib.sha1(be(info)).hexdigest().upper()' 'def call(m, *a):' ' body = xmlrpc.client.dumps(a, m).encode()' ' hdr = b\"CONTENT_LENGTH\\0%d\\0SCGI\\x001\\0\" % len(body)' ' s = socket.socket(socket.AF_UNIX)' ' s.connect(sock)' ' s.sendall(b\"%d:%s,\" % (len(hdr), hdr) + body)' ' r = b\"\"' ' while True:' ' c = s.recv(65536)' ' if not c:' ' break' ' r += c' ' s.close()' ' return xmlrpc.client.loads(r.split(b\"\\r\\n\\r\\n\", 1)[1])[0][0]' 'for _ in range(100):' ' if os.path.exists(sock):' ' break' ' time.sleep(0.1)' 'v = call(\"system.client_version\")' 'call(\"load.start_verbose\", \"\", t + \"/bvs.torrent\")' 'done = 0' 'for _ in range(100):' ' try:' ' done = call(\"d.complete\", ih)' ' except xmlrpc.client.Fault:' ' done = 0' ' if done == 1:' ' break' ' time.sleep(0.1)' 'print(\"rtorrent %s: %s %s complete=%d size=%d chunks=%d\" % (v, call(\"d.name\", ih), ih, done, call(\"d.size_bytes\", ih), call(\"d.size_chunks\", ih)))' 'try:' ' call(\"system.shutdown.normal\")' 'except Exception:' ' pass' > \"$t/rt.py\" && P=$(free_port) && { bin/rtorrent -n -o system.daemon.set=true -o \"session.path.set=$t/session\" -o \"directory.default.set=$t/data\" -o \"network.scgi.open_local=$t/rpc.sock\" -o \"network.listen.port.set=$P\" -o network.listen.port.random.set=no -o dht.mode.set=disable -o protocol.pex.set=no -o trackers.use_udp.set=no > \"$t/log\" 2>&1 & echo $! > \"$t/pid\"; } && timeout 60 python3 \"$t/rt.py\" \"$t\" > \"$t/out\" && has -x 'rtorrent 0.16.25: bvs.bin 0EF710DAE320975036DBBAD32B3FBEDA62F73CD9 complete=1 size=400000 chunks=13' < \"$t/out\" && echo \"rtorrent 0.16.25: a daemon on an SCGI socket (listen port $P) loads a torrent of 400000 bytes in 13 pieces over XML-RPC and finds the data complete by its hash check\"; r=$?; [ $r = 0 ] || cat \"$t/out\" \"$t/log\" >&2; [ -f \"$t/pid\" ] && kill \"$(cat \"$t/pid\")\" 2>/dev/null; rm -rf -- \"${t:?}\"; exit $r" }