tor lifecycle management

This commit is contained in:
Fabian Freund
2025-03-16 20:55:33 +01:00
parent 6830d94bac
commit 9bc9c53559
10 changed files with 176 additions and 24 deletions
@@ -12,24 +12,28 @@ class StartProxyController extends _$StartProxyController {
// ignore: document_ignores is used for dialog
// ignore: avoid_build_context_in_providers
Future<void> maybeStartProxy(BuildContext context) async {
final torProxyRunning = ref.read(torProxyServiceProvider);
final torProxyRunning =
await ref.read(torProxyServiceProvider.notifier).requestSync();
if (torProxyRunning.valueOrNull == null) {
final result = await showDialog<bool>(
context: context,
builder: (context) {
return TorDialog();
},
);
if (torProxyRunning == null) {
if (context.mounted) {
final result = await showDialog<bool>(
context: context,
builder: (context) {
return TorDialog();
},
);
if (result == true) {
final connection = ref.read(torProxyServiceProvider.notifier).connect();
if (result == true) {
final connection =
ref.read(torProxyServiceProvider.notifier).connect();
ref
.read(overlayControllerProvider.notifier)
.show(Positioned(top: 0, left: 0, child: TorNotification()));
ref
.read(overlayControllerProvider.notifier)
.show(Positioned(top: 0, left: 0, child: TorNotification()));
await connection;
await connection;
}
}
}
}
@@ -7,7 +7,7 @@ part of 'start_tor_proxy.dart';
// **************************************************************************
String _$startProxyControllerHash() =>
r'7ba8d6eded4664a8aa3eb1360926c56e9185cac9';
r'b83cdc1b6d1c358a2042ff2b7cc2f19f82e5d5ed';
/// See also [StartProxyController].
@ProviderFor(StartProxyController)