update zerotier module to support rootless app

This commit is contained in:
eventlOwOp
2024-07-02 12:25:20 +08:00
parent 7394eee0f0
commit fa2d60e1b8
11 changed files with 271 additions and 104 deletions
+6 -3
View File
@@ -1,5 +1,6 @@
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart';
class AuthedClientInner extends http.BaseClient {
final String _secret;
@@ -25,9 +26,11 @@ class AuthedClientInner extends http.BaseClient {
class AuthedClient {
late Future<AuthedClientInner> client;
Future<AuthedClientInner> loadSecret() async {
final results = await Process.run(
'su', ['-c', 'cat', '/data/adb/zerotier/home/authtoken.secret']);
return AuthedClientInner(results.stdout.toString().trim(), http.Client());
final path = (await getApplicationDocumentsDirectory()).path;
final file = File('$path/authtoken');
final token = await file.readAsString();
return AuthedClientInner(token.trim(), http.Client());
}
AuthedClient() {