From 34b220ec57497adf0adf34d0cce38276704e87b5 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 18 Mar 2022 17:45:01 +0100 Subject: [PATCH] torrent: parse private boolean --- cmd/btinfo/main.ha | 3 ++- torrent/torrent.ha | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/btinfo/main.ha b/cmd/btinfo/main.ha index f4116b3..876008e 100644 --- a/cmd/btinfo/main.ha +++ b/cmd/btinfo/main.ha @@ -59,7 +59,8 @@ fn dump(conf: *config, in: io::handle) void = { }; defer torrent::torrent_free(tor); - fmt::printfln("name: {}", tor.info.name)!; + fmt::printfln("name: {}{}", tor.info.name, + if (tor.info.private) " (private)" else "")!; fmt::printfln("announce: {}", tor.announce)!; match (tor.info.length) { diff --git a/torrent/torrent.ha b/torrent/torrent.ha index bd11a31..ab268ae 100644 --- a/torrent/torrent.ha +++ b/torrent/torrent.ha @@ -13,6 +13,7 @@ export type info = struct { name: str, piecelen: size, pieces: []u8, + private: bool, length: (size | void), files: []file, }; @@ -66,6 +67,8 @@ export fn read(in: io::handle) (*torrent | error) = { return invalid; }; t.info.pieces = alloc(pieces...); + case "private" => + t.info.private = getint(rec.1)? == 1; case "length" => t.info.length = getint(rec.1)?: size; case "files" => -- 2.45.2