proto: basic peer wire protocol that can download
This commit is contained in:
@@ -5,7 +5,7 @@ use hyper::Client;
|
||||
use url::form_urlencoded::byte_serialize;
|
||||
|
||||
use bencode::{decode, Dict};
|
||||
use torrent::Torrent;
|
||||
use metainfo::{Hash, Metainfo};
|
||||
use tracker::{Peer, TrackerError, TrackerResponse, TrackerResult};
|
||||
|
||||
macro_rules! ts {
|
||||
@@ -17,16 +17,16 @@ macro_rules! ts {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_peers(peer_id: [u8; 20], port: u16, torrent: &Torrent) -> TrackerResult {
|
||||
pub fn get_peers(peer_id: Hash, port: u16, metainfo: &Metainfo, uploaded: u64, downloaded: u64, left: u64) -> TrackerResult {
|
||||
let url = format!("{}?info_hash={}&peer_id={}&port={}&uploaded={}\
|
||||
&downloaded={}&left={}&compact=1",
|
||||
torrent.metainfo.announce,
|
||||
urlencode(&torrent.metainfo.info_hash),
|
||||
metainfo.announce,
|
||||
urlencode(&metainfo.info_hash),
|
||||
urlencode(&peer_id),
|
||||
port,
|
||||
torrent.uploaded,
|
||||
torrent.downloaded,
|
||||
torrent.left);
|
||||
uploaded,
|
||||
downloaded,
|
||||
left);
|
||||
|
||||
let client = Client::new();
|
||||
let mut resp = client.get(&url).send()?;
|
||||
|
||||
Reference in New Issue
Block a user