aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/dns_utils.cpp28
-rw-r--r--src/common/dns_utils.h2
-rw-r--r--src/common/int-util.h9
-rw-r--r--src/common/rpc_client.h16
-rw-r--r--src/common/util.cpp2
5 files changed, 37 insertions, 20 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index 06f127c25..1ecdae8ec 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -36,13 +36,21 @@
#include <boost/filesystem/fstream.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/algorithm/string/join.hpp>
using namespace epee;
namespace bf = boost::filesystem;
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.dns"
-#define DEFAULT_DNS_PUBLIC_ADDR "8.8.4.4"
+static const char *DEFAULT_DNS_PUBLIC_ADDR[] =
+{
+ "194.150.168.168", // CCC (Germany)
+ "81.3.27.54", // Lightning Wire Labs (Germany)
+ "31.3.135.232", // OpenNIC (Switzerland)
+ "80.67.169.40", // FDN (France)
+ "209.58.179.186", // Cyberghost (Singapore)
+};
static boost::mutex instance_lock;
@@ -201,13 +209,13 @@ public:
DNSResolver::DNSResolver() : m_data(new DNSResolverData())
{
int use_dns_public = 0;
- std::string dns_public_addr = DEFAULT_DNS_PUBLIC_ADDR;
+ std::vector<std::string> dns_public_addr;
if (auto res = getenv("DNS_PUBLIC"))
{
dns_public_addr = tools::dns_utils::parse_dns_public(res);
if (!dns_public_addr.empty())
{
- MGINFO("Using public DNS server: " << dns_public_addr << " (TCP)");
+ MGINFO("Using public DNS server(s): " << boost::join(dns_public_addr, ", ") << " (TCP)");
use_dns_public = 1;
}
else
@@ -221,7 +229,8 @@ DNSResolver::DNSResolver() : m_data(new DNSResolverData())
if (use_dns_public)
{
- ub_ctx_set_fwd(m_data->m_ub_context, dns_public_addr.c_str());
+ for (const auto &ip: dns_public_addr)
+ ub_ctx_set_fwd(m_data->m_ub_context, ip.c_str());
ub_ctx_set_option(m_data->m_ub_context, string_copy("do-udp:"), string_copy("no"));
ub_ctx_set_option(m_data->m_ub_context, string_copy("do-tcp:"), string_copy("yes"));
}
@@ -526,15 +535,16 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
return true;
}
-std::string parse_dns_public(const char *s)
+std::vector<std::string> parse_dns_public(const char *s)
{
unsigned ip0, ip1, ip2, ip3;
char c;
- std::string dns_public_addr;
+ std::vector<std::string> dns_public_addr;
if (!strcmp(s, "tcp"))
{
- dns_public_addr = DEFAULT_DNS_PUBLIC_ADDR;
- LOG_PRINT_L0("Using default public DNS server: " << dns_public_addr << " (TCP)");
+ for (size_t i = 0; i < sizeof(DEFAULT_DNS_PUBLIC_ADDR) / sizeof(DEFAULT_DNS_PUBLIC_ADDR[0]); ++i)
+ dns_public_addr.push_back(DEFAULT_DNS_PUBLIC_ADDR[i]);
+ LOG_PRINT_L0("Using default public DNS server(s): " << boost::join(dns_public_addr, ", ") << " (TCP)");
}
else if (sscanf(s, "tcp://%u.%u.%u.%u%c", &ip0, &ip1, &ip2, &ip3, &c) == 4)
{
@@ -544,7 +554,7 @@ std::string parse_dns_public(const char *s)
}
else
{
- dns_public_addr = std::string(s + strlen("tcp://"));
+ dns_public_addr.push_back(std::string(s + strlen("tcp://")));
}
}
else
diff --git a/src/common/dns_utils.h b/src/common/dns_utils.h
index d5dc03283..f46bca3dd 100644
--- a/src/common/dns_utils.h
+++ b/src/common/dns_utils.h
@@ -167,7 +167,7 @@ std::string get_account_address_as_str_from_url(const std::string& url, bool& dn
bool load_txt_records_from_dns(std::vector<std::string> &records, const std::vector<std::string> &dns_urls);
-std::string parse_dns_public(const char *s);
+std::vector<std::string> parse_dns_public(const char *s);
} // namespace tools::dns_utils
diff --git a/src/common/int-util.h b/src/common/int-util.h
index 11e39895e..3bcc085e2 100644
--- a/src/common/int-util.h
+++ b/src/common/int-util.h
@@ -34,7 +34,10 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+
+#ifndef _MSC_VER
#include <sys/param.h>
+#endif
#if defined(__ANDROID__)
#include <byteswap.h>
@@ -206,6 +209,12 @@ static inline void memcpy_swap64(void *dst, const void *src, size_t n) {
}
}
+#ifdef _MSC_VER
+# define LITTLE_ENDIAN 1234
+# define BIG_ENDIAN 4321
+# define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled");
#endif
diff --git a/src/common/rpc_client.h b/src/common/rpc_client.h
index 64c84ed19..9665966ae 100644
--- a/src/common/rpc_client.h
+++ b/src/common/rpc_client.h
@@ -72,10 +72,10 @@ namespace tools
fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port();
return false;
}
- ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
+ ok = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
if (!ok)
{
- fail_msg_writer() << "Daemon request failed";
+ fail_msg_writer() << "basic_json_rpc_request: Daemon request failed";
return false;
}
else
@@ -95,15 +95,15 @@ namespace tools
t_http_connection connection(&m_http_client);
bool ok = connection.is_open();
- ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
if (!ok)
{
fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port();
return false;
}
- else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
+ ok = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
+ if (!ok || res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
{
- fail_msg_writer() << fail_msg << " -- " << res.status;
+ fail_msg_writer() << fail_msg << " -- json_rpc_request: " << res.status;
return false;
}
else
@@ -123,15 +123,15 @@ namespace tools
t_http_connection connection(&m_http_client);
bool ok = connection.is_open();
- ok = ok && epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT());
if (!ok)
{
fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port();
return false;
}
- else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
+ ok = epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT());
+ if (!ok || res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
{
- fail_msg_writer() << fail_msg << " -- " << res.status;
+ fail_msg_writer() << fail_msg << "-- rpc_request: " << res.status;
return false;
}
else
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 659ea31b8..e0f3cd655 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -552,8 +552,6 @@ std::string get_nix_version_display_string()
}
bool on_startup()
{
- wipeable_string::set_wipe(&memwipe);
-
mlog_configure("", true);
sanitize_locale();