aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api/utils.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-01-28 14:48:45 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-01-28 14:57:47 +0000
commit9bd9906e8f60439328ed9e125b2c65c5ce45bc1f (patch)
treedcc9fb06f8c8dfd033b0588969989a36c81f9875 /src/wallet/api/utils.cpp
parentMerge pull request #1618 (diff)
downloadmonero-9bd9906e8f60439328ed9e125b2c65c5ce45bc1f.tar.xz
Factor is_address_local code into a tools function
Diffstat (limited to 'src/wallet/api/utils.cpp')
-rw-r--r--src/wallet/api/utils.cpp38
1 files changed, 2 insertions, 36 deletions
diff --git a/src/wallet/api/utils.cpp b/src/wallet/api/utils.cpp
index 0d30b61cd..788d98f25 100644
--- a/src/wallet/api/utils.cpp
+++ b/src/wallet/api/utils.cpp
@@ -31,50 +31,16 @@
#include "include_base_utils.h" // LOG_PRINT_x
-#include "net/http_client.h" // epee::net_utils::...
-#include <boost/asio.hpp>
+#include "common/util.h"
using namespace std;
namespace Monero {
namespace Utils {
-
-// copy-pasted from simplewallet.
-
bool isAddressLocal(const std::string &address)
{
- // extract host
- epee::net_utils::http::url_content u_c;
- if (!epee::net_utils::parse_url(address, u_c))
- {
- LOG_PRINT_L1("Failed to determine whether daemon is local, assuming not");
- return false;
- }
- if (u_c.host.empty())
- {
- LOG_PRINT_L1("Failed to determine whether daemon is local, assuming not");
- return false;
- }
- // resolver::resolve can throw an exception
- try {
- // 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::query::canonical_name);
- boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);
- while (i != boost::asio::ip::tcp::resolver::iterator())
- {
- const boost::asio::ip::tcp::endpoint &ep = *i;
- if (ep.address().is_loopback())
- return true;
- ++i;
- }
- } catch (const boost::system::system_error &e) {
- LOG_ERROR("Failed to resolve " << address << ", :" << e.what());
- }
-
- return false;
+ return tools::is_local_address(address);
}
}