diff --git a/README.md b/README.md index ec83c00..e2686ff 100644 --- a/README.md +++ b/README.md @@ -102,8 +102,6 @@ refer to `.github/workflow/build-{gcc|ndk}.yml` for detailed information. After 1.14.0, ZeroTierOne has introduce `multi-core concurrent packet processing`, which requires `pthread_setaffinity_np`. -However, `pthread_setaffinity_np` won't be available until API level 36, Android 16. (refer to https://android.googlesource.com/platform/bionic/+/master/libc/include/pthread.h) +However, for NDK, `pthread_setaffinity_np` won't be available until API level 36, Android 16. (refer to https://android.googlesource.com/platform/bionic/+/master/libc/include/pthread.h) -So in the NDK bulid version, it'll be replaced by the combination of `pthread_gettid_np` from `` and `sched_getaffinity` from ``. - -We'll add support to this soon. Use the GCC build version to get access to the newest ZeroTierOne. +So in the NDK bulid version, it is replaced by the combination of `pthread_gettid_np` from `` and `sched_getaffinity` from ``. \ No newline at end of file diff --git a/README_ZH.md b/README_ZH.md index 07d2563..8b9406b 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -97,3 +97,11 @@ ZeroTier 可执行文件和操作的 Shell 脚本放在 `/data/adb/zerotier/` ## 自行编译 参考 `.github/workflow/build-{gcc|ndk}.yml` + +## 注意 + +1.14.0 后 ZeroTierOne 引入了 `multi-core concurrent packet processing` ,其中使用了 `pthread_setaffinity_np` 实现线程亲和性设置 + +但 `pthread_setaffinity_np` 在 NDK 的 API level 36, Android 16 才受支持。 (参考 https://android.googlesource.com/platform/bionic/+/master/libc/include/pthread.h) + +所以 NDK 中他被替换成了 `` 中 `pthread_gettid_np` 和 `` 中 `sched_getaffinity` 的组合,来实现相同的功能 \ No newline at end of file diff --git a/app/lib/main.dart b/app/lib/main.dart index 369555c..0fcbcdc 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'dart:io'; import 'dart:developer' as developer; import 'package:flutter/services.dart'; +import 'package:quickalert/quickalert.dart'; import './authed_client.dart'; import 'package:path_provider/path_provider.dart'; @@ -126,8 +127,7 @@ class _MyHomePageState extends State { late Function restartFn, startFn, stopFn, joinFn, leaveFn; _MyHomePageState() : super() { - restartFn = - cmdButtonWrapper(() => zerotierCommand('restart')); + restartFn = cmdButtonWrapper(() => zerotierCommand('restart')); startFn = cmdButtonWrapper(() => zerotierCommand('start')); stopFn = cmdButtonWrapper(() => zerotierCommand('stop')); joinFn = cmdButtonWrapper(() => joinNetwork(_idInputController.text)); @@ -141,37 +141,44 @@ class _MyHomePageState extends State { } return Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Builder(builder: (BuildContext context) { - final color = (runningStatus ? Colors.green : Colors.red)[200]; + final color = (runningStatus ? Colors.green : Colors.red)[300]; return Column(children: [ - Icon(runningStatus ? Icons.play_arrow : Icons.stop, color: color, size: 72), + Icon(runningStatus ? Icons.play_arrow : Icons.stop, + color: color, size: 72), Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(runningStatus ? 'Running' : 'Stopped', style: TextStyle(color: color, fontSize: 18)), + Text(runningStatus ? 'Running' : 'Stopped', + style: TextStyle(color: color, fontSize: 18)), IconButton(icon: const Icon(Icons.refresh), onPressed: loadStatus) ]) ]); }), - ButtonBar( - alignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, + IntrinsicWidth( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ OutlinedButton.icon( + style: const ButtonStyle(alignment: Alignment.centerLeft), onPressed: startFn(), label: const Text('Start'), icon: const Icon(Icons.play_arrow), ), OutlinedButton.icon( + style: const ButtonStyle(alignment: Alignment.centerLeft), onPressed: restartFn(), label: const Text('Restart'), icon: const Icon(Icons.restart_alt), ), OutlinedButton.icon( + style: const ButtonStyle(alignment: Alignment.centerLeft), onPressed: stopFn(), label: const Text('Stop'), icon: const Icon(Icons.stop), ), ], - ) + )) ]); } @@ -196,7 +203,14 @@ class _MyHomePageState extends State { decoration: const InputDecoration( labelText: "network id", icon: Icon(Icons.router)))), OutlinedButton.icon( - onPressed: joinFn(), + onPressed: () { + joinFn()(); + QuickAlert.show( + context: context, + type: QuickAlertType.success, + text: 'Joined ${_idInputController.text}', + ); + }, label: const Text('Join'), icon: const Icon(Icons.add)), ]), @@ -231,15 +245,30 @@ class _MyHomePageState extends State { width: 96, child: Row(children: [ IconButton( - onPressed: () => Clipboard.setData( - ClipboardData( - text: networkList[i])) - .then, + onPressed: () { + Clipboard.setData(ClipboardData( + text: networkList[i])); + QuickAlert.show( + context: context, + type: QuickAlertType.success, + text: 'Copied to clipboard!', + ); + }, tooltip: '复制', icon: const Icon(Icons.copy)), IconButton( - onPressed: () => - leaveNetwork(networkList[i]), + onPressed: () => QuickAlert.show( + context: context, + type: QuickAlertType.confirm, + text: + 'Delete network ${networkList[i]} ?', + confirmBtnText: 'Yes', + cancelBtnText: 'No', + confirmBtnColor: Colors.green, + onConfirmBtnTap: () { + leaveNetwork(networkList[i]); + Navigator.pop(context); + }), tooltip: '离开', icon: const Icon(Icons.close)), ])))); @@ -252,11 +281,19 @@ class _MyHomePageState extends State { )); } + peersPage({bool title = false}) { + if (title) { + return 'Peers'; + } + return Container(); + } + int currentPageIndex = 0; genWidgetList({bool title = false}) { return [ homePage(title: title), - networkPage(title: title) + networkPage(title: title), + peersPage(title: title) ][currentPageIndex]; } @@ -282,6 +319,11 @@ class _MyHomePageState extends State { icon: Icon(Icons.router_outlined), label: 'Network', ), + NavigationDestination( + selectedIcon: Icon(Icons.account_box), + icon: Icon(Icons.account_box_outlined), + label: 'Peers', + ), ], ), body: Center( diff --git a/app/pubspec.lock b/app/pubspec.lock index 1e63f0c..a7050fe 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -175,26 +175,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -223,10 +223,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "1.11.0" + version: "1.12.0" path: dependency: transitive description: @@ -307,6 +307,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "2.1.8" + quickalert: + dependency: "direct main" + description: + name: quickalert + sha256: b5d62b1e20b08cc0ff5f40b6da519bdc7a5de6082f13d90572cf4e72eea56c5e + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "1.1.0" sky_engine: dependency: transitive description: flutter @@ -356,10 +364,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "0.6.1" + version: "0.7.0" typed_data: dependency: transitive description: @@ -380,10 +388,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted - version: "13.0.0" + version: "14.2.1" web: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index ee50743..9f8d668 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -37,6 +37,7 @@ dependencies: cupertino_icons: ^1.0.6 http: ^1.2.1 path_provider: ^2.1.3 + quickalert: ^1.1.0 dev_dependencies: flutter_test: