diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2021-03-29 21:08:36 -0400 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2021-03-29 21:08:36 -0400 |
| commit | c2bc829cca9d134fead5caa97c5d3a643232ece3 (patch) | |
| tree | e2d03b1ded4abb8fc6e02035f54103b7ce8ebc23 /src/rpc/bootstrap_daemon.cpp | |
| parent | 8c8197463feafc35eb8dda7ec962b8b3c6bfba5c (diff) | |
| parent | cf266d66dd14801b6d03668e7904dcde02a19327 (diff) | |
| download | monzero-core-c2bc829cca9d134fead5caa97c5d3a643232ece3.tar.gz monzero-core-c2bc829cca9d134fead5caa97c5d3a643232ece3.tar.xz monzero-core-c2bc829cca9d134fead5caa97c5d3a643232ece3.zip | |
Merge pull request #7326
cf266d6 bootstrap_daemon: proxy configuration support (xiphon)
Diffstat (limited to 'src/rpc/bootstrap_daemon.cpp')
| -rw-r--r-- | src/rpc/bootstrap_daemon.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/rpc/bootstrap_daemon.cpp b/src/rpc/bootstrap_daemon.cpp index 2fdd28406..ffea906d5 100644 --- a/src/rpc/bootstrap_daemon.cpp +++ b/src/rpc/bootstrap_daemon.cpp @@ -7,6 +7,7 @@ #include "crypto/crypto.h" #include "cryptonote_core/cryptonote_core.h" #include "misc_log_ex.h" +#include "net/parse.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "daemon.rpc.bootstrap_daemon" @@ -16,19 +17,23 @@ namespace cryptonote bootstrap_daemon::bootstrap_daemon( std::function<std::map<std::string, bool>()> get_public_nodes, - bool rpc_payment_enabled) + bool rpc_payment_enabled, + const std::string &proxy) : m_selector(new bootstrap_node::selector_auto(std::move(get_public_nodes))) , m_rpc_payment_enabled(rpc_payment_enabled) { + set_proxy(proxy); } bootstrap_daemon::bootstrap_daemon( const std::string &address, boost::optional<epee::net_utils::http::login> credentials, - bool rpc_payment_enabled) + bool rpc_payment_enabled, + const std::string &proxy) : m_selector(nullptr) , m_rpc_payment_enabled(rpc_payment_enabled) { + set_proxy(proxy); if (!set_server(address, std::move(credentials))) { throw std::runtime_error("invalid bootstrap daemon address or credentials"); @@ -78,6 +83,18 @@ namespace cryptonote return success; } + void bootstrap_daemon::set_proxy(const std::string &address) + { + if (!address.empty() && !net::get_tcp_endpoint(address)) + { + throw std::runtime_error("invalid proxy address format"); + } + if (!m_http_client.set_proxy(address)) + { + throw std::runtime_error("failed to set proxy address"); + } + } + bool bootstrap_daemon::set_server(const std::string &address, const boost::optional<epee::net_utils::http::login> &credentials /* = boost::none */) { if (!m_http_client.set_server(address, credentials)) |
