tracker: add http tracker support

This commit is contained in:
2016-12-11 22:03:27 -05:00
parent 2e9503d2d7
commit 74e82a0127
7 changed files with 179 additions and 3 deletions

View File

@@ -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(())
}