mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 20:02:43 +00:00
Improved handling of IP Banning (#2530)
This PR in general improves the handling around peer banning. Specifically there were issues when multiple peers under a single IP connected to us after we banned the IP for poor behaviour. This PR should now handle these peers gracefully as well as make some improvements around how we previously disconnected and banned peers. The logic now goes as follows: - Once a peer gets banned, its gets registered with its known IP addresses - Once enough banned peers exist under a single IP that IP is banned - We retain connections with existing peers under this IP - Any new connections under this IP are rejected
This commit is contained in:
@@ -141,6 +141,9 @@ pub enum GoodbyeReason {
|
||||
/// The peer is banned
|
||||
Banned = 251,
|
||||
|
||||
/// The IP address the peer is using is banned.
|
||||
BannedIP = 252,
|
||||
|
||||
/// Unknown reason.
|
||||
Unknown = 0,
|
||||
}
|
||||
@@ -155,6 +158,7 @@ impl From<u64> for GoodbyeReason {
|
||||
129 => GoodbyeReason::TooManyPeers,
|
||||
250 => GoodbyeReason::BadScore,
|
||||
251 => GoodbyeReason::Banned,
|
||||
252 => GoodbyeReason::BannedIP,
|
||||
_ => GoodbyeReason::Unknown,
|
||||
}
|
||||
}
|
||||
@@ -396,6 +400,7 @@ impl std::fmt::Display for GoodbyeReason {
|
||||
GoodbyeReason::TooManyPeers => write!(f, "Too many peers"),
|
||||
GoodbyeReason::BadScore => write!(f, "Bad Score"),
|
||||
GoodbyeReason::Banned => write!(f, "Banned"),
|
||||
GoodbyeReason::BannedIP => write!(f, "BannedIP"),
|
||||
GoodbyeReason::Unknown => write!(f, "Unknown Reason"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user