mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#21167: make CNode::m_inbound_onion public, initialize explicitly
This commit is contained in:
parent
a8cfd70587
commit
2b65526818
@ -530,7 +530,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||
if (!addr_bind.IsValid()) {
|
||||
addr_bind = GetBindAddress(sock->Get());
|
||||
}
|
||||
CNode* pnode = new CNode(id, nLocalServices, sock->Release(), addrConnect, CalculateKeyedNetGroup(addrConnect), nonce, addr_bind, pszDest ? pszDest : "", conn_type);
|
||||
CNode* pnode = new CNode(id, nLocalServices, sock->Release(), addrConnect, CalculateKeyedNetGroup(addrConnect), nonce, addr_bind, pszDest ? pszDest : "", conn_type, /* inbound_onion */ false);
|
||||
pnode->AddRef();
|
||||
statsClient.inc("peers.connect", 1.0f);
|
||||
|
||||
@ -4018,12 +4018,12 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const
|
||||
: nTimeConnected(GetTimeSeconds()),
|
||||
addr(addrIn),
|
||||
addrBind(addrBindIn),
|
||||
m_inbound_onion(inbound_onion),
|
||||
nKeyedNetGroup(nKeyedNetGroupIn),
|
||||
id(idIn),
|
||||
nLocalHostNonce(nLocalHostNonceIn),
|
||||
m_conn_type(conn_type_in),
|
||||
nLocalServices(nLocalServicesIn),
|
||||
m_inbound_onion(inbound_onion)
|
||||
nLocalServices(nLocalServicesIn)
|
||||
{
|
||||
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
|
||||
hSocket = hSocketIn;
|
||||
|
@ -471,6 +471,8 @@ public:
|
||||
const CAddress addr;
|
||||
// Bind address of our side of the connection
|
||||
const CAddress addrBind;
|
||||
//! Whether this peer is an inbound onion, i.e. connected via our Tor onion service.
|
||||
const bool m_inbound_onion;
|
||||
std::atomic<int> nNumWarningsSkipped{0};
|
||||
std::atomic<int> nVersion{0};
|
||||
/**
|
||||
@ -621,7 +623,7 @@ public:
|
||||
|
||||
bool IsBlockRelayOnly() const;
|
||||
|
||||
CNode(NodeId id, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in, bool inbound_onion = false);
|
||||
CNode(NodeId id, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in, bool inbound_onion);
|
||||
~CNode();
|
||||
CNode(const CNode&) = delete;
|
||||
CNode& operator=(const CNode&) = delete;
|
||||
@ -698,8 +700,6 @@ public:
|
||||
m_min_ping_time = std::min(m_min_ping_time.load(), ping_time);
|
||||
}
|
||||
|
||||
/** Whether this peer is an inbound onion, e.g. connected via our Tor onion service. */
|
||||
bool IsInboundOnion() const { return m_inbound_onion; }
|
||||
std::string GetLogString() const;
|
||||
|
||||
bool CanRelay() const { return !m_masternode_connection || m_masternode_iqr_connection; }
|
||||
@ -776,9 +776,6 @@ private:
|
||||
CService addrLocal GUARDED_BY(cs_addrLocal);
|
||||
mutable RecursiveMutex cs_addrLocal;
|
||||
|
||||
//! Whether this peer is an inbound onion, e.g. connected via our Tor onion service.
|
||||
const bool m_inbound_onion{false};
|
||||
|
||||
// Challenge sent in VERSION to be answered with MNAUTH (only happens between MNs)
|
||||
mutable Mutex cs_mnauth;
|
||||
uint256 sentMNAuthChallenge GUARDED_BY(cs_mnauth);
|
||||
|
@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||
|
||||
// Mock an outbound peer
|
||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
|
||||
CNode dummyNode1(id++, ServiceFlags(NODE_NETWORK), INVALID_SOCKET, addr1, 0, 0, CAddress(), "", ConnectionType::OUTBOUND_FULL_RELAY);
|
||||
CNode dummyNode1(id++, ServiceFlags(NODE_NETWORK), INVALID_SOCKET, addr1, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress(), /* pszDest */ "", ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false);
|
||||
dummyNode1.SetCommonVersion(PROTOCOL_VERSION);
|
||||
|
||||
peerLogic->InitializeNode(&dummyNode1);
|
||||
@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||
static void AddRandomOutboundPeer(std::vector<CNode*>& vNodes, PeerManager& peerLogic, ConnmanTestMsg& connman)
|
||||
{
|
||||
CAddress addr(ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE);
|
||||
vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK), INVALID_SOCKET, addr, 0, 0, CAddress(), "", ConnectionType::OUTBOUND_FULL_RELAY));
|
||||
vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK), INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress(), /* pszDest */ "", ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false));
|
||||
CNode &node = *vNodes.back();
|
||||
node.SetCommonVersion(PROTOCOL_VERSION);
|
||||
|
||||
@ -220,7 +220,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
|
||||
banman->ClearBanned();
|
||||
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
|
||||
CNode dummyNode1(id++, NODE_NETWORK, INVALID_SOCKET, addr1, 0, 0, CAddress(), "", ConnectionType::INBOUND);
|
||||
CNode dummyNode1(id++, NODE_NETWORK, INVALID_SOCKET, addr1, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress(), /* pszDest */ "", ConnectionType::INBOUND, /* inbound_onion */ false);
|
||||
dummyNode1.SetCommonVersion(PROTOCOL_VERSION);
|
||||
peerLogic->InitializeNode(&dummyNode1);
|
||||
dummyNode1.fSuccessfullyConnected = true;
|
||||
@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
BOOST_CHECK(!banman->IsDiscouraged(ip(0xa0b0c001|0x0000ff00))); // Different IP, not discouraged
|
||||
|
||||
CAddress addr2(ip(0xa0b0c002), NODE_NONE);
|
||||
CNode dummyNode2(id++, NODE_NETWORK, INVALID_SOCKET, addr2, 1, 1, CAddress(), "", ConnectionType::INBOUND);
|
||||
CNode dummyNode2(id++, NODE_NETWORK, INVALID_SOCKET, addr2, /* nKeyedNetGroupIn */ 1, /* nLocalHostNonceIn */ 1, CAddress(), /* pszDest */ "", ConnectionType::INBOUND, /* inbound_onion */ false);
|
||||
dummyNode2.SetCommonVersion(PROTOCOL_VERSION);
|
||||
peerLogic->InitializeNode(&dummyNode2);
|
||||
dummyNode2.fSuccessfullyConnected = true;
|
||||
@ -271,7 +271,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
SetMockTime(nStartTime); // Overrides future calls to GetTime()
|
||||
|
||||
CAddress addr(ip(0xa0b0c001), NODE_NONE);
|
||||
CNode dummyNode(id++, NODE_NETWORK, INVALID_SOCKET, addr, 4, 4, CAddress(), "", ConnectionType::INBOUND);
|
||||
CNode dummyNode(id++, NODE_NETWORK, INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 4, /* nLocalHostNonceIn */ 4, CAddress(), /* pszDest */ "", ConnectionType::INBOUND, /* inbound_onion */ false);
|
||||
dummyNode.SetCommonVersion(PROTOCOL_VERSION);
|
||||
peerLogic->InitializeNode(&dummyNode);
|
||||
dummyNode.fSuccessfullyConnected = true;
|
||||
|
@ -194,14 +194,15 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||
id++, NODE_NETWORK, hSocket, addr,
|
||||
/* nKeyedNetGroupIn = */ 0,
|
||||
/* nLocalHostNonceIn = */ 0,
|
||||
CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY);
|
||||
CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY,
|
||||
/* inbound_onion = */ false);
|
||||
BOOST_CHECK(pnode1->IsFullOutboundConn() == true);
|
||||
BOOST_CHECK(pnode1->IsManualConn() == false);
|
||||
BOOST_CHECK(pnode1->IsBlockOnlyConn() == false);
|
||||
BOOST_CHECK(pnode1->IsFeelerConn() == false);
|
||||
BOOST_CHECK(pnode1->IsAddrFetchConn() == false);
|
||||
BOOST_CHECK(pnode1->IsInboundConn() == false);
|
||||
BOOST_CHECK(pnode1->IsInboundOnion() == false);
|
||||
BOOST_CHECK(pnode1->m_inbound_onion == false);
|
||||
BOOST_CHECK_EQUAL(pnode1->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||
|
||||
std::unique_ptr<CNode> pnode2 = std::make_unique<CNode>(
|
||||
@ -216,7 +217,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||
BOOST_CHECK(pnode2->IsFeelerConn() == false);
|
||||
BOOST_CHECK(pnode2->IsAddrFetchConn() == false);
|
||||
BOOST_CHECK(pnode2->IsInboundConn() == true);
|
||||
BOOST_CHECK(pnode2->IsInboundOnion() == false);
|
||||
BOOST_CHECK(pnode2->m_inbound_onion == false);
|
||||
BOOST_CHECK_EQUAL(pnode2->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||
|
||||
std::unique_ptr<CNode> pnode3 = std::make_unique<CNode>(
|
||||
@ -231,7 +232,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||
BOOST_CHECK(pnode3->IsFeelerConn() == false);
|
||||
BOOST_CHECK(pnode3->IsAddrFetchConn() == false);
|
||||
BOOST_CHECK(pnode3->IsInboundConn() == false);
|
||||
BOOST_CHECK(pnode3->IsInboundOnion() == false);
|
||||
BOOST_CHECK(pnode3->m_inbound_onion == false);
|
||||
BOOST_CHECK_EQUAL(pnode3->ConnectedThroughNetwork(), Network::NET_IPV4);
|
||||
|
||||
std::unique_ptr<CNode> pnode4 = std::make_unique<CNode>(
|
||||
@ -246,7 +247,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
|
||||
BOOST_CHECK(pnode4->IsFeelerConn() == false);
|
||||
BOOST_CHECK(pnode4->IsAddrFetchConn() == false);
|
||||
BOOST_CHECK(pnode4->IsInboundConn() == true);
|
||||
BOOST_CHECK(pnode4->IsInboundOnion() == true);
|
||||
BOOST_CHECK(pnode4->m_inbound_onion == true);
|
||||
BOOST_CHECK_EQUAL(pnode4->ConnectedThroughNetwork(), Network::NET_ONION);
|
||||
}
|
||||
|
||||
@ -740,7 +741,7 @@ BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test)
|
||||
in_addr ipv4AddrPeer;
|
||||
ipv4AddrPeer.s_addr = 0xa0b0c001;
|
||||
CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK);
|
||||
std::unique_ptr<CNode> pnode = std::make_unique<CNode>(0, NODE_NETWORK, INVALID_SOCKET, addr, 0, 0, CAddress{}, std::string{}, ConnectionType::OUTBOUND_FULL_RELAY);
|
||||
std::unique_ptr<CNode> pnode = std::make_unique<CNode>(0, NODE_NETWORK, INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress{}, /* pszDest */ std::string{}, ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false);
|
||||
pnode->fSuccessfullyConnected.store(true);
|
||||
|
||||
// the peer claims to be reaching us via IPv6
|
||||
|
Loading…
Reference in New Issue
Block a user