- fix: `ping`
- new: support busybox `ping`
- new: flutter 3.10.0
This commit is contained in:
lollipopkit
2023-05-11 12:06:30 +08:00
parent 4f82eb09d8
commit 91f97e52b0
9 changed files with 55 additions and 50 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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),