Trait bip_handshake::HandshakeFilter
[−]
[src]
pub trait HandshakeFilter { fn as_any(&self) -> &Any; fn on_addr(&self, opt_addr: Option<&SocketAddr>) -> FilterDecision { ... } fn on_prot(&self, opt_prot: Option<&Protocol>) -> FilterDecision { ... } fn on_ext(&self, opt_ext: Option<&Extensions>) -> FilterDecision { ... } fn on_hash(&self, opt_hash: Option<&InfoHash>) -> FilterDecision { ... } fn on_pid(&self, opt_pid: Option<&PeerId>) -> FilterDecision { ... } }
Trait for filtering connections during handshaking.
By default, all methods will return FilterDecision::Pass
so that implementers filtering
on only a few fields only have to implement the methods for those fields. Option is passed
because some filters may be able to block peers before a connection is made, if data is
required, return FilterDecision::NeedData
when None
is passed.
In order for a handshake to pass the filter, each field has to be either not blocked, or
effectively "whitelisted" (see FilterDecision::Allow
).
Required Methods
Provided Methods
fn on_addr(&self, opt_addr: Option<&SocketAddr>) -> FilterDecision
Make a filter decision based on the peer SocketAddr
.
fn on_prot(&self, opt_prot: Option<&Protocol>) -> FilterDecision
Make a filter decision based on the handshake Protocol
.
fn on_ext(&self, opt_ext: Option<&Extensions>) -> FilterDecision
Make a filter decision based on the Extensions
.
fn on_hash(&self, opt_hash: Option<&InfoHash>) -> FilterDecision
Make a filter decision based on the InfoHash
.
fn on_pid(&self, opt_pid: Option<&PeerId>) -> FilterDecision
Make a filter decision based on the PeerId
.