aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/dns_utils.cpp21
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp3
-rw-r--r--src/daemon/command_parser_executor.cpp7
-rw-r--r--src/daemon/command_server.cpp2
-rw-r--r--src/daemon/rpc_command_executor.cpp2
-rw-r--r--src/p2p/net_node.inl8
-rw-r--r--src/p2p/net_peerlist_boost_serialization.h23
-rw-r--r--src/p2p/p2p_protocol_defs.h6
-rw-r--r--src/rpc/core_rpc_server.cpp9
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h3
-rw-r--r--src/serialization/json_object.cpp1
-rw-r--r--src/simplewallet/simplewallet.cpp11
12 files changed, 65 insertions, 31 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index 9c306505e..1310b8bfd 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -443,19 +443,28 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
std::uniform_int_distribution<int> dis(0, dns_urls.size() - 1);
size_t first_index = dis(gen);
- bool avail, valid;
+ // send all requests in parallel
+ std::vector<boost::thread> threads(dns_urls.size());
+ std::deque<bool> avail(dns_urls.size(), false), valid(dns_urls.size(), false);
+ for (size_t n = 0; n < dns_urls.size(); ++n)
+ {
+ threads[n] = boost::thread([n, dns_urls, &records, &avail, &valid](){
+ records[n] = tools::DNSResolver::instance().get_txt_record(dns_urls[n], avail[n], valid[n]);
+ });
+ }
+ for (size_t n = 0; n < dns_urls.size(); ++n)
+ threads[n].join();
+
size_t cur_index = first_index;
do
{
- std::string url = dns_urls[cur_index];
-
- records[cur_index] = tools::DNSResolver::instance().get_txt_record(url, avail, valid);
- if (!avail)
+ const std::string &url = dns_urls[cur_index];
+ if (!avail[cur_index])
{
records[cur_index].clear();
LOG_PRINT_L2("DNSSEC not available for checkpoint update at URL: " << url << ", skipping.");
}
- if (!valid)
+ if (!valid[cur_index])
{
records[cur_index].clear();
LOG_PRINT_L2("DNSSEC validation failed for checkpoint update at URL: " << url << ", skipping.");
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 57347fdbc..c1a5ae324 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1298,11 +1298,12 @@ namespace cryptonote
bool core::check_updates()
{
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);
+ static const char subdir[] = "cli"; // because it can never be simple
#else
static const char buildtag[] = "source";
+ static const char subdir[] = "source"; // because it can never be simple
#endif
if (check_updates_level == UPDATES_DISABLED)
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 395157869..af46453cd 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -125,12 +125,17 @@ bool t_command_parser_executor::print_blockchain_info(const std::vector<std::str
bool t_command_parser_executor::set_log_level(const std::vector<std::string>& args)
{
- if(args.size() != 1)
+ if(args.size() > 1)
{
std::cout << "use: set_log [<log_level_number_0-4> | <categories>]" << std::endl;
return true;
}
+ if (args.empty())
+ {
+ return m_executor.set_log_categories("+");
+ }
+
uint16_t l = 0;
if(epee::string_tools::get_xtype_from_string(l, args[0]))
{
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index b9f503c6b..3f1543857 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -141,7 +141,7 @@ t_command_server::t_command_server(
m_command_lookup.set_handler(
"set_log"
, std::bind(&t_command_parser_executor::set_log_level, &m_parser, p::_1)
- , "set_log <level>|<categories> - Change current loglevel, <level> is a number 0-4"
+ , "set_log <level>|<{+,-,}categories> - Change current log level/categories, <level> is a number 0-4"
);
m_command_lookup.set_handler(
"diff"
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 3cd32ec2f..ef593237c 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -599,7 +599,7 @@ bool t_rpc_command_executor::set_log_categories(const std::string &categories) {
}
}
- tools::success_msg_writer() << "Log categories are now " << categories;
+ tools::success_msg_writer() << "Log categories are now " << res.categories;
return true;
}
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f1ca50f76..6162d649b 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -390,7 +390,7 @@ namespace nodetool
ip::tcp::endpoint endpoint = *i;
if (endpoint.address().is_v4())
{
- epee::net_utils::network_address na(new epee::net_utils::ipv4_network_address(boost::asio::detail::socket_ops::host_to_network_long(endpoint.address().to_v4().to_ulong()), endpoint.port()));
+ epee::net_utils::network_address na{epee::net_utils::ipv4_network_address{boost::asio::detail::socket_ops::host_to_network_long(endpoint.address().to_v4().to_ulong()), endpoint.port()}};
seed_nodes.push_back(na);
MINFO("Added seed node: " << na.str());
}
@@ -1521,7 +1521,7 @@ namespace nodetool
return false;
std::string ip = epee::string_tools::get_ip_string_from_int32(actual_ip);
std::string port = epee::string_tools::num_to_string_fast(node_data.my_port);
- epee::net_utils::network_address address(new epee::net_utils::ipv4_network_address(actual_ip, node_data.my_port));
+ epee::net_utils::network_address address{epee::net_utils::ipv4_network_address(actual_ip, node_data.my_port)};
peerid_type pr = node_data.peer_id;
bool r = m_net_server.connect_async(ip, port, m_config.m_net_config.ping_connection_timeout, [cb, /*context,*/ address, pr, this](
const typename net_server::t_connection_context& ping_context,
@@ -1669,7 +1669,7 @@ namespace nodetool
if(arg.node_data.peer_id != m_config.m_peer_id && arg.node_data.my_port)
{
peerid_type peer_id_l = arg.node_data.peer_id;
- uint32_t port_l = arg.node_data.my_port;
+ uint32_t port_l = arg.node_data.my_port;
//try ping to be sure that we can add this peer to peer_list
try_ping(arg.node_data, context, [peer_id_l, port_l, context, this]()
{
@@ -1678,7 +1678,7 @@ namespace nodetool
//called only(!) if success pinged, update local peerlist
peerlist_entry pe;
const epee::net_utils::network_address na = context.m_remote_address;
- pe.adr.reset(new epee::net_utils::ipv4_network_address(na.as<epee::net_utils::ipv4_network_address>().ip(), port_l));
+ pe.adr = epee::net_utils::ipv4_network_address(na.as<epee::net_utils::ipv4_network_address>().ip(), port_l);
time_t last_seen;
time(&last_seen);
pe.last_seen = static_cast<int64_t>(last_seen);
diff --git a/src/p2p/net_peerlist_boost_serialization.h b/src/p2p/net_peerlist_boost_serialization.h
index 6ea2d48fd..079524aa1 100644
--- a/src/p2p/net_peerlist_boost_serialization.h
+++ b/src/p2p/net_peerlist_boost_serialization.h
@@ -31,11 +31,19 @@
#pragma once
#include "net/net_utils_base.h"
+#include "p2p/p2p_protocol_defs.h"
namespace boost
{
namespace serialization
{
+ template <class T, class Archive>
+ inline void do_serialize(Archive &a, epee::net_utils::network_address& na, T local)
+ {
+ if (typename Archive::is_saving()) local = na.as<T>();
+ a & local;
+ if (!typename Archive::is_saving()) na = local;
+ }
template <class Archive, class ver_type>
inline void serialize(Archive &a, epee::net_utils::network_address& na, const ver_type ver)
{
@@ -46,10 +54,8 @@ namespace boost
switch (type)
{
case epee::net_utils::ipv4_network_address::ID:
- if (!typename Archive::is_saving())
- na.reset(new epee::net_utils::ipv4_network_address(0, 0));
- a & na.as<epee::net_utils::ipv4_network_address>();
- break;
+ do_serialize(a, na, epee::net_utils::ipv4_network_address{0, 0});
+ break;
default:
throw std::runtime_error("Unsupported network address type");
}
@@ -57,13 +63,14 @@ namespace boost
template <class Archive, class ver_type>
inline void serialize(Archive &a, epee::net_utils::ipv4_network_address& na, const ver_type ver)
{
- a & na.m_ip;
- a & na.m_port;
+ uint32_t ip{na.ip()};
+ uint16_t port{na.port()};
+ a & ip;
+ a & port;
if (!typename Archive::is_saving())
- na.init_ids();
+ na = epee::net_utils::ipv4_network_address{ip, port};
}
-
template <class Archive, class ver_type>
inline void serialize(Archive &a, nodetool::peerlist_entry& pl, const ver_type ver)
{
diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h
index f2b2cd1da..d49d83989 100644
--- a/src/p2p/p2p_protocol_defs.h
+++ b/src/p2p/p2p_protocol_defs.h
@@ -120,7 +120,7 @@ namespace nodetool
ss << std::setfill ('0') << std::setw (8) << std::hex << std::noshowbase;
for(const peerlist_entry& pe: pl)
{
- ss << pe.id << "\t" << pe.adr->str() << " \tlast_seen: " << epee::misc_utils::get_time_interval_string(now_time - pe.last_seen) << std::endl;
+ ss << pe.id << "\t" << pe.adr.str() << " \tlast_seen: " << epee::misc_utils::get_time_interval_string(now_time - pe.last_seen) << std::endl;
}
return ss.str();
}
@@ -216,7 +216,7 @@ namespace nodetool
std::list<peerlist_entry_base<network_address_old>> local_peerlist;
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
for (const auto &p: local_peerlist)
- ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({new epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen}));
+ ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen}));
}
}
END_KV_SERIALIZE_MAP()
@@ -275,7 +275,7 @@ namespace nodetool
std::list<peerlist_entry_base<network_address_old>> local_peerlist;
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
for (const auto &p: local_peerlist)
- ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({new epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen}));
+ ((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen}));
}
}
END_KV_SERIALIZE_MAP()
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 9730cdf46..b9678f414 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -831,6 +831,7 @@ namespace cryptonote
bool core_rpc_server::on_set_log_categories(const COMMAND_RPC_SET_LOG_CATEGORIES::request& req, COMMAND_RPC_SET_LOG_CATEGORIES::response& res)
{
mlog_set_log(req.categories.c_str());
+ res.categories = mlog_get_categories();
res.status = CORE_RPC_STATUS_OK;
return true;
}
@@ -1394,7 +1395,7 @@ namespace cryptonote
}
else
{
- na.reset(new epee::net_utils::ipv4_network_address(i->ip, 0));
+ na = epee::net_utils::ipv4_network_address{i->ip, 0};
}
if (i->ban)
m_p2p.block_host(na, i->seconds);
@@ -1618,8 +1619,10 @@ namespace cryptonote
static const char software[] = "monero";
#ifdef BUILD_TAG
static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
+ static const char subdir[] = "cli";
#else
static const char buildtag[] = "source";
+ static const char subdir[] = "source";
#endif
if (req.command != "check" && req.command != "download" && req.command != "update")
@@ -1642,8 +1645,8 @@ namespace cryptonote
}
res.update = true;
res.version = version;
- res.user_uri = tools::get_update_url(software, "cli", buildtag, version, true);
- res.auto_uri = tools::get_update_url(software, "cli", buildtag, version, false);
+ res.user_uri = tools::get_update_url(software, subdir, buildtag, version, true);
+ res.auto_uri = tools::get_update_url(software, subdir, buildtag, version, false);
res.hash = hash;
if (req.command == "check")
{
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index ecf546bb0..85ac2ca30 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -981,8 +981,11 @@ namespace cryptonote
struct response
{
std::string status;
+ std::string categories;
+
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(status)
+ KV_SERIALIZE(categories)
END_KV_SERIALIZE_MAP()
};
};
diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp
index e35389f9c..a40821d19 100644
--- a/src/serialization/json_object.cpp
+++ b/src/serialization/json_object.cpp
@@ -776,6 +776,7 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::tx_in_pool& tx)
GET_FROM_JSON_OBJECT(val, tx.receive_time, receive_time);
GET_FROM_JSON_OBJECT(val, tx.last_relayed_time, last_relayed_time);
GET_FROM_JSON_OBJECT(val, tx.relayed, relayed);
+ GET_FROM_JSON_OBJECT(val, tx.do_not_relay, do_not_relay);
}
void toJsonValue(rapidjson::Document& doc, const cryptonote::rpc::hard_fork_info& info, rapidjson::Value& val)
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 13ed911f7..314670327 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -784,7 +784,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("donate", boost::bind(&simple_wallet::donate, this, _1), tr("donate [<ring_size>] <amount> [payment_id] - Donate <amount> to the development team (donate.getmonero.org)"));
m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this, _1), tr("Sign a transaction from a file"));
m_cmd_binder.set_handler("submit_transfer", boost::bind(&simple_wallet::submit_transfer, this, _1), tr("Submit a signed transaction from a file"));
- m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level>|<categories> - Change current log detail (level must be <0-4>)"));
+ m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level>|{+,-,}<categories> - Change current log detail (level must be <0-4>)"));
m_cmd_binder.set_handler("address", boost::bind(&simple_wallet::print_address, this, _1), tr("Show current wallet public address"));
m_cmd_binder.set_handler("integrated_address", boost::bind(&simple_wallet::print_integrated_address, this, _1), tr("integrated_address [PID] - Encode a payment ID into an integrated address for the current wallet public address (no argument uses a random payment ID), or decode an integrated address to standard address and payment ID"));
m_cmd_binder.set_handler("address_book", boost::bind(&simple_wallet::address_book, this, _1), tr("address_book [(add (<address> [pid <long or short payment id>])|<integrated address> [<description possibly with whitespaces>])|(delete <index>)] - Print all entries in the address book, optionally adding/deleting an entry to/from it"));
@@ -895,12 +895,14 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
//----------------------------------------------------------------------------------------------------
bool simple_wallet::set_log(const std::vector<std::string> &args)
{
- if(args.size() != 1)
+ if(args.size() > 1)
{
fail_msg_writer() << tr("usage: set_log <log_level_number_0-4> | <categories>");
return true;
}
- mlog_set_log(args[0].c_str());
+ if (!args.empty())
+ mlog_set_log(args[0].c_str());
+ success_msg_writer() << "New log categories: " << mlog_get_categories();
return true;
}
//----------------------------------------------------------------------------------------------------
@@ -1444,6 +1446,9 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
}
catch (const std::exception &e) { }
+ if (!m_trusted_daemon)
+ message_writer() << (boost::format(tr("Warning: using an untrusted daemon at %s, privacy will be lessened")) % m_wallet->get_daemon_address()).str();
+
m_http_client.set_server(m_wallet->get_daemon_address(), m_wallet->get_daemon_login());
m_wallet->callback(this);