|
@@ -299,7 +299,7 @@ impl Channel {
|
|
|
debug!(target: "net::channel::main_receive_loop()", "Stopping channel {:?}", self);
|
|
debug!(target: "net::channel::main_receive_loop()", "Stopping channel {:?}", self);
|
|
|
|
|
|
|
|
// We will reject further connections from this peer
|
|
// We will reject further connections from this peer
|
|
|
- self.p2p().hosts().mark_rejected(self.address()).await;
|
|
|
|
|
|
|
+ self.ban(self.address()).await;
|
|
|
|
|
|
|
|
return Err(Error::ChannelStopped)
|
|
return Err(Error::ChannelStopped)
|
|
|
}
|
|
}
|
|
@@ -308,6 +308,14 @@ impl Channel {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// Ban a malicious peer and stop the channel.
|
|
|
|
|
+ pub async fn ban(&self, peer: &Url) {
|
|
|
|
|
+ debug!(target: "net::channel::ban()", "START {:?}", self);
|
|
|
|
|
+ self.p2p().hosts().mark_rejected(peer).await;
|
|
|
|
|
+ self.stop().await;
|
|
|
|
|
+ debug!(target: "net::channel::ban()", "START {:?}", self);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// Returns the local socket address
|
|
/// Returns the local socket address
|
|
|
pub fn address(&self) -> &Url {
|
|
pub fn address(&self) -> &Url {
|
|
|
&self.info.addr
|
|
&self.info.addr
|