Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Low-level handling for Tor control connection. More...
Public Types | |
typedef std::function< void(TorControlConnection &)> | ConnectionCB |
typedef std::function< void(TorControlConnection &, const TorControlReply &)> | ReplyHandlerCB |
Public Member Functions | |
TorControlConnection (struct event_base *base) | |
Create a new TorControlConnection. More... | |
~TorControlConnection () | |
bool | Connect (const std::string &target, const ConnectionCB &connected, const ConnectionCB &disconnected) |
Connect to a Tor control port. More... | |
bool | Disconnect () |
Disconnect from Tor control port. More... | |
bool | Command (const std::string &cmd, const ReplyHandlerCB &reply_handler) |
Send a command, register a handler for the reply. More... | |
Public Attributes | |
boost::signals2::signal< void(TorControlConnection &, const TorControlReply &)> | async_handler |
Response handlers for async replies. More... | |
Static Private Member Functions | |
static void | readcb (struct bufferevent *bev, void *ctx) |
Libevent handlers: internal. More... | |
static void | eventcb (struct bufferevent *bev, short what, void *ctx) |
Private Attributes | |
std::function< void(TorControlConnection &)> | connected |
Callback when ready for use. More... | |
std::function< void(TorControlConnection &)> | disconnected |
Callback when connection lost. More... | |
struct event_base * | base |
Libevent event base. More... | |
struct bufferevent * | b_conn |
Connection to control socket. More... | |
TorControlReply | message |
Message being received. More... | |
std::deque< ReplyHandlerCB > | reply_handlers |
Response handlers. More... | |
Detailed Description
Low-level handling for Tor control connection.
Speaks the SMTP-like protocol as defined in torspec/control-spec.txt
Definition at line 71 of file torcontrol.cpp.
Member Typedef Documentation
◆ ConnectionCB
typedef std::function<void(TorControlConnection&)> TorControlConnection::ConnectionCB |
Definition at line 74 of file torcontrol.cpp.
◆ ReplyHandlerCB
typedef std::function<void(TorControlConnection &,const TorControlReply &)> TorControlConnection::ReplyHandlerCB |
Definition at line 75 of file torcontrol.cpp.
Constructor & Destructor Documentation
◆ TorControlConnection()
|
explicit |
Create a new TorControlConnection.
Definition at line 123 of file torcontrol.cpp.
◆ ~TorControlConnection()
TorControlConnection::~TorControlConnection | ( | ) |
Definition at line 128 of file torcontrol.cpp.
References b_conn.
Member Function Documentation
◆ Command()
bool TorControlConnection::Command | ( | const std::string & | cmd, |
const ReplyHandlerCB & | reply_handler | ||
) |
Send a command, register a handler for the reply.
A trailing CRLF is automatically added. Return true on success.
Definition at line 234 of file torcontrol.cpp.
References b_conn, and reply_handlers.
Referenced by TorController::auth_cb(), TorController::authchallenge_cb(), TorController::connected_cb(), and TorController::protocolinfo_cb().
◆ Connect()
bool TorControlConnection::Connect | ( | const std::string & | target, |
const ConnectionCB & | connected, | ||
const ConnectionCB & | disconnected | ||
) |
Connect to a Tor control port.
target is address of the form host:port. connected is the handler that is called when connection is successfully established. disconnected is a handler that is called when the connection is broken. Return true on success.
Definition at line 196 of file torcontrol.cpp.
References b_conn, base, connected, Disconnect(), disconnected, eventcb(), LogPrintf, and readcb().
Referenced by TorController::Reconnect(), and TorController::TorController().
◆ Disconnect()
bool TorControlConnection::Disconnect | ( | ) |
Disconnect from Tor control port.
Definition at line 226 of file torcontrol.cpp.
References b_conn.
Referenced by Connect().
◆ eventcb()
|
staticprivate |
Definition at line 179 of file torcontrol.cpp.
References ctx, LogPrint, and BCLog::TOR.
Referenced by Connect().
◆ readcb()
|
staticprivate |
Libevent handlers: internal.
Definition at line 134 of file torcontrol.cpp.
References atoi(), ctx, LogPrint, LogPrintf, MAX_LINE_LENGTH, and BCLog::TOR.
Referenced by Connect().
Member Data Documentation
◆ async_handler
boost::signals2::signal<void(TorControlConnection &,const TorControlReply &)> TorControlConnection::async_handler |
Response handlers for async replies.
Definition at line 103 of file torcontrol.cpp.
◆ b_conn
|
private |
Connection to control socket.
Definition at line 112 of file torcontrol.cpp.
Referenced by Command(), Connect(), Disconnect(), and ~TorControlConnection().
◆ base
|
private |
◆ connected
|
private |
Callback when ready for use.
Definition at line 106 of file torcontrol.cpp.
Referenced by Connect().
◆ disconnected
|
private |
Callback when connection lost.
Definition at line 108 of file torcontrol.cpp.
Referenced by Connect().
◆ message
|
private |
Message being received.
Definition at line 114 of file torcontrol.cpp.
◆ reply_handlers
|
private |
The documentation for this class was generated from the following file:
- src/torcontrol.cpp