-
Notifications
You must be signed in to change notification settings - Fork 930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swarm: ban connections based on peerid #1065
swarm: ban connections based on peerid #1065
Conversation
Co-Authored-By: montekki <fedor.sakharov@gmail.com>
Co-Authored-By: montekki <fedor.sakharov@gmail.com>
I think that it could also be a good idea to ignore any |
core/src/swarm/swarm.rs
Outdated
@@ -258,7 +273,11 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>, | |||
self.behaviour.inject_node_event(conn_info.peer_id().clone(), event); | |||
}, | |||
Async::Ready(RawSwarmEvent::Connected { conn_info, endpoint }) => { | |||
self.behaviour.inject_connected(conn_info.peer_id().clone(), endpoint); | |||
if self.banned_peers.contains(conn_info.peer_id()) { | |||
self.raw_swarm.peer(conn_info.peer_id().clone()).into_connected().map(|c| c.close()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually preferred the expect
here. If into_connected
returns None
then there's a very serious bug and it's preferable to panic rather than silently continue in an invalid state.
Co-Authored-By: montekki <fedor.sakharov@gmail.com>
Co-Authored-By: montekki <fedor.sakharov@gmail.com>
Tries to solve #786