aquatic_http: add PeerMapKey with PeerID and Either<Ip, announce key>

This commit is contained in:
Joakim Frostegård 2020-07-04 12:00:36 +02:00
parent 73807baacb
commit c50dec3496
3 changed files with 36 additions and 14 deletions

View file

@ -15,6 +15,7 @@ pub struct AnnounceRequest {
pub compact: bool,
/// Number of response peers wanted
pub numwant: Option<usize>,
pub key: Option<String>,
}
@ -78,6 +79,15 @@ impl Request {
} else {
None
};
let key = if let Some(s) = data.get("key"){
if s.len() > 100 {
return Err(anyhow::anyhow!("'key' is too long"))
}
Some(s.clone())
} else {
None
};
let request = AnnounceRequest {
info_hash: info_hashes.get(0)
@ -103,6 +113,7 @@ impl Request {
.map(|s| s == "1")
.unwrap_or(true),
numwant,
key,
};
Ok(Request::Announce(request))