MCPcopy Create free account
hub / github.com/ElementsProject/elements / add_onion_cb

Method add_onion_cb

src/torcontrol.cpp:341–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlReply& reply)
342{
343 if (reply.code == 250) {
344 LogPrint(BCLog::TOR, "tor: ADD_ONION successful\n");
345 for (const std::string &s : reply.lines) {
346 std::map<std::string,std::string> m = ParseTorReplyMapping(s);
347 std::map<std::string,std::string>::iterator i;
348 if ((i = m.find("ServiceID")) != m.end())
349 service_id = i->second;
350 if ((i = m.find("PrivateKey")) != m.end())
351 private_key = i->second;
352 }
353 if (service_id.empty()) {
354 LogPrintf("tor: Error parsing ADD_ONION parameters:\n");
355 for (const std::string &s : reply.lines) {
356 LogPrintf(" %s\n", SanitizeString(s));
357 }
358 return;
359 }
360 service = LookupNumeric(std::string(service_id+".onion"), Params().GetDefaultPort());
361 LogPrintf("tor: Got service ID %s, advertising service %s\n", service_id, service.ToString());
362 if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) {
363 LogPrint(BCLog::TOR, "tor: Cached service private key to %s\n", fs::PathToString(GetPrivateKeyFile()));
364 } else {
365 LogPrintf("tor: Error writing service private key to %s\n", fs::PathToString(GetPrivateKeyFile()));
366 }
367 AddLocal(service, LOCAL_MANUAL);
368 // ... onion requested - keep connection open
369 } else if (reply.code == 510) { // 510 Unrecognized command
370 LogPrintf("tor: Add onion failed with unrecognized command (You probably need to upgrade Tor)\n");
371 } else {
372 LogPrintf("tor: Add onion failed; error code %d\n", reply.code);
373 }
374}
375
376void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply& reply)
377{

Callers 1

FUZZ_TARGET_INITFunction · 0.80

Calls 12

ParseTorReplyMappingFunction · 0.85
SanitizeStringFunction · 0.85
LookupNumericFunction · 0.85
WriteBinaryFileFunction · 0.85
PathToStringFunction · 0.85
AddLocalFunction · 0.85
findMethod · 0.80
GetDefaultPortMethod · 0.80
ParamsClass · 0.70
endMethod · 0.45
emptyMethod · 0.45
ToStringMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.64