Changeset View
Changeset View
Standalone View
Standalone View
src/torcontrol.cpp
Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | static bool WriteBinaryFile(const fs::path &filename, const std::string &data) { | ||||
fclose(f); | fclose(f); | ||||
return true; | return true; | ||||
} | } | ||||
/****** Bitcoin specific TorController implementation ********/ | /****** Bitcoin specific TorController implementation ********/ | ||||
/** | /** | ||||
* Controller that connects to Tor control socket, authenticate, then create | * Controller that connects to Tor control socket, authenticate, then create | ||||
* and maintain an ephemeral hidden service. | * and maintain an ephemeral onion service. | ||||
*/ | */ | ||||
class TorController { | class TorController { | ||||
public: | public: | ||||
TorController(struct event_base *base, const std::string &target); | TorController(struct event_base *base, const std::string &target); | ||||
~TorController(); | ~TorController(); | ||||
/** Get name fo file to store private key in */ | /** Get name fo file to store private key in */ | ||||
fs::path GetPrivateKeyFile(); | fs::path GetPrivateKeyFile(); | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | if (reply.code == 250) { | ||||
} | } | ||||
// Finally - now create the service | // Finally - now create the service | ||||
// No private key, generate one | // No private key, generate one | ||||
if (private_key.empty()) { | if (private_key.empty()) { | ||||
// Explicitly request key type - see issue #9214 | // Explicitly request key type - see issue #9214 | ||||
private_key = "NEW:ED25519-V3"; | private_key = "NEW:ED25519-V3"; | ||||
} | } | ||||
// Request hidden service, redirect port. | // Request onion service, redirect port. | ||||
// Note that the 'virtual' port doesn't have to be the same as our | // Note that the 'virtual' port doesn't have to be the same as our | ||||
// internal port, but this is just a convenient choice. TODO; refactor | // internal port, but this is just a convenient choice. TODO; refactor | ||||
// the shutdown sequence some day. | // the shutdown sequence some day. | ||||
_conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", | _conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", | ||||
private_key, Params().GetDefaultPort(), | private_key, Params().GetDefaultPort(), | ||||
GetListenPort()), | GetListenPort()), | ||||
std::bind(&TorController::add_onion_cb, this, | std::bind(&TorController::add_onion_cb, this, | ||||
std::placeholders::_1, std::placeholders::_2)); | std::placeholders::_1, std::placeholders::_2)); | ||||
▲ Show 20 Lines • Show All 291 Lines • Show Last 20 Lines |