2023-08-08 16:01:45 +00:00
|
|
|
import 'package:flutter_libtor/flutter_libtor.dart';
|
2023-08-07 16:39:04 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:stackwallet/utilities/stack_file_system.dart';
|
|
|
|
|
2023-08-07 16:46:34 +00:00
|
|
|
final pTorService = Provider((_) => TorService.sharedInstance);
|
2023-08-07 16:39:04 +00:00
|
|
|
|
|
|
|
class TorService {
|
2023-08-07 16:46:34 +00:00
|
|
|
static final sharedInstance = TorService();
|
2023-08-07 16:39:04 +00:00
|
|
|
final _tor = Tor();
|
|
|
|
|
|
|
|
int get port => _tor.port;
|
|
|
|
|
|
|
|
Future<void> start() async {
|
|
|
|
final dir = await StackFileSystem.applicationTorDirectory();
|
2023-08-16 03:56:41 +00:00
|
|
|
await _tor.start(torDir: dir);
|
|
|
|
return;
|
2023-08-07 16:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> stop() async {
|
|
|
|
return await _tor.disable();
|
|
|
|
}
|
|
|
|
}
|