mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-12 08:37:58 +02:00
refactor: Use std::bind_front over std::bind
This commit is contained in:
@@ -332,8 +332,8 @@ TorController::TorController(struct event_base* _base, const std::string& tor_co
|
||||
if (!reconnect_ev)
|
||||
LogWarning("tor: Failed to create event for reconnection: out of memory?");
|
||||
// Start connection attempts immediately
|
||||
if (!conn.Connect(m_tor_control_center, std::bind(&TorController::connected_cb, this, std::placeholders::_1),
|
||||
std::bind(&TorController::disconnected_cb, this, std::placeholders::_1) )) {
|
||||
if (!conn.Connect(m_tor_control_center, std::bind_front(&TorController::connected_cb, this),
|
||||
std::bind_front(&TorController::disconnected_cb, this) )) {
|
||||
LogWarning("tor: Initiating connection to Tor control port %s failed", m_tor_control_center);
|
||||
}
|
||||
// Read service private key if cached
|
||||
@@ -469,7 +469,7 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
|
||||
// Now that we know Tor is running setup the proxy for onion addresses
|
||||
// if -onion isn't set to something else.
|
||||
if (gArgs.GetArg("-onion", "") == "") {
|
||||
_conn.Command("GETINFO net/listeners/socks", std::bind(&TorController::get_socks_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
_conn.Command("GETINFO net/listeners/socks", std::bind_front(&TorController::get_socks_cb, this));
|
||||
}
|
||||
|
||||
// Finally - now create the service
|
||||
@@ -479,7 +479,7 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
|
||||
// Request onion service, redirect port.
|
||||
// Note that the 'virtual' port is always the default port to avoid decloaking nodes using other ports.
|
||||
_conn.Command(strprintf("ADD_ONION %s Port=%i,%s", private_key, Params().GetDefaultPort(), m_target.ToStringAddrPort()),
|
||||
std::bind(&TorController::add_onion_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
std::bind_front(&TorController::add_onion_cb, this));
|
||||
} else {
|
||||
LogWarning("tor: Authentication failed");
|
||||
}
|
||||
@@ -538,7 +538,7 @@ void TorController::authchallenge_cb(TorControlConnection& _conn, const TorContr
|
||||
}
|
||||
|
||||
std::vector<uint8_t> computedClientHash = ComputeResponse(TOR_SAFE_CLIENTKEY, cookie, clientNonce, serverNonce);
|
||||
_conn.Command("AUTHENTICATE " + HexStr(computedClientHash), std::bind(&TorController::auth_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
_conn.Command("AUTHENTICATE " + HexStr(computedClientHash), std::bind_front(&TorController::auth_cb, this));
|
||||
} else {
|
||||
LogWarning("tor: Invalid reply to AUTHCHALLENGE");
|
||||
}
|
||||
@@ -589,23 +589,23 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro
|
||||
if (methods.contains("HASHEDPASSWORD")) {
|
||||
LogDebug(BCLog::TOR, "Using HASHEDPASSWORD authentication\n");
|
||||
ReplaceAll(torpassword, "\"", "\\\"");
|
||||
_conn.Command("AUTHENTICATE \"" + torpassword + "\"", std::bind(&TorController::auth_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
_conn.Command("AUTHENTICATE \"" + torpassword + "\"", std::bind_front(&TorController::auth_cb, this));
|
||||
} else {
|
||||
LogWarning("tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available");
|
||||
}
|
||||
} else if (methods.contains("NULL")) {
|
||||
LogDebug(BCLog::TOR, "Using NULL authentication\n");
|
||||
_conn.Command("AUTHENTICATE", std::bind(&TorController::auth_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
_conn.Command("AUTHENTICATE", std::bind_front(&TorController::auth_cb, this));
|
||||
} else if (methods.contains("SAFECOOKIE")) {
|
||||
// Cookie: hexdump -e '32/1 "%02x""\n"' ~/.tor/control_auth_cookie
|
||||
LogDebug(BCLog::TOR, "Using SAFECOOKIE authentication, reading cookie authentication from %s\n", cookiefile);
|
||||
std::pair<bool,std::string> status_cookie = ReadBinaryFile(fs::PathFromString(cookiefile), TOR_COOKIE_SIZE);
|
||||
if (status_cookie.first && status_cookie.second.size() == TOR_COOKIE_SIZE) {
|
||||
// _conn.Command("AUTHENTICATE " + HexStr(status_cookie.second), std::bind(&TorController::auth_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
// _conn.Command("AUTHENTICATE " + HexStr(status_cookie.second), std::bind_front(&TorController::auth_cb, this));
|
||||
cookie = std::vector<uint8_t>(status_cookie.second.begin(), status_cookie.second.end());
|
||||
clientNonce = std::vector<uint8_t>(TOR_NONCE_SIZE, 0);
|
||||
GetRandBytes(clientNonce);
|
||||
_conn.Command("AUTHCHALLENGE SAFECOOKIE " + HexStr(clientNonce), std::bind(&TorController::authchallenge_cb, this, std::placeholders::_1, std::placeholders::_2));
|
||||
_conn.Command("AUTHCHALLENGE SAFECOOKIE " + HexStr(clientNonce), std::bind_front(&TorController::authchallenge_cb, this));
|
||||
} else {
|
||||
if (status_cookie.first) {
|
||||
LogWarning("tor: Authentication cookie %s is not exactly %i bytes, as is required by the spec", cookiefile, TOR_COOKIE_SIZE);
|
||||
@@ -627,7 +627,7 @@ void TorController::connected_cb(TorControlConnection& _conn)
|
||||
{
|
||||
reconnect_timeout = RECONNECT_TIMEOUT_START;
|
||||
// First send a PROTOCOLINFO command to figure out what authentication is expected
|
||||
if (!_conn.Command("PROTOCOLINFO 1", std::bind(&TorController::protocolinfo_cb, this, std::placeholders::_1, std::placeholders::_2)))
|
||||
if (!_conn.Command("PROTOCOLINFO 1", std::bind_front(&TorController::protocolinfo_cb, this)))
|
||||
LogWarning("tor: Error sending initial protocolinfo command");
|
||||
}
|
||||
|
||||
@@ -656,8 +656,8 @@ void TorController::Reconnect()
|
||||
/* Try to reconnect and reestablish if we get booted - for example, Tor
|
||||
* may be restarting.
|
||||
*/
|
||||
if (!conn.Connect(m_tor_control_center, std::bind(&TorController::connected_cb, this, std::placeholders::_1),
|
||||
std::bind(&TorController::disconnected_cb, this, std::placeholders::_1) )) {
|
||||
if (!conn.Connect(m_tor_control_center, std::bind_front(&TorController::connected_cb, this),
|
||||
std::bind_front(&TorController::disconnected_cb, this) )) {
|
||||
LogWarning("tor: Re-initiating connection to Tor control port %s failed", m_tor_control_center);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user