In order to learn Rust, I plan to develop a bittorrent tracker. But I ran into a problem:
async fn announce(
RawQuery(rawquery): RawQuery,
Query(query_map): Query<BTreeMap<String, String>>,
) -> impl IntoResponse {
let rawquery = rawquery.unwrap();
dbg!(&rawquery, query_map);
"todo!"
}
I use qBittorrent to try to access this tracker:
&rawquery = "token=token&info_hash=%f9%98%fc%fa%a4%06%85a%08*********%f8%3b9%1f%fd%b5%bf%91&peer_id=-qB4540-Cm**********&port=39718&uploaded=0&downloaded=0&left=0&corrupt=0&key=42A5****&event=started&numwant=200&compact=1&no_peer_id=1&supportcrypto=1&redundant=0"
query_map = {
"compact": "1",
"corrupt": "0",
"downloaded": "0",
"event": "started",
"info_hash": "�����\u{6}�\u{8}�a۶�;\u{1f}���9�",
"key": "42A5****",
"left": "0",
"no_peer_id": "1",
"numwant": "200",
"peer_id": "-qB4540-Cm**********",
"port": "39718",
"redundant": "0",
"supportcrypto": "1",
"token": "token",
"uploaded": "0",
}
I know that info_hash
is the hexadecimal representation [u8; 20]
, but no better way to serialize/deserialize has been found.