Skip to content

Commit

Permalink
we can now ban/unban peers by ip only (port optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Feb 15, 2019
1 parent ad4481d commit e245a8a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions api/src/handlers/peers_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,18 @@ impl Handler for PeerHandler {
};
let addr = match path_elems.next() {
None => return response(StatusCode::BAD_REQUEST, "invalid url"),
Some(a) => match a.parse() {
Err(e) => {
Some(a) => {
if let Ok(ip_addr) = a.parse() {
PeerAddr::from_ip(ip_addr)
} else if let Ok(addr) = a.parse() {
PeerAddr(addr)
} else {
return response(
StatusCode::BAD_REQUEST,
format!("invalid peer address: {}", e),
format!("invalid peer address: {}", req.uri().path()),
);
}
Ok(addr) => PeerAddr(addr),
},
}
};

match command {
Expand Down

0 comments on commit e245a8a

Please sign in to comment.