More robust peer banning (#3086)

More robust peer banning
This commit is contained in:
Quentin Le Sceller
2019-10-04 18:00:49 -04:00
committed by GitHub
parent 4e37c1c9e7
commit eefd87aa2e
5 changed files with 87 additions and 60 deletions
+14 -2
View File
@@ -101,8 +101,20 @@ impl Handler for PeerHandler {
};
match command {
"ban" => w_fut!(&self.peers).ban_peer(addr, ReasonForBan::ManualBan),
"unban" => w_fut!(&self.peers).unban_peer(addr),
"ban" => match w_fut!(&self.peers).ban_peer(addr, ReasonForBan::ManualBan) {
Ok(_) => response(StatusCode::OK, "{}"),
Err(e) => response(
StatusCode::INTERNAL_SERVER_ERROR,
format!("ban failed: {:?}", e),
),
},
"unban" => match w_fut!(&self.peers).unban_peer(addr) {
Ok(_) => response(StatusCode::OK, "{}"),
Err(e) => response(
StatusCode::INTERNAL_SERVER_ERROR,
format!("unban failed: {:?}", e),
),
},
_ => return response(StatusCode::BAD_REQUEST, "invalid command"),
};