![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include "torcontrol.h"
#include "utilstrencodings.h"
#include "netbase.h"
#include "net.h"
#include "util.h"
#include "crypto/hmac_sha256.h"
#include <vector>
#include <deque>
#include <set>
#include <stdlib.h>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/util.h>
#include <event2/event.h>
#include <event2/thread.h>
Go to the source code of this file.
Classes | |
class | TorControlReply |
class | TorControlConnection |
class | TorController |
Functions | |
static std::pair< std::string, std::string > | SplitTorReplyLine (const std::string &s) |
static std::map< std::string, std::string > | ParseTorReplyMapping (const std::string &s) |
static std::pair< bool, std::string > | ReadBinaryFile (const std::string &filename, size_t maxsize=std::numeric_limits< size_t >::max()) |
static bool | WriteBinaryFile (const std::string &filename, const std::string &data) |
static std::vector< uint8_t > | ComputeResponse (const std::string &key, const std::vector< uint8_t > &cookie, const std::vector< uint8_t > &clientNonce, const std::vector< uint8_t > &serverNonce) |
static void | TorControlThread () |
void | StartTorControl (boost::thread_group &threadGroup, CScheduler &scheduler) |
void | InterruptTorControl () |
void | StopTorControl () |
Variables | |
const std::string | DEFAULT_TOR_CONTROL = "127.0.0.1:9051" |
static const int | TOR_COOKIE_SIZE = 32 |
static const int | TOR_NONCE_SIZE = 32 |
static const std::string | TOR_SAFE_SERVERKEY = "Tor safe cookie authentication server-to-controller hash" |
static const std::string | TOR_SAFE_CLIENTKEY = "Tor safe cookie authentication controller-to-server hash" |
static const float | RECONNECT_TIMEOUT_START = 1.0 |
static const float | RECONNECT_TIMEOUT_EXP = 1.5 |
static const int | MAX_LINE_LENGTH = 100000 |
struct event_base * | base |
boost::thread | torControlThread |
|
static |
Compute Tor SAFECOOKIE response.
ServerHash is computed as: HMAC-SHA256("Tor safe cookie authentication server-to-controller hash", CookieString | ClientNonce | ServerNonce) (with the HMAC key as its first argument)
After a controller sends a successful AUTHCHALLENGE command, the next command sent on the connection must be an AUTHENTICATE command, and the only authentication string which that AUTHENTICATE command will accept is:
HMAC-SHA256("Tor safe cookie authentication controller-to-server hash", CookieString | ClientNonce | ServerNonce)
Definition at line 496 of file torcontrol.cpp.
Referenced by TorController::authchallenge_cb().
void InterruptTorControl | ( | ) |
Definition at line 686 of file torcontrol.cpp.
Referenced by Interrupt().
|
static |
Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'.
Definition at line 264 of file torcontrol.cpp.
Referenced by TorController::add_onion_cb(), TorController::authchallenge_cb(), and TorController::protocolinfo_cb().
|
static |
Read full contents of a file and return them in a std::string. Returns a pair <status, string>. If an error occurred, status will be false, otherwise status will be true and the data will be returned in string.
maxsize | Puts a maximum size limit on the file that is read. If the file is larger than this, truncated data (with len > maxsize) will be returned. |
Definition at line 312 of file torcontrol.cpp.
Referenced by TorController::protocolinfo_cb(), and TorController::TorController().
|
static |
Definition at line 249 of file torcontrol.cpp.
Referenced by TorController::authchallenge_cb(), and TorController::protocolinfo_cb().
void StartTorControl | ( | boost::thread_group & | threadGroup, |
CScheduler & | scheduler | ||
) |
Definition at line 669 of file torcontrol.cpp.
Referenced by AppInit2().
void StopTorControl | ( | ) |
Definition at line 694 of file torcontrol.cpp.
Referenced by Shutdown().
|
static |
Definition at line 662 of file torcontrol.cpp.
Referenced by StartTorControl().
|
static |
Write contents of std::string to a file.
Definition at line 332 of file torcontrol.cpp.
Referenced by TorController::add_onion_cb().
struct event_base* base |
Definition at line 659 of file torcontrol.cpp.
Referenced by CallRPC(), CKeePassIntegrator::doHTTPPost(), HTTPEvent::HTTPEvent(), InitHTTPServer(), InterruptTorControl(), TrafficGraphWidget::paintEvent(), StartTorControl(), StopTorControl(), ThreadHTTP(), and TorControlThread().
const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051" |
Default control port
Definition at line 29 of file torcontrol.cpp.
Referenced by HelpMessage(), and TorControlThread().
|
static |
Maximum length for lines received on TorControlConnection. tor-control-spec.txt mentions that there is explicitly no limit defined to line length, this is belt-and-suspenders sanity limit to prevent memory exhaustion.
Definition at line 46 of file torcontrol.cpp.
Referenced by TorControlConnection::readcb().
|
static |
Exponential backoff configuration - growth factor
Definition at line 41 of file torcontrol.cpp.
Referenced by TorController::disconnected_cb().
|
static |
Exponential backoff configuration - initial timeout in seconds
Definition at line 39 of file torcontrol.cpp.
Referenced by TorController::connected_cb().
|
static |
Tor cookie size (from control-spec.txt)
Definition at line 31 of file torcontrol.cpp.
Referenced by TorController::protocolinfo_cb().
|
static |
Size of client/server nonce for SAFECOOKIE
Definition at line 33 of file torcontrol.cpp.
Referenced by TorController::protocolinfo_cb().
|
static |
For computing clientHash in SAFECOOKIE
Definition at line 37 of file torcontrol.cpp.
Referenced by TorController::authchallenge_cb().
|
static |
For computing serverHash in SAFECOOKIE
Definition at line 35 of file torcontrol.cpp.
Referenced by TorController::authchallenge_cb().
boost::thread torControlThread |
Definition at line 660 of file torcontrol.cpp.
Referenced by StartTorControl(), and StopTorControl().