Skip to content
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

Merged
merged 14 commits into from
Apr 18, 2019
Merged

swarm: ban connections based on peerid #1065

merged 14 commits into from
Apr 18, 2019

Conversation

montekki
Copy link
Contributor

Tries to solve #786

examples/chat.rs Outdated Show resolved Hide resolved
core/src/swarm/swarm.rs Outdated Show resolved Hide resolved
core/src/swarm/swarm.rs Show resolved Hide resolved
core/src/swarm/swarm.rs Show resolved Hide resolved
core/src/swarm/swarm.rs Outdated Show resolved Hide resolved
@tomaka
Copy link
Member

tomaka commented Apr 17, 2019

I think that it could also be a good idea to ignore any DialPeer action that we receive containing a banned node.
EDIT: And immediately call inject_dial_failure instead.

@montekki montekki marked this pull request as ready for review April 17, 2019 14:26
core/src/swarm/swarm.rs Outdated Show resolved Hide resolved
core/src/swarm/swarm.rs Outdated Show resolved Hide resolved
@@ -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());
Copy link
Member

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.

tomaka and others added 3 commits April 17, 2019 20:16
Co-Authored-By: montekki <fedor.sakharov@gmail.com>
Co-Authored-By: montekki <fedor.sakharov@gmail.com>
@ghost ghost assigned tomaka Apr 18, 2019
@ghost ghost added the in progress label Apr 18, 2019
@tomaka tomaka merged commit 7dc95e7 into libp2p:master Apr 18, 2019
@ghost ghost removed the in progress label Apr 18, 2019
@tomaka tomaka mentioned this pull request Apr 19, 2019
@montekki montekki deleted the fs-refuse-connections-by-peer-id branch May 13, 2019 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants