Changeset View
Changeset View
Standalone View
Standalone View
src/torcontrol.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | private: | ||||
std::deque<ReplyHandlerCB> reply_handlers; | std::deque<ReplyHandlerCB> reply_handlers; | ||||
/** Libevent handlers: internal */ | /** Libevent handlers: internal */ | ||||
static void readcb(struct bufferevent *bev, void *ctx); | static void readcb(struct bufferevent *bev, void *ctx); | ||||
static void eventcb(struct bufferevent *bev, short what, void *ctx); | static void eventcb(struct bufferevent *bev, short what, void *ctx); | ||||
}; | }; | ||||
TorControlConnection::TorControlConnection(struct event_base *_base) | TorControlConnection::TorControlConnection(struct event_base *_base) | ||||
: base(_base), b_conn(0) {} | : base(_base), b_conn(nullptr) {} | ||||
TorControlConnection::~TorControlConnection() { | TorControlConnection::~TorControlConnection() { | ||||
if (b_conn) { | if (b_conn) { | ||||
bufferevent_free(b_conn); | bufferevent_free(b_conn); | ||||
} | } | ||||
} | } | ||||
void TorControlConnection::readcb(struct bufferevent *bev, void *ctx) { | void TorControlConnection::readcb(struct bufferevent *bev, void *ctx) { | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | bool TorControlConnection::Connect(const std::string &target, | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool TorControlConnection::Disconnect() { | bool TorControlConnection::Disconnect() { | ||||
if (b_conn) { | if (b_conn) { | ||||
bufferevent_free(b_conn); | bufferevent_free(b_conn); | ||||
} | } | ||||
b_conn = 0; | b_conn = nullptr; | ||||
return true; | return true; | ||||
} | } | ||||
bool TorControlConnection::Command(const std::string &cmd, | bool TorControlConnection::Command(const std::string &cmd, | ||||
const ReplyHandlerCB &reply_handler) { | const ReplyHandlerCB &reply_handler) { | ||||
if (!b_conn) { | if (!b_conn) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | if (pkf.first) { | ||||
GetPrivateKeyFile()); | GetPrivateKeyFile()); | ||||
private_key = pkf.second; | private_key = pkf.second; | ||||
} | } | ||||
} | } | ||||
TorController::~TorController() { | TorController::~TorController() { | ||||
if (reconnect_ev) { | if (reconnect_ev) { | ||||
event_free(reconnect_ev); | event_free(reconnect_ev); | ||||
reconnect_ev = 0; | reconnect_ev = nullptr; | ||||
} | } | ||||
if (service.IsValid()) { | if (service.IsValid()) { | ||||
RemoveLocal(service); | RemoveLocal(service); | ||||
} | } | ||||
} | } | ||||
void TorController::add_onion_cb(TorControlConnection &_conn, | void TorController::add_onion_cb(TorControlConnection &_conn, | ||||
const TorControlReply &reply) { | const TorControlReply &reply) { | ||||
▲ Show 20 Lines • Show All 333 Lines • Show Last 20 Lines |