Skip to content

Commit

Permalink
Read blocked peers from config
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiNano committed Jan 30, 2024
1 parent b2f26a5 commit ced8cf0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions nano/node/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ void nano::network::start ()
}
ongoing_keepalive ();

auto ip = boost::asio::ip::make_address ("144.76.30.235");
node.logger.info (nano::log::type::network, "Blocking: {}", ip.to_string() );
block_ip (ip);
auto blocked_peers = node.config.blocked_peers;

for (const std::string & ip_string : blocked_peers)
{
auto ip = boost::asio::ip::make_address (ip_string);
block_ip (ip);
node.logger.info (nano::log::type::network, "Added blocking rule for ip {}", ip.to_string ());
}
}

void nano::network::stop ()
Expand Down
8 changes: 8 additions & 0 deletions nano/node/nodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
});
}

if (toml.has_key ("blocked_peers"))
{
blocked_peers.clear ();
toml.array_entries_required<std::string> ("blocked_peers", [this, &toml] (std::string entry) {
blocked_peers.push_back (entry);
});
}

if (toml.has_key ("preconfigured_representatives"))
{
preconfigured_representatives.clear ();
Expand Down
1 change: 1 addition & 0 deletions nano/node/nodeconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class node_config
std::vector<std::pair<std::string, uint16_t>> work_peers;
std::vector<std::pair<std::string, uint16_t>> secondary_work_peers{ { "127.0.0.1", 8076 } }; /* Default of nano-pow-server */
std::vector<std::string> preconfigured_peers;
std::vector<std::string> blocked_peers{};
std::vector<nano::account> preconfigured_representatives;
unsigned bootstrap_fraction_numerator{ 1 };
nano::amount receive_minimum{ nano::xrb_ratio };
Expand Down

0 comments on commit ced8cf0

Please sign in to comment.