update zerotier module to support rootless app
This commit is contained in:
@@ -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() {
|
||||
|
||||
+5
-6
@@ -40,9 +40,8 @@ class MyHomePage extends StatefulWidget {
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
Future zerotierCommand(String exe, String command) {
|
||||
return Process.run('su', ['-c', '/data/adb/zerotier/$exe', command],
|
||||
environment: {'LD_LIBRARY_PATH': '/system/lib64:/data/adb/zerotier/lib'});
|
||||
Future zerotierCommand(String command) {
|
||||
return Process.run('echo', [command, '>/data/data/com.eventlowop.zerotier_magisk_app/files/pipe']);
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
@@ -125,9 +124,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
_MyHomePageState() : super() {
|
||||
restartFn =
|
||||
cmdButtonWrapper(() => zerotierCommand('zerotier.sh', 'restart'));
|
||||
startFn = cmdButtonWrapper(() => zerotierCommand('zerotier.sh', 'start'));
|
||||
stopFn = cmdButtonWrapper(() => zerotierCommand('zerotier.sh', 'stop'));
|
||||
cmdButtonWrapper(() => zerotierCommand('restart'));
|
||||
startFn = cmdButtonWrapper(() => zerotierCommand('start'));
|
||||
stopFn = cmdButtonWrapper(() => zerotierCommand('stop'));
|
||||
joinFn = cmdButtonWrapper(() => joinNetwork(_idInputController.text));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user