basic tor service

This commit is contained in:
julian 2023-08-07 10:39:04 -06:00
parent dc9add8da3
commit 53b8adca16
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/utilities/stack_file_system.dart';
import 'package:tor/tor.dart';
final pTorService = Provider((_) => TorService());
class TorService {
final _tor = Tor();
int get port => _tor.port;
Future<void> start() async {
final dir = await StackFileSystem.applicationTorDirectory();
return await _tor.start(torDir: dir);
}
Future<void> stop() async {
return await _tor.disable();
}
}

View file

@ -60,6 +60,19 @@ abstract class StackFileSystem {
}
}
static Future<Directory> applicationTorDirectory() async {
final root = await applicationRootDirectory();
if (Util.isDesktop) {
final dir = Directory("${root.path}/tor");
if (!dir.existsSync()) {
await dir.create();
}
return dir;
} else {
return root;
}
}
static Future<Directory> applicationHiveDirectory() async {
final root = await applicationRootDirectory();
if (Util.isDesktop) {