mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
basic tor service
This commit is contained in:
parent
dc9add8da3
commit
53b8adca16
2 changed files with 33 additions and 0 deletions
20
lib/networking/tor_service.dart
Normal file
20
lib/networking/tor_service.dart
Normal 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();
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue