mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 05:23:01 +01:00
torcontrol: Log invalid parameters in Tor reply strings where meaningful
This commit is contained in:
parent
0b6f40d4ca
commit
0182a11737
@ -267,6 +267,7 @@ static std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'.
|
/** Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'.
|
||||||
|
* Returns a map of keys to values, or an empty map if there was an error.
|
||||||
* Grammar is implicitly defined in https://spec.torproject.org/control-spec by
|
* Grammar is implicitly defined in https://spec.torproject.org/control-spec by
|
||||||
* the server reply formats for PROTOCOLINFO (S3.21), AUTHCHALLENGE (S3.24),
|
* the server reply formats for PROTOCOLINFO (S3.21), AUTHCHALLENGE (S3.24),
|
||||||
* and ADD_ONION (S3.27). See also sections 2.1 and 2.3.
|
* and ADD_ONION (S3.27). See also sections 2.1 and 2.3.
|
||||||
@ -450,6 +451,13 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe
|
|||||||
if ((i = m.find("PrivateKey")) != m.end())
|
if ((i = m.find("PrivateKey")) != m.end())
|
||||||
private_key = i->second;
|
private_key = i->second;
|
||||||
}
|
}
|
||||||
|
if (service_id.empty()) {
|
||||||
|
LogPrintf("tor: Error parsing ADD_ONION parameters:\n");
|
||||||
|
for (const std::string &s : reply.lines) {
|
||||||
|
LogPrintf(" %s\n", SanitizeString(s));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
service = LookupNumeric(std::string(service_id+".onion").c_str(), GetListenPort());
|
service = LookupNumeric(std::string(service_id+".onion").c_str(), GetListenPort());
|
||||||
LogPrintf("tor: Got service ID %s, advertising service %s\n", service_id, service.ToString());
|
LogPrintf("tor: Got service ID %s, advertising service %s\n", service_id, service.ToString());
|
||||||
if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) {
|
if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) {
|
||||||
@ -527,6 +535,10 @@ void TorController::authchallenge_cb(TorControlConnection& _conn, const TorContr
|
|||||||
std::pair<std::string,std::string> l = SplitTorReplyLine(reply.lines[0]);
|
std::pair<std::string,std::string> l = SplitTorReplyLine(reply.lines[0]);
|
||||||
if (l.first == "AUTHCHALLENGE") {
|
if (l.first == "AUTHCHALLENGE") {
|
||||||
std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
|
std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
|
||||||
|
if (m.empty()) {
|
||||||
|
LogPrintf("tor: Error parsing AUTHCHALLENGE parameters: %s\n", SanitizeString(l.second));
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::vector<uint8_t> serverHash = ParseHex(m["SERVERHASH"]);
|
std::vector<uint8_t> serverHash = ParseHex(m["SERVERHASH"]);
|
||||||
std::vector<uint8_t> serverNonce = ParseHex(m["SERVERNONCE"]);
|
std::vector<uint8_t> serverNonce = ParseHex(m["SERVERNONCE"]);
|
||||||
LogPrint(BCLog::TOR, "tor: AUTHCHALLENGE ServerHash %s ServerNonce %s\n", HexStr(serverHash), HexStr(serverNonce));
|
LogPrint(BCLog::TOR, "tor: AUTHCHALLENGE ServerHash %s ServerNonce %s\n", HexStr(serverHash), HexStr(serverNonce));
|
||||||
|
Loading…
Reference in New Issue
Block a user