Added `--no-dns` command line parameter

pull/206/head
SChernykh 2 years ago
parent c49e8d4770
commit e4dd46b498

@ -24,6 +24,7 @@
--no-autodiff Disable automatic difficulty adjustment for miners connected to stratum
--rpc-login Specify username[:password] required for Monero RPC server
--socks5 Specify IP:port of a SOCKS5 proxy to use for outgoing connections
--no-dns disable DNS queries, use only IP addresses to connect to peers (seed node DNS will be unavailable too)
```
### Example command line

@ -49,6 +49,7 @@ void p2pool_usage()
"--no-autodiff Disable automatic difficulty adjustment for miners connected to stratum\n"
"--rpc-login Specify username[:password] required for Monero RPC server\n"
"--socks5 Specify IP:port of a SOCKS5 proxy to use for outgoing connections\n"
"--no-dns disable DNS queries, use only IP addresses to connect to peers (seed node DNS will be unavailable too)\n"
"--help Show this help message\n\n"
"Example command line:\n\n"
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",

@ -246,7 +246,7 @@ void P2PServer::connect_to_peers(const std::string& peer_list)
parse_address_list(peer_list,
[this](bool is_v6, const std::string& /*address*/, std::string ip, int port)
{
if (!m_socks5Proxy.empty() || resolve_host(ip, is_v6)) {
if (!m_pool->params().m_dns || resolve_host(ip, is_v6)) {
connect_to_peer(is_v6, ip.c_str(), port);
}
});
@ -356,7 +356,7 @@ void P2PServer::update_peer_connections()
peer_list.pop_back();
}
if (!has_good_peers && ((m_timerCounter % 30) == 0)) {
if (!has_good_peers && ((m_timerCounter % 10) == 0)) {
LOGERR(1, "no connections to other p2pool nodes, check your monerod/p2pool/network/firewall setup!!!");
load_peer_list();
if (m_peerListMonero.empty()) {
@ -536,11 +536,13 @@ void P2PServer::load_peer_list()
}
};
if (m_pool->side_chain().is_default()) {
load_from_seed_nodes(seed_nodes, DEFAULT_P2P_PORT);
}
else if (m_pool->side_chain().is_mini()) {
load_from_seed_nodes(seed_nodes_mini, DEFAULT_P2P_PORT_MINI);
if (m_pool->params().m_dns) {
if (m_pool->side_chain().is_default()) {
load_from_seed_nodes(seed_nodes, DEFAULT_P2P_PORT);
}
else if (m_pool->side_chain().is_mini()) {
load_from_seed_nodes(seed_nodes_mini, DEFAULT_P2P_PORT_MINI);
}
}
// Finally load peers from p2pool_peers.txt

@ -64,10 +64,18 @@ p2pool::p2pool(int argc, char* argv[])
throw std::exception();
}
bool is_v6;
if (m_params->m_socks5Proxy.empty() && !resolve_host(m_params->m_host, is_v6)) {
LOGERR(1, "resolve_host failed for " << m_params->m_host);
throw std::exception();
if (m_params->m_socks5Proxy.empty()) {
if (m_params->m_dns) {
bool is_v6;
if (!resolve_host(m_params->m_host, is_v6)) {
LOGERR(1, "resolve_host failed for " << m_params->m_host);
throw std::exception();
}
}
else if (m_params->m_host.find_first_not_of("0123456789.:") != std::string::npos) {
LOGERR(1, "Can't resolve hostname " << m_params->m_host << " with DNS disabled");
throw std::exception();
}
}
hash pub, sec, eph_public_key;

@ -140,6 +140,12 @@ Params::Params(int argc, char* argv[])
ok = true;
}
if (strcmp(argv[i], "--no-dns") == 0) {
m_dns = false;
disable_resolve_host = true;
ok = true;
}
if (!ok) {
fprintf(stderr, "Unknown command line parameter %s\n\n", argv[i]);
p2pool_usage();

@ -51,6 +51,7 @@ struct Params
bool m_autoDiff = true;
std::string m_rpcLogin;
std::string m_socks5Proxy;
bool m_dns = true;
};
} // namespace p2pool

@ -353,8 +353,15 @@ static thread_local bool main_thread = false;
void set_main_thread() { main_thread = true; }
bool is_main_thread() { return main_thread; }
bool disable_resolve_host = false;
bool resolve_host(std::string& host, bool& is_v6)
{
if (disable_resolve_host) {
LOGERR(1, "resolve_host was called with DNS disabled for host " << host);
return false;
}
addrinfo hints{};
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

@ -171,6 +171,7 @@ extern BackgroundJobTracker bkg_jobs_tracker;
void set_main_thread();
bool is_main_thread();
extern bool disable_resolve_host;
bool resolve_host(std::string& host, bool& is_v6);
template <typename Key, typename T>

Loading…
Cancel
Save