update rootless app
This commit is contained in:
@@ -27,7 +27,7 @@ class AuthedClient {
|
|||||||
late Future<AuthedClientInner> client;
|
late Future<AuthedClientInner> client;
|
||||||
Future<AuthedClientInner> loadSecret() async {
|
Future<AuthedClientInner> loadSecret() async {
|
||||||
final path = (await getApplicationDocumentsDirectory()).path;
|
final path = (await getApplicationDocumentsDirectory()).path;
|
||||||
final file = File('$path/authtoken');
|
final file = File('$path/run/authtoken');
|
||||||
final token = await file.readAsString();
|
final token = await file.readAsString();
|
||||||
|
|
||||||
return AuthedClientInner(token.trim(), http.Client());
|
return AuthedClientInner(token.trim(), http.Client());
|
||||||
|
|||||||
+6
-3
@@ -5,6 +5,7 @@ import 'dart:developer' as developer;
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import './authed_client.dart';
|
import './authed_client.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@@ -40,8 +41,10 @@ class MyHomePage extends StatefulWidget {
|
|||||||
State<MyHomePage> createState() => _MyHomePageState();
|
State<MyHomePage> createState() => _MyHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future zerotierCommand(String command) {
|
Future<void> zerotierCommand(String command) async {
|
||||||
return Process.run('echo', [command, '>/data/data/com.eventlowop.zerotier_magisk_app/files/pipe']);
|
final path = (await getApplicationDocumentsDirectory()).path;
|
||||||
|
final file = File('$path/run/pipe');
|
||||||
|
await file.writeAsString(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
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 client = await authed.client;
|
||||||
final resp = await client.put(Uri.http('localhost:9993', 'network/$id'));
|
final resp = await client.put(Uri.http('localhost:9993', 'network/$id'));
|
||||||
if (resp.statusCode != 200) {
|
if (resp.statusCode != 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user