From 10ce90d99ba1621c089aa0d74a0c84813daaacbf Mon Sep 17 00:00:00 2001 From: Thiago Silva Date: Fri, 3 Feb 2023 17:34:16 -0300 Subject: [PATCH] Remove disable_udp flag --- nano/node/cli.cpp | 4 +--- nano/node/node.cpp | 6 +++--- nano/node/nodeconfig.hpp | 1 - nano/node/portmapping.cpp | 4 +++- nano/node/transport/tcp_server.cpp | 23 +++++------------------ 5 files changed, 12 insertions(+), 26 deletions(-) diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index 3f89da982..9a08c5d4d 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -102,7 +102,6 @@ void nano::add_node_flag_options (boost::program_options::options_description & ("disable_request_loop", "Disable request loop") ("disable_bootstrap_listener", "Disables bootstrap processing for TCP listener (not including realtime network TCP connections)") ("disable_tcp_realtime", "Disables TCP realtime network") - ("disable_udp", "(Deprecated) UDP is disabled by default") ("enable_udp", "Enables UDP realtime network") ("disable_unchecked_cleanup", "Disables periodic cleanup of old records from unchecked table") ("disable_unchecked_drop", "Disables drop of unchecked table at startup") @@ -141,8 +140,7 @@ std::error_code nano::update_flags (nano::node_flags & flags_a, boost::program_o { ec = nano::error_cli::ambiguous_udp_options; } - flags_a.disable_udp = (vm.count ("enable_udp") == 0); - if (flags_a.disable_tcp_realtime && flags_a.disable_udp) + if (flags_a.disable_tcp_realtime) { ec = nano::error_cli::disable_all_network; } diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 89b3c7e48..44221879a 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -658,7 +658,7 @@ void nano::node::start () tcp_listener.start (); tcp_enabled = true; - if (flags.disable_udp && network.port != tcp_listener.port) + if (network.port != tcp_listener.port) { network.port = tcp_listener.port; } @@ -682,8 +682,8 @@ void nano::node::start () this_l->bootstrap_wallet (); }); } - // Start port mapping if external address is not defined and TCP or UDP ports are enabled - if (config.external_address == boost::asio::ip::address_v6{}.any ().to_string () && (tcp_enabled || !flags.disable_udp)) + // Start port mapping if external address is not defined and TCP ports are enabled + if (config.external_address == boost::asio::ip::address_v6{}.any ().to_string () && tcp_enabled) { port_mapping.start (); } diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 43a403224..c8d97c061 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -137,7 +137,6 @@ public: bool disable_rep_crawler{ false }; bool disable_request_loop{ false }; // For testing only bool disable_tcp_realtime{ false }; - bool disable_udp{ true }; bool disable_unchecked_cleanup{ false }; bool disable_unchecked_drop{ true }; bool disable_providing_telemetry_metrics{ false }; diff --git a/nano/node/portmapping.cpp b/nano/node/portmapping.cpp index 12146d27e..690b7ce90 100644 --- a/nano/node/portmapping.cpp +++ b/nano/node/portmapping.cpp @@ -17,7 +17,9 @@ std::string nano::mapping_protocol::to_string () nano::port_mapping::port_mapping (nano::node & node_a) : node (node_a), - protocols ({ { { "TCP", boost::asio::ip::address_v4::any (), 0, true }, { "UDP", boost::asio::ip::address_v4::any (), 0, !node_a.flags.disable_udp } } }) + // Kept UDP in the array (set disabled) so the port mapping is still + // implemented in case other transport protocols that rely on it is added. + protocols ({ { { "TCP", boost::asio::ip::address_v4::any (), 0, true }, { "UDP", boost::asio::ip::address_v4::any (), 0, false } } }) { } diff --git a/nano/node/transport/tcp_server.cpp b/nano/node/transport/tcp_server.cpp index b5be8c747..bee85cc1f 100644 --- a/nano/node/transport/tcp_server.cpp +++ b/nano/node/transport/tcp_server.cpp @@ -27,33 +27,20 @@ void nano::transport::tcp_listener::start () throw std::runtime_error (ec.message ()); } - // the user can either specify a port value in the config or it can leave the choice up to the OS; - // independently of user's port choice, he may have also opted to disable UDP or not; this gives us 4 possibilities: - // (1): UDP enabled, port specified - // (2): UDP enabled, port not specified - // (3): UDP disabled, port specified - // (4): UDP disabled, port not specified + // the user can either specify a port value in the config or it can leave the choice up to the OS: + // (1): port specified + // (2): port not specified // const auto listening_port = listening_socket->listening_port (); - if (!node.flags.disable_udp) { - // (1) and (2) -- no matter if (1) or (2), since UDP socket binding happens before this TCP socket binding, - // we must have already been constructed with a valid port value, so check that it really is the same everywhere - // - debug_assert (port == listening_port); - debug_assert (port == node.network.port); - debug_assert (port == node.network.endpoint ().port ()); - } - else - { - // (3) -- nothing to do, just check that port values match everywhere + // (1) -- nothing to do, just check that port values match everywhere // if (port == listening_port) { debug_assert (port == node.network.port); debug_assert (port == node.network.endpoint ().port ()); } - // (4) -- OS port choice happened at TCP socket bind time, so propagate this port value back; + // (2) -- OS port choice happened at TCP socket bind time, so propagate this port value back; // the propagation is done here for the `tcp_listener` itself, whereas for `network`, the node does it // after calling `tcp_listener.start ()` //