aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/dns_utils.cpp2
-rw-r--r--src/common/perf_timer.cpp2
-rw-r--r--src/common/util.cpp35
3 files changed, 18 insertions, 21 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index ce4555ae3..9c10c420c 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -339,8 +339,10 @@ std::vector<std::string> DNSResolver::get_record(const std::string& url, int rec
dnssec_available = (result->secure || result->bogus);
dnssec_valid = result->secure && !result->bogus;
if (dnssec_available && !dnssec_valid)
+ {
MWARNING("Invalid DNSSEC " << get_record_name(record_type) << " record signature for " << url << ": " << result->why_bogus);
MWARNING("Possibly your DNS service is problematic. You can have monerod use an alternate via env variable DNS_PUBLIC. Example: DNS_PUBLIC=tcp://9.9.9.9");
+ }
if (result->havedata)
{
for (size_t i=0; result->data[i] != NULL; i++)
diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp
index 2b67154e5..229748994 100644
--- a/src/common/perf_timer.cpp
+++ b/src/common/perf_timer.cpp
@@ -62,7 +62,7 @@ namespace tools
while (1)
{
t1 = epee::misc_utils::get_ns_count();
- if (t1 - t0 > 1*1000000000) break; // work one second
+ if (t1 - t0 > 1*100000000) break; // work 0.1 seconds
}
uint64_t r1 = get_tick_count();
diff --git a/src/common/util.cpp b/src/common/util.cpp
index c89a85267..b4f3360ef 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -610,13 +610,6 @@ namespace tools
bool is_local_address(const std::string &address)
{
- // always assume Tor/I2P addresses to be untrusted by default
- if (is_privacy_preserving_network(address))
- {
- MDEBUG("Address '" << address << "' is Tor/I2P, non local");
- return false;
- }
-
// extract host
epee::net_utils::http::url_content u_c;
if (!epee::net_utils::parse_url(address, u_c))
@@ -630,20 +623,22 @@ namespace tools
return false;
}
- // resolve to IP
- boost::asio::io_service io_service;
- boost::asio::ip::tcp::resolver resolver(io_service);
- boost::asio::ip::tcp::resolver::query query(u_c.host, "");
- boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);
- while (i != boost::asio::ip::tcp::resolver::iterator())
+ if (u_c.host == "localhost" || boost::ends_with(u_c.host, ".localhost")) { // RFC 6761 (6.3)
+ MDEBUG("Address '" << address << "' is local");
+ return true;
+ }
+
+ boost::system::error_code ec;
+ const auto parsed_ip = boost::asio::ip::address::from_string(u_c.host, ec);
+ if (ec) {
+ MDEBUG("Failed to parse '" << address << "' as IP address: " << ec.message() << ". Considering it not local");
+ return false;
+ }
+
+ if (parsed_ip.is_loopback())
{
- const boost::asio::ip::tcp::endpoint &ep = *i;
- if (ep.address().is_loopback())
- {
- MDEBUG("Address '" << address << "' is local");
- return true;
- }
- ++i;
+ MDEBUG("Address '" << address << "' is local");
+ return true;
}
MDEBUG("Address '" << address << "' is not local");