mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http: add PeerMapKey with PeerID and Either<Ip, announce key>
This commit is contained in:
parent
73807baacb
commit
c50dec3496
3 changed files with 36 additions and 14 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue