aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/updates.cpp15
-rw-r--r--src/common/updates.h4
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp9
-rw-r--r--src/wallet/api/wallet_manager.cpp28
-rw-r--r--src/wallet/wallet2_api.h3
5 files changed, 46 insertions, 13 deletions
diff --git a/src/common/updates.cpp b/src/common/updates.cpp
index c84566f57..5b1acf5fa 100644
--- a/src/common/updates.cpp
+++ b/src/common/updates.cpp
@@ -35,7 +35,7 @@
namespace tools
{
- bool check_updates(const std::string &software, const std::string &buildtag, bool testnet, std::string &version, std::string &hash)
+ bool check_updates(const std::string &software, const std::string &buildtag, std::string &version, std::string &hash)
{
std::vector<std::string> records;
bool found = false;
@@ -44,12 +44,13 @@ namespace tools
// All four MoneroPulse domains have DNSSEC on and valid
static const std::vector<std::string> dns_urls = {
+ "updates.moneropulse.org",
+ "updates.moneropulse.net",
+ "updates.moneropulse.co",
+ "updates.moneropulse.se"
};
- static const std::vector<std::string> testnet_dns_urls = { "testver.moneropulse.net"
- };
-
- if (!tools::dns_utils::load_txt_records_from_dns(records, testnet ? testnet_dns_urls : dns_urls))
+ if (!tools::dns_utils::load_txt_records_from_dns(records, dns_urls))
return false;
for (const auto& record : records)
@@ -94,9 +95,9 @@ namespace tools
return found;
}
- std::string get_update_url(const std::string &software, const std::string &subdir, const std::string &buildtag, const std::string &version)
+ std::string get_update_url(const std::string &software, const std::string &subdir, const std::string &buildtag, const std::string &version, bool user)
{
- static const char base[] = "https://updates.getmonero.org/";
+ const char *base = user ? "https://downloads.getmonero.org/" : "http://updates.getmonero.org/";
#ifdef _WIN32
static const char extension[] = ".zip";
#else
diff --git a/src/common/updates.h b/src/common/updates.h
index 1a70e06fd..e494ed7ac 100644
--- a/src/common/updates.h
+++ b/src/common/updates.h
@@ -32,6 +32,6 @@
namespace tools
{
- bool check_updates(const std::string &software, const std::string &buildtag, bool bestnet, std::string &version, std::string &hash);
- std::string get_update_url(const std::string &software, const std::string &subdir, const std::string &buildtag, const std::string &version);
+ bool check_updates(const std::string &software, const std::string &buildtag, std::string &version, std::string &hash);
+ std::string get_update_url(const std::string &software, const std::string &subdir, const std::string &buildtag, const std::string &version, bool user);
}
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index c96389ac7..98c53890e 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1088,7 +1088,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
bool core::check_updates()
{
- static const char software[] = "monerod";
+ static const char software[] = "monero";
static const char subdir[] = "cli"; // because it can never be simple
#ifdef BUILD_TAG
static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
@@ -1101,18 +1101,19 @@ namespace cryptonote
std::string version, hash;
MCDEBUG("updates", "Checking for a new " << software << " version for " << buildtag);
- if (!tools::check_updates(software, buildtag, m_testnet, version, hash))
+ if (!tools::check_updates(software, buildtag, version, hash))
return false;
if (tools::vercmp(version.c_str(), MONERO_VERSION) <= 0)
return true;
- std::string url = tools::get_update_url(software, subdir, buildtag, version);
+ std::string url = tools::get_update_url(software, subdir, buildtag, version, true);
MGINFO("Version " << version << " of " << software << " for " << buildtag << " is available: " << url << ", SHA256 hash " << hash);
if (check_updates_level == UPDATES_NOTIFY)
return true;
+ url = tools::get_update_url(software, subdir, buildtag, version, false);
std::string filename;
const char *slash = strrchr(url.c_str(), '/');
if (slash)
@@ -1141,7 +1142,7 @@ namespace cryptonote
MCERROR("updates", "Download from " << url << " does not match the expected hash");
return false;
}
- MCINFO("updates", "New version downloaded to " << path);
+ MGINFO("New version downloaded to " << path);
}
else
{
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 38f24e3d9..359b57349 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -33,11 +33,16 @@
#include "wallet.h"
#include "common_defines.h"
#include "common/dns_utils.h"
+#include "common/util.h"
+#include "common/updates.h"
+#include "version.h"
#include "net/http_client.h"
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "WalletAPI"
namespace epee {
unsigned int g_test_dbg_lock_sleep = 0;
@@ -443,6 +448,29 @@ std::string WalletManagerImpl::resolveOpenAlias(const std::string &address, bool
return addresses.front();
}
+std::tuple<bool, std::string, std::string, std::string, std::string> WalletManager::checkUpdates(const std::string &software, const std::string &subdir)
+{
+#ifdef BUILD_TAG
+ static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
+#else
+ static const char buildtag[] = "source";
+#endif
+
+ std::string version, hash;
+ MDEBUG("Checking for a new " << software << " version for " << buildtag);
+ if (!tools::check_updates(software, buildtag, version, hash))
+ return std::make_tuple(false, "", "", "", "");
+
+ if (tools::vercmp(version.c_str(), MONERO_VERSION) > 0)
+ {
+ std::string user_url = tools::get_update_url(software, subdir, buildtag, version, true);
+ std::string auto_url = tools::get_update_url(software, subdir, buildtag, version, false);
+ MGINFO("Version " << version << " of " << software << " for " << buildtag << " is available: " << user_url << ", SHA256 hash " << hash);
+ return std::make_tuple(true, version, hash, user_url, auto_url);
+ }
+ return std::make_tuple(false, "", "", "", "");
+}
+
///////////////////// WalletManagerFactory implementation //////////////////////
WalletManager *WalletManagerFactory::getWalletManager()
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 3a819444a..eec4f8b8f 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -703,6 +703,9 @@ struct WalletManager
//! resolves an OpenAlias address to a monero address
virtual std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const = 0;
+
+ //! checks for an update and returns version, hash and url
+ static std::tuple<bool, std::string, std::string, std::string, std::string> checkUpdates(const std::string &software, const std::string &subdir);
};