validate info-hash argument

This commit is contained in:
yggverse 2025-08-07 13:55:32 +03:00
parent 00e8f8078b
commit 3e94c483d6
2 changed files with 4 additions and 1 deletions

View file

@ -20,7 +20,7 @@ pub fn magnet(info_hash: &str, trackers: Option<&Vec<url::Url>>) -> String {
let mut b = if info_hash.len() == 40 {
format!("magnet:?xt=urn:btih:{info_hash}")
} else {
todo!("info-hash v2 is not supported by librqbit")
todo!("info-hash v2 yet not supported")
};
if let Some(t) = trackers {
for tracker in t {

View file

@ -26,6 +26,9 @@ impl Scraper {
pub fn scrape(&self, info_hash: &[u8]) -> Option<Scrape> {
self.udp.as_ref()?;
if info_hash.len() != 40 {
todo!("info-hash v2 yet not supported")
}
let mut t = Scrape::default();
if let Some(ref u) = self.udp {
let r = u.scrape(info_hash).ok()?; // @TODO handle