diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/dns_utils.cpp | 54 | ||||
-rw-r--r-- | src/common/dns_utils.h | 8 | ||||
-rw-r--r-- | src/common/scoped_message_writer.h | 2 | ||||
-rw-r--r-- | src/common/stack_trace.cpp | 5 | ||||
-rw-r--r-- | src/common/stack_trace.h | 1 | ||||
-rw-r--r-- | src/common/updates.cpp | 1 | ||||
-rw-r--r-- | src/common/util.h | 9 |
7 files changed, 14 insertions, 66 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index ab38cbbae..e7ff11c5c 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -26,12 +26,9 @@ // 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 "common/command_line.h" -#include "common/i18n.h" #include "common/dns_utils.h" +#include "common/i18n.h" #include "cryptonote_basic/cryptonote_basic_impl.h" -#include <cstring> -#include <sstream> // check local first (in the event of static or in-source compilation of libunbound) #include "unbound.h" @@ -307,12 +304,8 @@ DNSResolver& DNSResolver::instance() { boost::lock_guard<boost::mutex> lock(instance_lock); - static DNSResolver* staticInstance = NULL; - if (staticInstance == NULL) - { - staticInstance = new DNSResolver(); - } - return *staticInstance; + static DNSResolver staticInstance; + return staticInstance; } DNSResolver DNSResolver::create() @@ -405,7 +398,7 @@ std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec return addresses; } -std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, bool cli_confirm) +std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm) { // attempt to get address from dns query auto addresses = addresses_from_url(url, dnssec_valid); @@ -414,44 +407,7 @@ std::string get_account_address_as_str_from_url(const std::string& url, bool& dn LOG_ERROR("wrong address: " << url); return {}; } - // for now, move on only if one address found - if (addresses.size() > 1) - { - LOG_ERROR("not yet supported: Multiple Monero addresses found for given URL: " << url); - return {}; - } - if (!cli_confirm) - return addresses[0]; - // prompt user for confirmation. - // inform user of DNSSEC validation status as well. - std::string dnssec_str; - if (dnssec_valid) - { - dnssec_str = tr("DNSSEC validation passed"); - } - else - { - dnssec_str = tr("WARNING: DNSSEC validation was unsuccessful, this address may not be correct!"); - } - std::stringstream prompt; - prompt << tr("For URL: ") << url - << ", " << dnssec_str << std::endl - << tr(" Monero Address = ") << addresses[0] - << std::endl - << tr("Is this OK? (Y/n) ") - ; - // prompt the user for confirmation given the dns query and dnssec status - std::string confirm_dns_ok = command_line::input_line(prompt.str()); - if (std::cin.eof()) - { - return {}; - } - if (!command_line::is_yes(confirm_dns_ok)) - { - std::cout << tr("you have cancelled the transfer request") << std::endl; - return {}; - } - return addresses[0]; + return dns_confirm(url, addresses, dnssec_valid); } namespace diff --git a/src/common/dns_utils.h b/src/common/dns_utils.h index 53c0c1c7b..f19584516 100644 --- a/src/common/dns_utils.h +++ b/src/common/dns_utils.h @@ -29,7 +29,7 @@ #include <vector> #include <string> -#include "cryptonote_basic/cryptonote_basic.h" +#include <functional> namespace tools { @@ -101,7 +101,7 @@ public: * * @return A vector of strings containing a TXT record; or an empty vector */ - // TODO: modify this to accomodate DNSSEC + // TODO: modify this to accommodate DNSSEC std::vector<std::string> get_txt_record(const std::string& url, bool& dnssec_available, bool& dnssec_valid); /** @@ -142,7 +142,7 @@ private: * * @return A vector of strings containing the requested record; or an empty vector */ - // TODO: modify this to accomodate DNSSEC + // TODO: modify this to accommodate DNSSEC std::vector<std::string> get_record(const std::string& url, int record_type, std::string (*reader)(const char *,size_t), bool& dnssec_available, bool& dnssec_valid); /** @@ -163,7 +163,7 @@ namespace dns_utils std::string address_from_txt_record(const std::string& s); std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec_valid); -std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, bool cli_confirm = true); +std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> confirm_dns); bool load_txt_records_from_dns(std::vector<std::string> &records, const std::vector<std::string> &dns_urls); diff --git a/src/common/scoped_message_writer.h b/src/common/scoped_message_writer.h index 7ee4f1379..e31f8f0b2 100644 --- a/src/common/scoped_message_writer.h +++ b/src/common/scoped_message_writer.h @@ -91,7 +91,7 @@ public: { m_flush = false; - MCLOG(m_log_level, "msgwriter", m_oss.str()); + MCLOG_FILE(m_log_level, "msgwriter", m_oss.str()); if (epee::console_color_default == m_color) { diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp index ef64c20c5..6fdf4dd47 100644 --- a/src/common/stack_trace.cpp +++ b/src/common/stack_trace.cpp @@ -30,8 +30,7 @@ #define USE_UNWIND #endif -#include "common/stack_trace.h" -#include "misc_log_ex.h" +#include <stdexcept> #ifdef USE_UNWIND #define UNW_LOCAL_ONLY #include <libunwind.h> @@ -40,6 +39,8 @@ #ifndef STATICLIB #include <dlfcn.h> #endif +#include "common/stack_trace.h" +#include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "stacktrace" diff --git a/src/common/stack_trace.h b/src/common/stack_trace.h index 25eec9fb3..0f6bdc08b 100644 --- a/src/common/stack_trace.h +++ b/src/common/stack_trace.h @@ -29,7 +29,6 @@ #ifndef MONERO_EXCEPTION_H #define MONERO_EXCEPTION_H -#include <stdexcept> #include <string> namespace tools diff --git a/src/common/updates.cpp b/src/common/updates.cpp index 5b1acf5fa..8a057b1cf 100644 --- a/src/common/updates.cpp +++ b/src/common/updates.cpp @@ -26,6 +26,7 @@ // 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 "misc_log_ex.h" #include "util.h" #include "dns_utils.h" #include "updates.h" diff --git a/src/common/util.h b/src/common/util.h index 4291d7e18..2452bc9d5 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -40,7 +40,6 @@ #include <string> #include "crypto/hash.h" -#include "p2p/p2p_protocol_defs.h" /*! \brief Various Tools * @@ -108,14 +107,6 @@ namespace tools bool sanitize_locale(); - inline crypto::hash get_proof_of_trust_hash(const nodetool::proof_of_trust& pot) - { - std::string s; - s.append(reinterpret_cast<const char*>(&pot.peer_id), sizeof(pot.peer_id)); - s.append(reinterpret_cast<const char*>(&pot.time), sizeof(pot.time)); - return crypto::cn_fast_hash(s.data(), s.size()); - } - /*! \brief Defines a signal handler for win32 and *nix */ class signal_handler |