Changeset View
Changeset View
Standalone View
Standalone View
src/torcontrol.cpp
// Copyright (c) 2015-2016 The Bitcoin Core developers | // Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017 The Zcash developers | // Copyright (c) 2017 The Zcash developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <chainparams.h> | |||||
#include <torcontrol.h> | #include <torcontrol.h> | ||||
#include <crypto/hmac_sha256.h> | #include <crypto/hmac_sha256.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
▲ Show 20 Lines • Show All 543 Lines • ▼ Show 20 Lines | if (reply.code == 250) { | ||||
if (service_id.empty()) { | if (service_id.empty()) { | ||||
LogPrintf("tor: Error parsing ADD_ONION parameters:\n"); | LogPrintf("tor: Error parsing ADD_ONION parameters:\n"); | ||||
for (const std::string &s : reply.lines) { | for (const std::string &s : reply.lines) { | ||||
LogPrintf(" %s\n", SanitizeString(s)); | LogPrintf(" %s\n", SanitizeString(s)); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
service = LookupNumeric(std::string(service_id + ".onion").c_str(), | service = LookupNumeric(std::string(service_id + ".onion").c_str(), | ||||
GetListenPort()); | Params().GetDefaultPort()); | ||||
LogPrintf("tor: Got service ID %s, advertising service %s\n", | LogPrintf("tor: Got service ID %s, advertising service %s\n", | ||||
service_id, service.ToString()); | service_id, service.ToString()); | ||||
if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) { | if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) { | ||||
LogPrint(BCLog::TOR, "tor: Cached service private key to %s\n", | LogPrint(BCLog::TOR, "tor: Cached service private key to %s\n", | ||||
GetPrivateKeyFile()); | GetPrivateKeyFile()); | ||||
} else { | } else { | ||||
LogPrintf("tor: Error writing service private key to %s\n", | LogPrintf("tor: Error writing service private key to %s\n", | ||||
GetPrivateKeyFile()); | GetPrivateKeyFile()); | ||||
Show All 28 Lines | if (reply.code == 250) { | ||||
// Explicitly request RSA1024 - see issue #9214 | // Explicitly request RSA1024 - see issue #9214 | ||||
private_key = "NEW:RSA1024"; | private_key = "NEW:RSA1024"; | ||||
} | } | ||||
// Request hidden service, redirect port. | // Request hidden 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, GetListenPort(), GetListenPort()), | private_key, Params().GetDefaultPort(), | ||||
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)); | ||||
} else { | } else { | ||||
LogPrintf("tor: Authentication failed\n"); | LogPrintf("tor: Authentication failed\n"); | ||||
} | } | ||||
} | } | ||||
/** Compute Tor SAFECOOKIE response. | /** Compute Tor SAFECOOKIE response. | ||||
▲ Show 20 Lines • Show All 285 Lines • Show Last 20 Lines |