Fixed banning process.

This commit is contained in:
Revertron
2021-04-19 23:36:08 +02:00
parent 068ff395f7
commit e0425f46dc
3 changed files with 10 additions and 3 deletions
-2
View File
@@ -635,10 +635,8 @@ impl Chain {
} }
pub fn update_max_height(&mut self, height: u64) { pub fn update_max_height(&mut self, height: u64) {
if height > self.max_height {
self.max_height = height; self.max_height = height;
} }
}
/// Check if this block can be added to our blockchain /// Check if this block can be added to our blockchain
pub fn check_new_block(&self, block: &Block) -> BlockQuality { pub fn check_new_block(&self, block: &Block) -> BlockQuality {
+5
View File
@@ -98,6 +98,11 @@ impl Network {
} }
} }
if peers.is_ignored(&address.ip()) {
debug!("Ignoring connection from banned {:?}", &address.ip());
continue;
}
if yggdrasil_only && !is_yggdrasil(&address.ip()) { if yggdrasil_only && !is_yggdrasil(&address.ip()) {
debug!("Dropping connection from Internet"); debug!("Dropping connection from Internet");
stream.shutdown(Shutdown::Both).unwrap_or_else(|e|{ warn!("Error in shutdown, {}", e); }); stream.shutdown(Shutdown::Both).unwrap_or_else(|e|{ warn!("Error in shutdown, {}", e); });
+4
View File
@@ -140,6 +140,10 @@ impl Peers {
self.my_id.eq(rand) self.my_id.eq(rand)
} }
pub fn is_ignored(&self, addr: &IpAddr) -> bool {
self.ignored.contains(addr)
}
pub fn get_peers_for_exchange(&self, peer_address: &SocketAddr) -> Vec<String> { pub fn get_peers_for_exchange(&self, peer_address: &SocketAddr) -> Vec<String> {
let mut result: Vec<String> = Vec::new(); let mut result: Vec<String> = Vec::new();
for (_, peer) in self.peers.iter() { for (_, peer) in self.peers.iter() {