Improve initial TCP server keepalive (#2528)

Send additional random peers in `nano::network::send_keepalive_self ()` function
This commit is contained in:
Sergey Kroshnin 2020-02-04 03:51:10 +03:00 committed by GitHub
commit 66d5f33b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,6 +105,9 @@ void nano::network::send_keepalive (std::shared_ptr<nano::transport::channel> ch
void nano::network::send_keepalive_self (std::shared_ptr<nano::transport::channel> channel_a)
{
nano::keepalive message;
random_fill (message.peers);
// Replace part of message with node external address or listening port
message.peers[1] = nano::endpoint (boost::asio::ip::address_v6{}, 0); // For node v19 (response channels)
if (node.config.external_address != boost::asio::ip::address_v6{}.to_string () && node.config.external_port != 0)
{
message.peers[0] = nano::endpoint (boost::asio::ip::make_address_v6 (node.config.external_address), node.config.external_port);