mirror of
https://github.com/monero-project/monero.git
synced 2025-08-05 22:54:16 -04:00
Adding initial support for broadcasting transactions over Tor
- Support for ".onion" in --add-exclusive-node and --add-peer - Add --anonymizing-proxy for outbound Tor connections - Add --anonymous-inbounds for inbound Tor connections - Support for sharing ".onion" addresses over Tor connections - Support for broadcasting transactions received over RPC exclusively over Tor (else broadcast over public IP when Tor not enabled).
This commit is contained in:
parent
1e5cd3b35a
commit
973403bc9f
39 changed files with 4298 additions and 831 deletions
|
@ -103,7 +103,7 @@ namespace net_utils
|
|||
// connection_basic_pimpl
|
||||
// ================================================================================================
|
||||
|
||||
connection_basic_pimpl::connection_basic_pimpl(const std::string &name) : m_throttle(name) { }
|
||||
connection_basic_pimpl::connection_basic_pimpl(const std::string &name) : m_throttle(name), m_peer_number(0) { }
|
||||
|
||||
// ================================================================================================
|
||||
// connection_basic
|
||||
|
@ -113,27 +113,31 @@ connection_basic_pimpl::connection_basic_pimpl(const std::string &name) : m_thro
|
|||
int connection_basic_pimpl::m_default_tos;
|
||||
|
||||
// methods:
|
||||
connection_basic::connection_basic(boost::asio::io_service& io_service, std::atomic<long> &ref_sock_count, std::atomic<long> &sock_number)
|
||||
:
|
||||
connection_basic::connection_basic(boost::asio::ip::tcp::socket&& socket, boost::shared_ptr<socket_stats> stats)
|
||||
:
|
||||
m_stats(std::move(stats)),
|
||||
mI( new connection_basic_pimpl("peer") ),
|
||||
strand_(io_service),
|
||||
socket_(io_service),
|
||||
strand_(socket.get_io_service()),
|
||||
socket_(std::move(socket)),
|
||||
m_want_close_connection(false),
|
||||
m_was_shutdown(false),
|
||||
m_ref_sock_count(ref_sock_count)
|
||||
{
|
||||
++ref_sock_count; // increase the global counter
|
||||
mI->m_peer_number = sock_number.fetch_add(1); // use, and increase the generated number
|
||||
m_was_shutdown(false)
|
||||
{
|
||||
// add nullptr checks if removed
|
||||
CHECK_AND_ASSERT_THROW_MES(bool(m_stats), "stats shared_ptr cannot be null");
|
||||
|
||||
++(m_stats->sock_count); // increase the global counter
|
||||
mI->m_peer_number = m_stats->sock_number.fetch_add(1); // use, and increase the generated number
|
||||
|
||||
std::string remote_addr_str = "?";
|
||||
try { boost::system::error_code e; remote_addr_str = socket_.remote_endpoint(e).address().to_string(); } catch(...){} ;
|
||||
|
||||
_note("Spawned connection p2p#"<<mI->m_peer_number<<" to " << remote_addr_str << " currently we have sockets count:" << m_ref_sock_count);
|
||||
_note("Spawned connection p2p#"<<mI->m_peer_number<<" to " << remote_addr_str << " currently we have sockets count:" << m_stats->sock_count);
|
||||
}
|
||||
|
||||
connection_basic::~connection_basic() noexcept(false) {
|
||||
--(m_stats->sock_count);
|
||||
|
||||
std::string remote_addr_str = "?";
|
||||
m_ref_sock_count--;
|
||||
try { boost::system::error_code e; remote_addr_str = socket_.remote_endpoint(e).address().to_string(); } catch(...){} ;
|
||||
_note("Destructing connection p2p#"<<mI->m_peer_number << " to " << remote_addr_str);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
namespace epee { namespace net_utils
|
||||
{
|
||||
const uint8_t ipv4_network_address::ID;
|
||||
|
||||
bool ipv4_network_address::equal(const ipv4_network_address& other) const noexcept
|
||||
{ return is_same_host(other) && port() == other.port(); }
|
||||
|
||||
|
@ -58,20 +56,6 @@ namespace epee { namespace net_utils
|
|||
return self_->is_same_host(*other_self);
|
||||
}
|
||||
|
||||
bool create_network_address(network_address &address, const std::string &string, uint16_t default_port)
|
||||
{
|
||||
uint32_t ip;
|
||||
uint16_t port;
|
||||
if (epee::string_tools::parse_peer_from_string(ip, port, string))
|
||||
{
|
||||
if (default_port && !port)
|
||||
port = default_port;
|
||||
address = ipv4_network_address{ip, port};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string print_connection_context(const connection_context_base& ctx)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
@ -86,5 +70,31 @@ namespace epee { namespace net_utils
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
const char* zone_to_string(zone value) noexcept
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case zone::public_:
|
||||
return "public";
|
||||
case zone::i2p:
|
||||
return "i2p";
|
||||
case zone::tor:
|
||||
return "tor";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
zone zone_from_string(const boost::string_ref value) noexcept
|
||||
{
|
||||
if (value == "public")
|
||||
return zone::public_;
|
||||
if (value == "i2p")
|
||||
return zone::i2p;
|
||||
if (value == "tor")
|
||||
return zone::tor;
|
||||
return zone::invalid;
|
||||
}
|
||||
}}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue