From 91f97e52b07304e11077d23ea592cf3ad3baf72d Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Thu, 11 May 2023 12:06:30 +0800 Subject: [PATCH] #34 fix & new - fix: `ping` - new: support busybox `ping` - new: flutter 3.10.0 --- ios/Podfile.lock | 4 +-- ios/Runner.xcodeproj/project.pbxproj | 13 +++++---- lib/data/model/server/ping_result.dart | 22 ++++++++++----- lib/data/res/build_data.dart | 6 ++-- lib/view/page/ping.dart | 12 +++----- lib/view/page/private_key/edit.dart | 2 +- lib/view/page/server/detail.dart | 6 ++-- pubspec.lock | 38 +++++++++++++------------- pubspec.yaml | 2 +- 9 files changed, 55 insertions(+), 50 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f352ff16..42673bc1 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -23,7 +23,7 @@ DEPENDENCIES: - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) - - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) + - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - plain_notification_token (from `.symlinks/plugins/plain_notification_token/ios`) - r_upgrade (from `.symlinks/plugins/r_upgrade/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`) @@ -39,7 +39,7 @@ EXTERNAL SOURCES: flutter_native_splash: :path: ".symlinks/plugins/flutter_native_splash/ios" path_provider_foundation: - :path: ".symlinks/plugins/path_provider_foundation/ios" + :path: ".symlinks/plugins/path_provider_foundation/darwin" plain_notification_token: :path: ".symlinks/plugins/plain_notification_token/ios" r_upgrade: diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 3be4cc2c..7c477750 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -206,6 +206,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -359,7 +360,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 293; + CURRENT_PROJECT_VERSION = 294; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -367,7 +368,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.293; + MARKETING_VERSION = 1.0.294; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -490,7 +491,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 293; + CURRENT_PROJECT_VERSION = 294; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -498,7 +499,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.293; + MARKETING_VERSION = 1.0.294; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -515,7 +516,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 293; + CURRENT_PROJECT_VERSION = 294; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -523,7 +524,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.293; + MARKETING_VERSION = 1.0.294; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/model/server/ping_result.dart b/lib/data/model/server/ping_result.dart index 0495466c..de59f73c 100644 --- a/lib/data/model/server/ping_result.dart +++ b/lib/data/model/server/ping_result.dart @@ -1,9 +1,10 @@ final parseFailed = Exception('Parse failed'); -final seqReg = RegExp(r'icmp_seq=(.+) ttl=(.+) time=(.+) ms'); +final seqReg = RegExp(r'seq=(.+) ttl=(.+) time=(.+) ms'); final packetReg = RegExp(r'(.+) packets transmitted, (.+) received, (.+)% packet loss'); final timeReg = RegExp(r'min/avg/max/mdev = (.+)/(.+)/(.+)/(.+) ms'); -final ipReg = RegExp(r' \((\S+)\) '); +final timeAlpineReg = RegExp(r'round-trip min/avg/max = (.+)/(.+)/(.+) ms'); +final ipReg = RegExp(r' \((\S+)\)'); class PingResult { String serverName; @@ -65,15 +66,22 @@ class PingStatistics { } final packetMatched = packetReg.firstMatch(lines[0]); final timeMatched = timeReg.firstMatch(lines[1]); - if (packetMatched == null || timeMatched == null) { + final timeAlpineMatched = timeAlpineReg.firstMatch(lines[1]); + if (packetMatched == null) { return; } total = int.tryParse(packetMatched.group(1)!); received = int.tryParse(packetMatched.group(2)!); loss = double.tryParse(packetMatched.group(3)!); - min = double.tryParse(timeMatched.group(1)!); - avg = double.tryParse(timeMatched.group(2)!); - max = double.tryParse(timeMatched.group(3)!); - stddev = double.tryParse(timeMatched.group(4)!); + if (timeMatched != null) { + min = double.tryParse(timeMatched.group(1)!); + avg = double.tryParse(timeMatched.group(2)!); + max = double.tryParse(timeMatched.group(3)!); + stddev = double.tryParse(timeMatched.group(4)!); + } else if (timeAlpineMatched != null) { + min = double.tryParse(timeAlpineMatched.group(1)!); + avg = double.tryParse(timeAlpineMatched.group(2)!); + max = double.tryParse(timeAlpineMatched.group(3)!); + } } } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index a639f436..aee84cc2 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 293; + static const int build = 294; static const String engine = "3.7.11"; - static const String buildAt = "2023-05-10 12:26:52.686"; - static const int modifications = 11; + static const String buildAt = "2023-05-10 13:26:09.654757"; + static const int modifications = 1; } diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index 6b3b1106..7102d099 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -14,11 +14,8 @@ import '../../locator.dart'; import '../widget/input_field.dart'; import '../widget/round_rect_card.dart'; -final doaminReg = - RegExp(r'^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$'); -final ipv4Reg = - RegExp(r'^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$'); -final ipv6Reg = RegExp(r'^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'); +/// Only permit ipv4 / ipv6 / domain chars +final targetReg = RegExp(r'[a-zA-Z0-9\.-_:]+'); class PingPage extends StatefulWidget { const PingPage({Key? key}) : super(key: key); @@ -148,9 +145,8 @@ class _PingPageState extends State return; } - if (!doaminReg.hasMatch(target) && - !ipv4Reg.hasMatch(target) && - !ipv6Reg.hasMatch(target)) { + /// avoid ping command injection + if (!targetReg.hasMatch(target)) { showSnackBar(context, Text(s.pingInputIP)); return; } diff --git a/lib/view/page/private_key/edit.dart b/lib/view/page/private_key/edit.dart index a38abca7..d3a46aae 100644 --- a/lib/view/page/private_key/edit.dart +++ b/lib/view/page/private_key/edit.dart @@ -152,7 +152,7 @@ class _PrivateKeyEditPageState extends State onPressed: () async { final path = await pickOneFile(); if (path == null) { - showSnackBar(context, const Text('path is null')); + showSnackBar(context, Text(_s.fieldMustNotEmpty)); return; } diff --git a/lib/view/page/server/detail.dart b/lib/view/page/server/detail.dart index 5a6e5813..c719469e 100644 --- a/lib/view/page/server/detail.dart +++ b/lib/view/page/server/detail.dart @@ -345,11 +345,11 @@ class _ServerDetailPageState extends State } Widget _buildNetSpeedTop() { - return Padding( - padding: const EdgeInsets.only(bottom: 3), + return const Padding( + padding: EdgeInsets.only(bottom: 3), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: const [ + children: [ Icon(Icons.device_hub, size: 17), Icon(Icons.arrow_downward, size: 17), Icon(Icons.arrow_upward, size: 17), diff --git a/pubspec.lock b/pubspec.lock index 4c5e1d70..240f4fc3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -53,10 +53,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -133,10 +133,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" checked_yaml: dependency: transitive description: @@ -174,10 +174,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" convert: dependency: transitive description: @@ -474,10 +474,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.18.0" io: dependency: transitive description: @@ -490,10 +490,10 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" json_annotation: dependency: transitive description: @@ -522,10 +522,10 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -538,10 +538,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" mime: dependency: transitive description: @@ -570,10 +570,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider: dependency: "direct main" description: @@ -855,10 +855,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" timing: dependency: transitive description: @@ -1029,5 +1029,5 @@ packages: source: hosted version: "0.0.6" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml index c4c36f73..4cc58090 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,7 +53,7 @@ dependencies: path_provider: ^2.0.9 easy_isolate: ^1.3.0 share_plus: 6.3.2 - intl: ^0.17.0 + intl: ^0.18.0 share_plus_web: ^3.1.0 # xterm: ^3.4.1 xterm: