aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt15
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/debug_utilities/CMakeLists.txt22
-rw-r--r--src/debug_utilities/dns_checks.cpp149
4 files changed, 187 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a22478e9..cf6955306 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -246,6 +246,12 @@ enable_testing()
option(BUILD_DOCUMENTATION "Build the Doxygen documentation." ON)
option(BUILD_TESTS "Build tests." OFF)
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(DEFAULT_BUILD_DEBUG_UTILITIES ON)
+else()
+ set(DEFAULT_BUILD_DEBUG_UTILITIES OFF)
+endif()
+option(BUILD_DEBUG_UTILITIES "Build debug utilities." DEFAULT_BUILD_DEBUG_UTILITIES)
# Check whether we're on a 32-bit or 64-bit system
if(CMAKE_SIZEOF_VOID_P EQUAL "8")
@@ -998,7 +1004,16 @@ add_subdirectory(contrib)
add_subdirectory(src)
if(BUILD_TESTS)
+ message(STATUS "Building tests")
add_subdirectory(tests)
+else()
+ message(STATUS "Not building tests")
+endif()
+
+if(BUILD_DEBUG_UTILITIES)
+ message(STATUS "Building debug utilities")
+else()
+ message(STATUS "Not building debug utilities")
endif()
if(BUILD_DOCUMENTATION)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index da6d76d97..8a21763c8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -133,7 +133,7 @@ if(NOT IOS)
add_subdirectory(blockchain_utilities)
endif()
-if(CMAKE_BUILD_TYPE STREQUAL Debug)
+if(BUILD_DEBUG_UTILITIES)
add_subdirectory(debug_utilities)
endif()
diff --git a/src/debug_utilities/CMakeLists.txt b/src/debug_utilities/CMakeLists.txt
index 7bc2c324f..03c2b3e20 100644
--- a/src/debug_utilities/CMakeLists.txt
+++ b/src/debug_utilities/CMakeLists.txt
@@ -69,3 +69,25 @@ set_property(TARGET object_sizes
PROPERTY
OUTPUT_NAME "monero-utils-object-sizes")
+
+set(dns_checks_sources
+ dns_checks.cpp
+ )
+
+monero_add_executable(dns_checks
+ ${dns_checks_sources}
+ ${dns_checks_private_headers})
+
+target_link_libraries(dns_checks
+ LINK_PRIVATE
+ common
+ epee
+ version
+ ${Boost_PROGRAM_OPTIONS_LIBRARY}
+ ${Boost_SYSTEM_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT})
+
+set_property(TARGET dns_checks
+ PROPERTY
+ OUTPUT_NAME "monero-utils-dns-checks")
+
diff --git a/src/debug_utilities/dns_checks.cpp b/src/debug_utilities/dns_checks.cpp
new file mode 100644
index 000000000..3c9daa769
--- /dev/null
+++ b/src/debug_utilities/dns_checks.cpp
@@ -0,0 +1,149 @@
+// Copyright (c) 2019, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <string>
+#include <vector>
+#include <map>
+#include <algorithm>
+#include <boost/program_options.hpp>
+#include "misc_log_ex.h"
+#include "common/util.h"
+#include "common/command_line.h"
+#include "common/dns_utils.h"
+#include "version.h"
+
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "debugtools.dnschecks"
+
+namespace po = boost::program_options;
+
+enum lookup_t { LOOKUP_A, LOOKUP_TXT };
+
+static std::vector<std::string> lookup(lookup_t type, const char *hostname)
+{
+ bool dnssec_available = false, dnssec_valid = false;
+ std::vector<std::string> res;
+ switch (type)
+ {
+ case LOOKUP_A: res = tools::DNSResolver::instance().get_ipv4(hostname, dnssec_available, dnssec_valid); break;
+ case LOOKUP_TXT: res = tools::DNSResolver::instance().get_txt_record(hostname, dnssec_available, dnssec_valid); break;
+ default: MERROR("Invalid lookup type: " << (int)type); return {};
+ }
+ if (!dnssec_available)
+ {
+ MWARNING("No DNSSEC for " << hostname);
+ return {};
+ }
+ if (!dnssec_valid)
+ {
+ MWARNING("Invalid DNSSEC check for " << hostname);
+ return {};
+ }
+ MINFO(res.size() << " valid signed result(s) for " << hostname);
+ return res;
+}
+
+static void lookup(lookup_t type, const std::vector<std::string> hostnames)
+{
+ std::vector<std::vector<std::string>> results;
+ for (const std::string &hostname: hostnames)
+ {
+ auto res = lookup(type, hostname.c_str());
+ if (!res.empty())
+ {
+ std::sort(res.begin(), res.end());
+ results.push_back(res);
+ }
+ }
+ std::map<std::vector<std::string>, size_t> counter;
+ for (const auto &e: results)
+ counter[e]++;
+ size_t count = 0;
+ for (const auto &e: counter)
+ count = std::max(count, e.second);
+ if (results.size() > 1)
+ {
+ if (count < results.size())
+ MERROR("Only " << count << "/" << results.size() << " records match");
+ else
+ MINFO(count << "/" << results.size() << " records match");
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ TRY_ENTRY();
+
+ tools::on_startup();
+
+ po::options_description desc_cmd_only("Command line options");
+ po::options_description desc_cmd_sett("Command line options and settings options");
+
+ command_line::add_arg(desc_cmd_only, command_line::arg_help);
+
+ po::options_description desc_options("Allowed options");
+ desc_options.add(desc_cmd_only).add(desc_cmd_sett);
+
+ po::variables_map vm;
+ bool r = command_line::handle_error_helper(desc_options, [&]()
+ {
+ po::store(po::parse_command_line(argc, argv, desc_options), vm);
+ po::notify(vm);
+ return true;
+ });
+ if (! r)
+ return 1;
+
+ if (command_line::get_arg(vm, command_line::arg_help))
+ {
+ std::cout << "Monero '" << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")" << ENDL << ENDL;
+ std::cout << desc_options << std::endl;
+ return 1;
+ }
+
+ mlog_configure("", true);
+ mlog_set_categories("+" MONERO_DEFAULT_LOG_CATEGORY ":INFO");
+
+ lookup(LOOKUP_A, {"seeds.moneroseeds.se", "seeds.moneroseeds.ae.org", "seeds.moneroseeds.ch", "seeds.moneroseeds.li"});
+
+ lookup(LOOKUP_TXT, {"updates.moneropulse.org", "updates.moneropulse.net", "updates.moneropulse.co", "updates.moneropulse.se"});
+
+ lookup(LOOKUP_TXT, {"checkpoints.moneropulse.org", "checkpoints.moneropulse.net", "checkpoints.moneropulse.co", "checkpoints.moneropulse.se"});
+
+ // those are in the code, but don't seem to actually exist
+#if 0
+ lookup(LOOKUP_TXT, {"testpoints.moneropulse.org", "testpoints.moneropulse.net", "testpoints.moneropulse.co", "testpoints.moneropulse.se");
+
+ lookup(LOOKUP_TXT, {"stagenetpoints.moneropulse.org", "stagenetpoints.moneropulse.net", "stagenetpoints.moneropulse.co", "stagenetpoints.moneropulse.se"});
+#endif
+
+ lookup(LOOKUP_TXT, {"segheights.moneropulse.org", "segheights.moneropulse.net", "segheights.moneropulse.co", "segheights.moneropulse.se"});
+
+ return 0;
+ CATCH_ENTRY_L0("main", 1);
+}