| 555 | } |
| 556 | |
| 557 | void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply& reply) |
| 558 | { |
| 559 | if (reply.code == TOR_REPLY_OK) { |
| 560 | LogDebug(BCLog::TOR, "Authentication successful"); |
| 561 | |
| 562 | // Now that we know Tor is running setup the proxy for onion addresses |
| 563 | // if -onion isn't set to something else. |
| 564 | if (gArgs.GetArg("-onion", "") == "") { |
| 565 | _conn.Command("GETINFO net/listeners/socks", std::bind_front(&TorController::get_socks_cb, this)); |
| 566 | } |
| 567 | |
| 568 | // Finally - now create the service |
| 569 | if (m_private_key.empty()) { // No private key, generate one |
| 570 | m_private_key = "NEW:ED25519-V3"; // Explicitly request key type - see issue #9214 |
| 571 | } |
| 572 | // Request onion service, redirect port. |
| 573 | _conn.Command(MakeAddOnionCmd(m_private_key, m_target.ToStringAddrPort(), /*enable_pow=*/true), |
| 574 | [this](TorControlConnection& conn, const TorControlReply& reply) { |
| 575 | add_onion_cb(conn, reply, /*pow_was_enabled=*/true); |
| 576 | }); |
| 577 | } else { |
| 578 | LogWarning("tor: Authentication failed"); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | /** Compute Tor SAFECOOKIE response. |
| 583 | * |
no test coverage detected