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

Ignore selected peers #4413

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

RickiNano
Copy link
Contributor

This PR introduces an optional list of ip addresses that a node operator wants to ignore. The peers are inserted in the config file as "blocked_peers"
Both ip v4 and v6 address formats are supported and can be mixed. Example:
blocked_peers = ["::ffff:10.0.0.1", "192.168.0.1"]
This could be useful for blocking malicious nodes.

nano/core_test/toml.cpp Outdated Show resolved Hide resolved
nano/node/network.cpp Outdated Show resolved Hide resolved
nano/node/network.cpp Outdated Show resolved Hide resolved
@clemahieu
Copy link
Contributor

We should also have an affirmative test that shows the ip blocking works.

@RickiNano
Copy link
Contributor Author

I've moved the logic to the tcp_listener::on_connection function. I will try to add some unit tests next

@@ -136,6 +137,13 @@ void nano::transport::tcp_listener::on_connection (std::function<bool (std::shar
[this_l, new_connection, cbk = std::move (callback)] (boost::system::error_code const & ec_a) mutable {
this_l->evict_dead_connections ();

if (this_l->is_ip_blocked (new_connection->remote.address ()))
{
this_l->node.logger.info (nano::log::type::tcp_listener, "Connection refused from blocked IP: {}", new_connection->remote_endpoint ().address ().to_string ());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should remain a debug log as it could be high-volume.

@RickiNano RickiNano marked this pull request as draft August 16, 2024 12:47
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