tracker: add http tracker support
This commit is contained in:
@@ -7,6 +7,8 @@ use std::str;
|
||||
|
||||
use magnolia::bencode::*;
|
||||
use magnolia::metainfo::Metainfo;
|
||||
use magnolia::torrent::Torrent;
|
||||
use magnolia::tracker::http;
|
||||
|
||||
fn load_file(path: &str) -> io::Result<()> {
|
||||
let mut buf = Vec::new();
|
||||
@@ -14,8 +16,18 @@ fn load_file(path: &str) -> io::Result<()> {
|
||||
f.read_to_end(&mut buf)?;
|
||||
|
||||
let obj = decode(&buf).unwrap();
|
||||
let meta = Metainfo::from_bencode(obj);
|
||||
println!("{:#?}", meta);
|
||||
let meta = Metainfo::from_bencode(obj).unwrap();
|
||||
|
||||
let t = Torrent {
|
||||
metainfo: meta,
|
||||
uploaded: 0,
|
||||
downloaded: 0,
|
||||
left: 0,
|
||||
};
|
||||
|
||||
let resp = http::get_peers([1u8; 20], 55555, &t).unwrap();
|
||||
|
||||
print!("{:?}", resp);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user