Merge pull request #7326

cf266d6 bootstrap_daemon: proxy configuration support (xiphon)
This commit is contained in:
luigi1111 2021-03-29 21:08:36 -04:00
commit c2bc829cca
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
9 changed files with 125 additions and 27 deletions

View file

@ -986,17 +986,67 @@ bool t_command_parser_executor::check_blockchain_pruning(const std::vector<std::
bool t_command_parser_executor::set_bootstrap_daemon(const std::vector<std::string>& args)
{
const size_t args_count = args.size();
if (args_count < 1 || args_count > 3)
struct parsed_t
{
std::string address;
std::string user;
std::string password;
std::string proxy;
};
boost::optional<parsed_t> parsed = [&args]() -> boost::optional<parsed_t> {
const size_t args_count = args.size();
if (args_count == 0)
{
return {};
}
if (args[0] == "auto")
{
if (args_count == 1)
{
return {{args[0], "", "", ""}};
}
if (args_count == 2)
{
return {{args[0], "", "", args[1]}};
}
}
else if (args[0] == "none")
{
if (args_count == 1)
{
return {{"", "", "", ""}};
}
}
else
{
if (args_count == 1)
{
return {{args[0], "", "", ""}};
}
if (args_count == 2)
{
return {{args[0], "", "", args[1]}};
}
if (args_count == 3)
{
return {{args[0], args[1], args[2], ""}};
}
if (args_count == 4)
{
return {{args[0], args[1], args[2], args[3]}};
}
}
return {};
}();
if (!parsed)
{
std::cout << "Invalid syntax: Wrong number of parameters. For more details, use the help command." << std::endl;
return true;
}
return m_executor.set_bootstrap_daemon(
args[0] != "none" ? args[0] : std::string(),
args_count > 1 ? args[1] : std::string(),
args_count > 2 ? args[2] : std::string());
return m_executor.set_bootstrap_daemon(parsed->address, parsed->user, parsed->password, parsed->proxy);
}
bool t_command_parser_executor::flush_cache(const std::vector<std::string>& args)

View file

@ -326,7 +326,7 @@ t_command_server::t_command_server(
m_command_lookup.set_handler(
"set_bootstrap_daemon"
, std::bind(&t_command_parser_executor::set_bootstrap_daemon, &m_parser, p::_1)
, "set_bootstrap_daemon (auto | none | host[:port] [username] [password])"
, "set_bootstrap_daemon (auto | none | host[:port] [username] [password]) [proxy_ip:proxy_port]"
, "URL of a 'bootstrap' remote daemon that the connected wallets can use while this daemon is still not fully synced.\n"
"Use 'auto' to enable automatic public nodes discovering and bootstrap daemon switching"
);

View file

@ -2405,7 +2405,8 @@ bool t_rpc_command_executor::check_blockchain_pruning()
bool t_rpc_command_executor::set_bootstrap_daemon(
const std::string &address,
const std::string &username,
const std::string &password)
const std::string &password,
const std::string &proxy)
{
cryptonote::COMMAND_RPC_SET_BOOTSTRAP_DAEMON::request req;
cryptonote::COMMAND_RPC_SET_BOOTSTRAP_DAEMON::response res;
@ -2414,6 +2415,7 @@ bool t_rpc_command_executor::set_bootstrap_daemon(
req.address = address;
req.username = username;
req.password = password;
req.proxy = proxy;
if (m_is_rpc)
{

View file

@ -168,7 +168,8 @@ public:
bool set_bootstrap_daemon(
const std::string &address,
const std::string &username,
const std::string &password);
const std::string &password,
const std::string &proxy);
bool rpc_payments();