Bitcoin Core 31.99.0
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TorController Class Reference

Controller that connects to Tor control socket, authenticate, then create and maintain an ephemeral onion service. More...

#include <torcontrol.h>

Collaboration diagram for TorController:
[legend]

Public Member Functions

 TorController (const std::string &tor_control_center, const CService &target)
 
 TorController ()
 
 ~TorController ()
 
fs::path GetPrivateKeyFile ()
 Get name of file to store private key in. More...
 
void Interrupt ()
 Interrupt the controller thread. More...
 
void Join ()
 Wait for the controller thread to exit. More...
 
void get_socks_cb (TorControlConnection &conn, const TorControlReply &reply)
 Callback for GETINFO net/listeners/socks result. More...
 
void add_onion_cb (TorControlConnection &conn, const TorControlReply &reply, bool pow_was_enabled)
 Callback for ADD_ONION result. More...
 
void auth_cb (TorControlConnection &conn, const TorControlReply &reply)
 Callback for AUTHENTICATE result. More...
 
void authchallenge_cb (TorControlConnection &conn, const TorControlReply &reply)
 Callback for AUTHCHALLENGE result. More...
 
void protocolinfo_cb (TorControlConnection &conn, const TorControlReply &reply)
 Callback for PROTOCOLINFO result. More...
 
void connected_cb (TorControlConnection &conn)
 Callback after successful connection. More...
 
void disconnected_cb (TorControlConnection &conn)
 Callback after connection lost or failed connection attempt. More...
 

Private Member Functions

void ThreadControl ()
 Main control thread. More...
 

Private Attributes

CThreadInterrupt m_interrupt
 
std::thread m_thread
 
const std::string m_tor_control_center
 
TorControlConnection m_conn
 
std::string m_private_key
 
std::string m_service_id
 
std::atomic< bool > m_reconnect
 
std::chrono::duration< double > m_reconnect_timeout
 
CService m_service
 
const CService m_target
 
std::vector< uint8_t > m_cookie
 Cookie for SAFECOOKIE auth. More...
 
std::vector< uint8_t > m_client_nonce
 ClientNonce for SAFECOOKIE auth. More...
 

Detailed Description

Controller that connects to Tor control socket, authenticate, then create and maintain an ephemeral onion service.

Definition at line 122 of file torcontrol.h.

Constructor & Destructor Documentation

◆ TorController() [1/2]

TorController::TorController ( const std::string &  tor_control_center,
const CService target 
)

Definition at line 352 of file torcontrol.cpp.

Here is the call graph for this function:

◆ TorController() [2/2]

TorController::TorController ( )
inline

Definition at line 126 of file torcontrol.h.

◆ ~TorController()

TorController::~TorController ( )

Definition at line 368 of file torcontrol.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ add_onion_cb()

void TorController::add_onion_cb ( TorControlConnection conn,
const TorControlReply reply,
bool  pow_was_enabled 
)

Callback for ADD_ONION result.

Definition at line 516 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ auth_cb()

void TorController::auth_cb ( TorControlConnection conn,
const TorControlReply reply 
)

Callback for AUTHENTICATE result.

Definition at line 557 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ authchallenge_cb()

void TorController::authchallenge_cb ( TorControlConnection conn,
const TorControlReply reply 
)

Callback for AUTHCHALLENGE result.

Definition at line 609 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connected_cb()

void TorController::connected_cb ( TorControlConnection conn)

Callback after successful connection.

Definition at line 724 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnected_cb()

void TorController::disconnected_cb ( TorControlConnection conn)

Callback after connection lost or failed connection attempt.

Definition at line 732 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_socks_cb()

void TorController::get_socks_cb ( TorControlConnection conn,
const TorControlReply reply 
)

Callback for GETINFO net/listeners/socks result.

Definition at line 435 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPrivateKeyFile()

fs::path TorController::GetPrivateKeyFile ( )

Get name of file to store private key in.

Definition at line 745 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Interrupt()

void TorController::Interrupt ( )

Interrupt the controller thread.

Definition at line 377 of file torcontrol.cpp.

Here is the caller graph for this function:

◆ Join()

void TorController::Join ( )

Wait for the controller thread to exit.

Definition at line 383 of file torcontrol.cpp.

Here is the caller graph for this function:

◆ protocolinfo_cb()

void TorController::protocolinfo_cb ( TorControlConnection conn,
const TorControlReply reply 
)

Callback for PROTOCOLINFO result.

Definition at line 648 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThreadControl()

void TorController::ThreadControl ( )
private

Main control thread.

Definition at line 390 of file torcontrol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_client_nonce

std::vector<uint8_t> TorController::m_client_nonce
private

ClientNonce for SAFECOOKIE auth.

Definition at line 153 of file torcontrol.h.

◆ m_conn

TorControlConnection TorController::m_conn
private

Definition at line 143 of file torcontrol.h.

◆ m_cookie

std::vector<uint8_t> TorController::m_cookie
private

Cookie for SAFECOOKIE auth.

Definition at line 151 of file torcontrol.h.

◆ m_interrupt

CThreadInterrupt TorController::m_interrupt
private

Definition at line 140 of file torcontrol.h.

◆ m_private_key

std::string TorController::m_private_key
private

Definition at line 144 of file torcontrol.h.

◆ m_reconnect

std::atomic<bool> TorController::m_reconnect
private

Definition at line 146 of file torcontrol.h.

◆ m_reconnect_timeout

std::chrono::duration<double> TorController::m_reconnect_timeout
private

Definition at line 147 of file torcontrol.h.

◆ m_service

CService TorController::m_service
private

Definition at line 148 of file torcontrol.h.

◆ m_service_id

std::string TorController::m_service_id
private

Definition at line 145 of file torcontrol.h.

◆ m_target

const CService TorController::m_target
private

Definition at line 149 of file torcontrol.h.

◆ m_thread

std::thread TorController::m_thread
private

Definition at line 141 of file torcontrol.h.

◆ m_tor_control_center

const std::string TorController::m_tor_control_center
private

Definition at line 142 of file torcontrol.h.


The documentation for this class was generated from the following files: