torcontrol: Move tor controller into node context

Co-authored-by: sedited <seb.kung@gmail.com>
This commit is contained in:
Fabian Jahr
2026-03-13 15:19:48 +01:00
parent eae193e750
commit b1869e9a2d
5 changed files with 11 additions and 36 deletions

View File

@@ -276,7 +276,9 @@ void Interrupt(NodeContext& node)
InterruptHTTPRPC();
InterruptRPC();
InterruptREST();
InterruptTorControl();
if (node.tor_controller) {
node.tor_controller->Interrupt();
}
InterruptMapPort();
if (node.connman)
node.connman->Interrupt();
@@ -319,7 +321,10 @@ void Shutdown(NodeContext& node)
if (node.peerman && node.validation_signals) node.validation_signals->UnregisterValidationInterface(node.peerman.get());
if (node.connman) node.connman->Stop();
StopTorControl();
if (node.tor_controller) {
node.tor_controller->Join();
node.tor_controller.reset();
}
if (node.background_init_thread.joinable()) node.background_init_thread.join();
// After everything has been shut down, but before things get flushed, stop the
@@ -2187,7 +2192,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
"for the automatically created Tor onion service."),
onion_service_target.ToStringAddrPort()));
}
StartTorControl(onion_service_target);
node.tor_controller = std::make_unique<TorController>(gArgs.GetArg("-torcontrol", DEFAULT_TOR_CONTROL), onion_service_target);
}
if (connOptions.bind_on_any) {