Struct bip_handshake::BTHandshaker [] [src]

pub struct BTHandshaker<T> where T: Send {
    // some fields omitted
}

Bittorrent TCP peer handshaker.

Methods

impl<T> BTHandshaker<T> where T: From<BTPeer> + Send + 'static
[src]

fn new<C>(chan: C, listen: SocketAddr, pid: PeerId) -> Result<BTHandshaker<T>> where C: Channel<T> + 'static

Create a new BTHandshaker with the given PeerId and bind address which will forward metadata and handshaken connections onto the provided channel.

fn with_protocol<C>(chan: C, listen: SocketAddr, pid: PeerId, protocol: &'static str) -> Result<BTHandshaker<T>> where C: Channel<T> + 'static

Similar to BTHandshaker::new() but allows a client to specify a custom protocol that the handshaker will specify during the handshake.

Panics if the length of the provided protocol exceeds 255 bytes.

fn register_hash(&self, hash: InfoHash)

Register interest for the given InfoHash allowing connections for the given InfoHash to succeed. Connections already in the handshaking process may not be effected by this call.

By default, a BTHandshaker will be interested in zero InfoHashs.

This is a blocking operation.

fn deregister_hash(&self, hash: InfoHash)

Deregister interest for the given InfoHash causing connections for the given InfoHash to fail. Connections already in the handshaking process may not be effected by this call.

By default, a BTHandshaker will be interested in zero InfoHashs.

This is a blocking operation.

Trait Implementations

impl<T> Clone for BTHandshaker<T> where T: Send
[src]

fn clone(&self) -> BTHandshaker<T>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<T> Handshaker for BTHandshaker<T> where T: Send
[src]

type MetadataEnvelope = T

Type that metadata will be passed back to the client as.

fn id(&self) -> PeerId

PeerId exposed to peer discovery services.

fn port(&self) -> u16

Port exposed to peer discovery services. Read more

fn connect(&mut self, expected: Option<PeerId>, hash: InfoHash, addr: SocketAddr)

Connect to the given address with the InfoHash and expecting the PeerId.

fn metadata(&mut self, data: Self::MetadataEnvelope)

Send the given Metadata back to the client.