Skip to main content

dht_crawler/
protocol.rs

1use serde::Deserialize;
2
3#[derive(Deserialize, Debug)]
4#[allow(dead_code)]
5pub struct DhtMessage {
6    pub t: serde_bytes::ByteBuf,
7    #[allow(dead_code)]
8    pub y: String,
9    #[allow(dead_code)]
10    pub q: Option<String>,
11    pub a: Option<DhtArgs>,
12    pub r: Option<DhtResponse>,
13}
14
15#[derive(Deserialize, Debug)]
16pub struct DhtArgs {
17    pub id: Option<serde_bytes::ByteBuf>,
18    pub target: Option<serde_bytes::ByteBuf>,
19    pub info_hash: Option<serde_bytes::ByteBuf>,
20    pub token: Option<serde_bytes::ByteBuf>,
21    pub port: Option<u16>,
22    pub implied_port: Option<u8>,
23}
24
25#[derive(Deserialize, Debug)]
26pub struct DhtResponse {
27    #[serde(default)]
28    #[allow(dead_code)]
29    pub id: Option<serde_bytes::ByteBuf>,
30    #[serde(default)]
31    pub nodes: Option<serde_bytes::ByteBuf>,
32    #[serde(default)]
33    pub nodes6: Option<serde_bytes::ByteBuf>,
34}