aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/p2p/net_node.h2
-rw-r--r--src/p2p/net_node.inl132
-rw-r--r--src/rpc/core_rpc_server.cpp1
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h4
-rw-r--r--src/wallet/wallet2.cpp17
5 files changed, 102 insertions, 54 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 87fec9994..b16f587c9 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -149,7 +149,7 @@ namespace nodetool
{
config_t()
: m_net_config(),
- m_peer_id(crypto::rand<uint64_t>()),
+ m_peer_id(1),
m_support_flags(0)
{}
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 2f47de0f0..3d8e31a20 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -71,6 +71,17 @@
#define MIN_WANTED_SEED_NODES 12
+static inline boost::asio::ip::address_v4 make_address_v4_from_v6(const boost::asio::ip::address_v6& a)
+{
+ const auto &bytes = a.to_bytes();
+ uint32_t v4 = 0;
+ v4 = (v4 << 8) | bytes[12];
+ v4 = (v4 << 8) | bytes[13];
+ v4 = (v4 << 8) | bytes[14];
+ v4 = (v4 << 8) | bytes[15];
+ return boost::asio::ip::address_v4(v4);
+}
+
namespace nodetool
{
template<class t_payload_net_handler>
@@ -128,7 +139,9 @@ namespace nodetool
if (storage)
m_peerlist_storage = std::move(*storage);
- m_network_zones[epee::net_utils::zone::public_].m_config.m_support_flags = P2P_SUPPORT_FLAGS;
+ network_zone& public_zone = m_network_zones[epee::net_utils::zone::public_];
+ public_zone.m_config.m_support_flags = P2P_SUPPORT_FLAGS;
+ public_zone.m_config.m_peer_id = crypto::rand<uint64_t>();
m_first_connection_maker_call = true;
CATCH_ENTRY_L0("node_server::init_config", false);
@@ -781,9 +794,21 @@ namespace nodetool
case epee::net_utils::zone::public_:
return get_dns_seed_nodes();
case epee::net_utils::zone::tor:
- return {};
+ if (m_nettype == cryptonote::MAINNET)
+ {
+ return {
+ "xwvz3ekocr3dkyxfkmgm2hvbpzx2ysqmaxgter7znnqrhoicygkfswid.onion:18083",
+ "4pixvbejrvihnkxmduo2agsnmc3rrulrqc7s3cbwwrep6h6hrzsibeqd.onion:18083"
+ };
+ }
case epee::net_utils::zone::i2p:
- return {};
+ if (m_nettype == cryptonote::MAINNET)
+ {
+ return {
+ "s3l6ke4ed3df466khuebb4poienoingwof7oxtbo6j4n56sghe3a.b32.i2p:18080",
+ "sel36x6fibfzujwvt4hf5gxolz6kd3jpvbjqg6o3ud2xtionyl2q.b32.i2p:18080"
+ };
+ }
default:
break;
}
@@ -1109,11 +1134,12 @@ namespace nodetool
pi = context.peer_id = rsp.node_data.peer_id;
context.m_rpc_port = rsp.node_data.rpc_port;
context.m_rpc_credits_per_hash = rsp.node_data.rpc_credits_per_hash;
- network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
+ const auto azone = context.m_remote_address.get_zone();
+ network_zone& zone = m_network_zones.at(azone);
zone.m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port, context.m_rpc_credits_per_hash);
// move
- if(rsp.node_data.peer_id == zone.m_config.m_peer_id)
+ if(azone == epee::net_utils::zone::public_ && rsp.node_data.peer_id == zone.m_config.m_peer_id)
{
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
hsh_result = false;
@@ -1205,50 +1231,51 @@ namespace nodetool
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::is_peer_used(const peerlist_entry& peer)
{
- for(const auto& zone : m_network_zones)
- if(zone.second.m_config.m_peer_id == peer.id)
- return true;//dont make connections to ourself
+ const auto zone = peer.adr.get_zone();
+ const auto server = m_network_zones.find(zone);
+ if (server == m_network_zones.end())
+ return false;
+
+ const bool is_public = (zone == epee::net_utils::zone::public_);
+ if(is_public && server->second.m_config.m_peer_id == peer.id)
+ return true;//dont make connections to ourself
bool used = false;
- for(auto& zone : m_network_zones)
+ server->second.m_net_server.get_config_object().foreach_connection([&, is_public](const p2p_connection_context& cntxt)
{
- zone.second.m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt)
+ if((is_public && cntxt.peer_id == peer.id) || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
{
- if(cntxt.peer_id == peer.id || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
- {
- used = true;
- return false;//stop enumerating
- }
- return true;
- });
-
- if(used)
- return true;
- }
- return false;
+ used = true;
+ return false;//stop enumerating
+ }
+ return true;
+ });
+ return used;
}
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::is_peer_used(const anchor_peerlist_entry& peer)
{
- for(auto& zone : m_network_zones) {
- if(zone.second.m_config.m_peer_id == peer.id) {
- return true;//dont make connections to ourself
- }
- bool used = false;
- zone.second.m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt)
+ const auto zone = peer.adr.get_zone();
+ const auto server = m_network_zones.find(zone);
+ if (server == m_network_zones.end())
+ return false;
+
+ const bool is_public = (zone == epee::net_utils::zone::public_);
+ if(is_public && server->second.m_config.m_peer_id == peer.id)
+ return true;//dont make connections to ourself
+
+ bool used = false;
+ server->second.m_net_server.get_config_object().foreach_connection([&, is_public](const p2p_connection_context& cntxt)
+ {
+ if((is_public && cntxt.peer_id == peer.id) || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
{
- if(cntxt.peer_id == peer.id || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
- {
- used = true;
- return false;//stop enumerating
- }
- return true;
- });
- if (used)
- return true;
- }
- return false;
+ used = true;
+ return false;//stop enumerating
+ }
+ return true;
+ });
+ return used;
}
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
@@ -1288,6 +1315,9 @@ namespace nodetool
if (zone.m_connect == nullptr) // outgoing connections in zone not possible
return false;
+ if (zone.m_our_address == na)
+ return false;
+
if (zone.m_current_number_of_out_peers == zone.m_config.m_net_config.max_out_connection_count) // out peers limit
{
return false;
@@ -1484,36 +1514,34 @@ namespace nodetool
const uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
classB.insert(actual_ip & 0x0000ffff);
}
-#if BOOST_VERSION > 106600
else if (cntxt.m_remote_address.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
{
const epee::net_utils::network_address na = cntxt.m_remote_address;
const boost::asio::ip::address_v6 &actual_ip = na.as<const epee::net_utils::ipv6_network_address>().ip();
if (actual_ip.is_v4_mapped())
{
- boost::asio::ip::address_v4 v4ip = make_address_v4(boost::asio::ip::v4_mapped, actual_ip);
+ boost::asio::ip::address_v4 v4ip = make_address_v4_from_v6(actual_ip);
uint32_t actual_ipv4;
memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
classB.insert(actual_ipv4 & ntohl(0xffff0000));
}
}
-#endif
return true;
});
}
auto get_host_string = [](const epee::net_utils::network_address &address) {
-#if BOOST_VERSION > 106600
if (address.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
{
boost::asio::ip::address_v6 actual_ip = address.as<const epee::net_utils::ipv6_network_address>().ip();
if (actual_ip.is_v4_mapped())
{
- boost::asio::ip::address_v4 v4ip = make_address_v4(boost::asio::ip::v4_mapped, actual_ip);
- return epee::net_utils::ipv4_network_address(v4ip.to_uint(), 0).host_str();
+ boost::asio::ip::address_v4 v4ip = make_address_v4_from_v6(actual_ip);
+ uint32_t actual_ipv4;
+ memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
+ return epee::net_utils::ipv4_network_address(actual_ipv4, 0).host_str();
}
}
-#endif
return address.host_str();
};
std::unordered_set<std::string> hosts_added;
@@ -1533,20 +1561,18 @@ namespace nodetool
uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
skip = classB.find(actual_ip & 0x0000ffff) != classB.end();
}
-#if BOOST_VERSION > 106600
else if (skip_duplicate_class_B && pe.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
{
const epee::net_utils::network_address na = pe.adr;
const boost::asio::ip::address_v6 &actual_ip = na.as<const epee::net_utils::ipv6_network_address>().ip();
if (actual_ip.is_v4_mapped())
{
- boost::asio::ip::address_v4 v4ip = make_address_v4(boost::asio::ip::v4_mapped, actual_ip);
+ boost::asio::ip::address_v4 v4ip = make_address_v4_from_v6(actual_ip);
uint32_t actual_ipv4;
memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
skip = classB.find(actual_ipv4 & ntohl(0xffff0000)) != classB.end();
}
}
-#endif
// consider each host once, to avoid giving undue inflence to hosts running several nodes
if (!skip)
@@ -1619,6 +1645,9 @@ namespace nodetool
peerid_to_string(pe.id) << " " << pe.adr.str() << ", pruning seed " << epee::string_tools::to_string_hex(pe.pruning_seed) <<
" (stripe " << next_needed_pruning_stripe << " needed)");
+ if(zone.m_our_address == pe.adr)
+ continue;
+
if(is_peer_used(pe)) {
_note("Peer is used");
continue;
@@ -2392,11 +2421,12 @@ namespace nodetool
return 1;
}
- network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
+ const auto azone = context.m_remote_address.get_zone();
+ network_zone& zone = m_network_zones.at(azone);
// test only the remote end's zone, otherwise an attacker could connect to you on clearnet
// and pass in a tor connection's peer id, and deduce the two are the same if you reject it
- if(arg.node_data.peer_id == zone.m_config.m_peer_id)
+ if(azone == epee::net_utils::zone::public_ && arg.node_data.peer_id == zone.m_config.m_peer_id)
{
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
drop_connection(context);
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 98e8e8c66..264a50040 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -498,6 +498,7 @@ namespace cryptonote
res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
res.update_available = restricted ? false : m_core.is_update_available();
res.version = restricted ? "" : MONERO_VERSION_FULL;
+ res.synchronized = check_core_ready();
res.status = CORE_RPC_STATUS_OK;
return true;
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 8748b0540..10f7aac7a 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -88,7 +88,7 @@ namespace cryptonote
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define CORE_RPC_VERSION_MAJOR 3
-#define CORE_RPC_VERSION_MINOR 2
+#define CORE_RPC_VERSION_MINOR 3
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
@@ -685,6 +685,7 @@ namespace cryptonote
uint64_t database_size;
bool update_available;
std::string version;
+ bool synchronized;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_PARENT(rpc_access_response_base)
@@ -724,6 +725,7 @@ namespace cryptonote
KV_SERIALIZE(database_size)
KV_SERIALIZE(update_available)
KV_SERIALIZE(version)
+ KV_SERIALIZE(synchronized)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<response_t> response;
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 30d06c20c..920e0413c 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -2962,7 +2962,8 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction,
MTRACE("update_pool_state got pool");
// remove any pending tx that's not in the pool
- constexpr const std::chrono::seconds tx_propagation_timeout{CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE * 3 / 2};
+ // TODO: set tx_propagation_timeout to CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE * 3 / 2 after v15 hardfork
+ constexpr const std::chrono::seconds tx_propagation_timeout{500};
const auto now = std::chrono::system_clock::now();
std::unordered_map<crypto::hash, wallet2::unconfirmed_transfer_details>::iterator it = m_unconfirmed_txs.begin();
while (it != m_unconfirmed_txs.end())
@@ -13402,6 +13403,20 @@ size_t wallet2::import_multisig(std::vector<cryptonote::blobdata> blobs)
loaded = true;
}
CHECK_AND_ASSERT_THROW_MES(loaded, "Failed to load output data");
+
+ for (const auto &e: i)
+ {
+ for (const auto &lr: e.m_LR)
+ {
+ CHECK_AND_ASSERT_THROW_MES(rct::isInMainSubgroup(lr.m_L), "Multisig value is not in the main subgroup");
+ CHECK_AND_ASSERT_THROW_MES(rct::isInMainSubgroup(lr.m_R), "Multisig value is not in the main subgroup");
+ }
+ for (const auto &ki: e.m_partial_key_images)
+ {
+ CHECK_AND_ASSERT_THROW_MES(rct::isInMainSubgroup(rct::ki2rct(ki)), "Multisig partial key image is not in the main subgroup");
+ }
+ }
+
MINFO(boost::format("%u outputs found") % boost::lexical_cast<std::string>(i.size()));
info.push_back(std::move(i));
}