mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
#34 fix & new
- fix: `ping` - new: support busybox `ping` - new: flutter 3.10.0
This commit is contained in:
@@ -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)!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<PingPage>
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
onPressed: () async {
|
||||
final path = await pickOneFile();
|
||||
if (path == null) {
|
||||
showSnackBar(context, const Text('path is null'));
|
||||
showSnackBar(context, Text(_s.fieldMustNotEmpty));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -345,11 +345,11 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
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),
|
||||
|
||||
Reference in New Issue
Block a user