Report whether a peer was kept from Handler::on_connect

This commit is contained in:
Vurich
2017-06-30 10:58:48 +02:00
parent a3e693d5c3
commit 5eba9078fc
4 changed files with 117 additions and 26 deletions

View File

@@ -66,6 +66,8 @@ pub enum Error {
BadProtocolVersion,
/// Peer is overburdened.
Overburdened,
/// No handler kept the peer.
RejectedByHandlers,
}
impl Error {
@@ -85,6 +87,7 @@ impl Error {
Error::UnsupportedProtocolVersion(_) => Punishment::Disable,
Error::BadProtocolVersion => Punishment::Disable,
Error::Overburdened => Punishment::None,
Error::RejectedByHandlers => Punishment::Disconnect,
}
}
}
@@ -117,6 +120,7 @@ impl fmt::Display for Error {
Error::UnsupportedProtocolVersion(pv) => write!(f, "Unsupported protocol version: {}", pv),
Error::BadProtocolVersion => write!(f, "Bad protocol version in handshake"),
Error::Overburdened => write!(f, "Peer overburdened"),
Error::RejectedByHandlers => write!(f, "No handler kept this peer"),
}
}
}