update rootless app

This commit is contained in:
eventlOwOp
2024-07-02 13:43:54 +08:00
parent 19e9c26f59
commit e2c0c3a515
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ class AuthedClient {
late Future<AuthedClientInner> client;
Future<AuthedClientInner> loadSecret() async {
final path = (await getApplicationDocumentsDirectory()).path;
final file = File('$path/authtoken');
final file = File('$path/run/authtoken');
final token = await file.readAsString();
return AuthedClientInner(token.trim(), http.Client());
+6 -3
View File
@@ -5,6 +5,7 @@ import 'dart:developer' as developer;
import 'package:flutter/services.dart';
import './authed_client.dart';
import 'package:path_provider/path_provider.dart';
void main() {
runApp(const MyApp());
@@ -40,8 +41,10 @@ class MyHomePage extends StatefulWidget {
State<MyHomePage> createState() => _MyHomePageState();
}
Future zerotierCommand(String command) {
return Process.run('echo', [command, '>/data/data/com.eventlowop.zerotier_magisk_app/files/pipe']);
Future<void> zerotierCommand(String command) async {
final path = (await getApplicationDocumentsDirectory()).path;
final file = File('$path/run/pipe');
await file.writeAsString(command);
}
class _MyHomePageState extends State<MyHomePage> {
@@ -72,7 +75,7 @@ class _MyHomePageState extends State<MyHomePage> {
});
}
void joinNetwork(String id) async {
Future<void> joinNetwork(String id) async {
final client = await authed.client;
final resp = await client.put(Uri.http('localhost:9993', 'network/$id'));
if (resp.statusCode != 200) {