Crates.io | tdyne-peer-id-registry |
lib.rs | tdyne-peer-id-registry |
version | 0.1.1 |
source | src |
created_at | 2023-10-07 22:07:08.089555 |
updated_at | 2023-10-07 22:08:16.473017 |
description | A library for parsing and (soon) encoding BitTorrent peer IDs. Tracks all known BitTorrent implementations and their peer ID formats. |
homepage | https://github.com/torrentdyne/tdyne-peer-id-registry |
repository | https://github.com/torrentdyne/tdyne-peer-id-registry |
max_upload_size | |
id | 996621 |
size | 103,494 |
By convention, BitTorrent clients identify themselves and their versions in peer IDs they send to trackers and other clients. Unfortunately, there is no single client/version encoding, so over time different clients adopted different conventions, which made parsing peer IDs difficult. This crate provides a comprehensive peer ID parser and a registry of all known BitTorrent clients.
Peer ID encoding is one of immediate goals, see "Roadmap" below for details.
This crate uses [tdyne_peer_id
] to encode peer IDs.
Example:
use tdyne_peer_id::PeerId;
use tdyne_peer_id_registry::parse;
let peer_id = PeerId::from(b"-TR404Z-*\x00\x01d7xkqq04n");
let parsed = parse(peer_id).expect("recognised peer ID");
assert_eq!(parsed.client, "Transmission");
let version = parsed.version
.expect("valid version encoding")
.expect("Transmission does encode a version in its peer ID");
assert_eq!(version, "4.0.4 (Dev)");
bittorrent-peerid
,
the most popular JS implementation of BitTorrent peer ID parsingbittorrent-peerid
by
recognising more clients and versionsA peer ID formatting API that only accepts known clients (in release mode) and takes choices out of peer ID formatting would help the ecosystem to stay more consistent.
Transmission has
an extensive peer ID parser.
Right now the Venn diagram of clients that tdyne_peer_id_registry
and Transmission
can handle is two intersecting circles. It needs to get closer to two concentric rings.
tdyne_peer_id_registry
is designed to parse into an allocation-free tree
of structs and enums. In the current version the tree is not exposed as it is not stable yet
and changing it would be a breaking change. Instead, the API immediately turns the tree
into strings, the lowest common denominator. However, exposing the tree directly
would help projects that need to act on the information from the peer ID,
as they would be able to work directly with the structures instead of re-parsing strings.