diff options
author | anon <anon [at] nowhere> | 2021-03-18 20:50:21 +0000 |
---|---|---|
committer | tobtoht <thotbot@protonmail.com> | 2021-08-20 21:24:29 +0200 |
commit | 4ced092aae04e5a6789e94b68a07c74e653cd869 (patch) | |
tree | 8b298bd88ae5bcdf88eaa3e8a7c510b527d56d91 /src/p2p | |
parent | Merge pull request #7735 (diff) | |
download | monero-4ced092aae04e5a6789e94b68a07c74e653cd869.tar.xz |
daemon: allow proxy configuration
Co-authored-by: selsta <selsta@sent.at>
Co-authored-by: tobtoht <thotbot@protonmail.com>
Diffstat (limited to 'src/p2p')
-rw-r--r-- | src/p2p/net_node.cpp | 3 | ||||
-rw-r--r-- | src/p2p/net_node.h | 4 | ||||
-rw-r--r-- | src/p2p/net_node.inl | 19 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp index 84cc1581e..c951db085 100644 --- a/src/p2p/net_node.cpp +++ b/src/p2p/net_node.cpp @@ -94,6 +94,9 @@ namespace case net::i2p_address::get_type_id(): set = client->set_connect_command(remote.as<net::i2p_address>()); break; + case epee::net_utils::ipv4_network_address::get_type_id(): + set = client->set_connect_command(remote.as<epee::net_utils::ipv4_network_address>()); + break; default: MERROR("Unsupported network address in socks_connect"); return false; diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index f2888674b..9e64121be 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -259,6 +259,7 @@ namespace nodetool m_offline(false), is_closing(false), m_network_id(), + m_enable_dns_seed_nodes(true), max_connections(1) {} virtual ~node_server(); @@ -267,7 +268,7 @@ namespace nodetool bool run(); network_zone& add_zone(epee::net_utils::zone zone); - bool init(const boost::program_options::variables_map& vm); + bool init(const boost::program_options::variables_map& vm, const std::string& proxy = {}, bool proxy_dns_leaks_allowed = {}); bool deinit(); bool send_stop_signal(); uint32_t get_this_peer_port(){return m_listening_port;} @@ -516,6 +517,7 @@ namespace nodetool epee::net_utils::ssl_support_t m_ssl_support; + bool m_enable_dns_seed_nodes; bool m_enable_dns_blocklist; uint32_t max_connections; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index a0b8438b2..e2b1f3c9c 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -723,6 +723,12 @@ namespace nodetool { return get_ip_seed_nodes(); } + if (!m_enable_dns_seed_nodes) + { + // TODO: a domain can be set through socks, so that the remote side does the lookup for the DNS seed nodes. + m_fallback_seed_nodes_added.test_and_set(); + return get_ip_seed_nodes(); + } std::set<std::string> full_addrs; @@ -861,10 +867,21 @@ namespace nodetool } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> - bool node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm) + bool node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm, const std::string& proxy, bool proxy_dns_leaks_allowed) { bool res = handle_command_line(vm); CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); + if (proxy.size()) + { + const auto endpoint = net::get_tcp_endpoint(proxy); + CHECK_AND_ASSERT_MES(endpoint, false, "Failed to parse proxy: " << proxy << " - " << endpoint.error()); + network_zone& public_zone = m_network_zones[epee::net_utils::zone::public_]; + public_zone.m_connect = &socks_connect; + public_zone.m_proxy_address = *endpoint; + public_zone.m_can_pingback = false; + m_enable_dns_seed_nodes &= proxy_dns_leaks_allowed; + m_enable_dns_blocklist &= proxy_dns_leaks_allowed; + } if (m_nettype == cryptonote::TESTNET) { |