From d4dde24034d7467883b290111da60527ab8048f8 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:07:36 +0300 Subject: net: Add CNode::m_inbound_onion data member --- src/net.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index 1051511f54..e702c13db3 100644 --- a/src/net.h +++ b/src/net.h @@ -253,6 +253,7 @@ public: LOCK(cs_vAddedNodes); vAddedNodes = connOptions.m_added_nodes; } + m_onion_binds = connOptions.onion_binds; } CConnman(uint64_t seed0, uint64_t seed1, bool network_active = true); @@ -586,6 +587,12 @@ private: std::atomic m_next_send_inv_to_incoming{0}; + /** + * A vector of -bind=
:=onion arguments each of which is + * an address and port that are designated for incoming Tor connections. + */ + std::vector m_onion_binds; + friend struct CConnmanTest; friend struct ConnmanTestMsg; }; @@ -1035,7 +1042,7 @@ public: std::set orphan_work_set; - CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress &addrBindIn, const std::string &addrNameIn, ConnectionType conn_type_in); + CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, 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(); CNode(const CNode&) = delete; CNode& operator=(const CNode&) = delete; @@ -1073,6 +1080,10 @@ private: // Our address, as reported by the peer CService addrLocal GUARDED_BY(cs_addrLocal); mutable RecursiveMutex cs_addrLocal; + + //! Whether this peer connected via our Tor onion service. + const bool m_inbound_onion{false}; + public: NodeId GetId() const { -- cgit v1.2.3 From 49fba9c1aa699d3aa47ea4dafe07b47c8d0aac6e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:19:19 +0300 Subject: net: Add CNode::ConnectedThroughNetwork member function --- src/net.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index e702c13db3..a8b13124c3 100644 --- a/src/net.h +++ b/src/net.h @@ -961,6 +961,18 @@ public: assert(false); } + /** + * Get network the peer connected through. + * + * Returns Network::NET_ONION for *inbound* onion connections, + * and CNetAddr::GetNetClass() otherwise. The latter cannot be used directly + * because it doesn't detect the former, and it's not the responsibility of + * the CNetAddr class to know the actual network a peer is connected through. + * + * @return network the peer connected through. + */ + Network ConnectedThroughNetwork() const; + protected: mapMsgCmdSize mapSendBytesPerMsgCmd; mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv); -- cgit v1.2.3