Paskelbtas šaltinis
Atsisiųsti šaltinį ZIP
CH-J SM Mobile
Naršyti aplankus ir failus konkrečiai programai išleisti.
CH-J / SM Mobile
134 failai
sm-mobile-20261016T050549Z-3678f2a05fa9
Pridėta: · Pastatytas:
1
import 'dart:io';2
import 'package:flutter/material.dart';3
import '../core/app_controller.dart';4
import '../core/failure.dart';5
import '../l10n/strings.dart';6
import '../services/diagnostics.dart';7
import 'common.dart';9
class DiagnosticsPage extends StatefulWidget {10
final AppController controller;11
const DiagnosticsPage(this.controller, {super.key});12
@override13
State<DiagnosticsPage> createState() => _DiagnosticsPageState();14
}16
class _DiagnosticsPageState extends State<DiagnosticsPage> {17
late final host = TextEditingController(18
text: widget.controller.ssh.profile?.host,19
);20
late final port = TextEditingController(21
text: '${widget.controller.ssh.profile?.port ?? 22}',22
);23
InternetAddressType type = InternetAddressType.any;24
ProbeResult? result;25
bool busy = false;26
Future<void> probe() async {27
setState(() {28
busy = true;29
result = null;30
});31
try {32
final number = int.tryParse(port.text) ?? 0;33
if (number < 1 || number > 65535) throw const Failure('invalidProfile');34
final data = await Diagnostics().probe(35
host.text.trim(),36
number,37
type: type,38
);39
if (mounted && widget.controller.vault.unlocked) {40
setState(() => result = data);41
}42
} catch (e) {43
if (mounted) showFailure(context, e);44
} finally {45
if (mounted) setState(() => busy = false);46
}47
}49
@override50
void dispose() {51
host.dispose();52
port.dispose();53
super.dispose();54
}56
@override57
Widget build(BuildContext context) => ListView(58
padding: const EdgeInsets.all(20),59
children: [60
TextField(61
controller: host,62
autocorrect: false,63
decoration: InputDecoration(labelText: context.tr('host')),64
),65
const SizedBox(height: 16),66
TextField(67
controller: port,68
keyboardType: TextInputType.number,69
decoration: InputDecoration(labelText: context.tr('port')),70
),71
const SizedBox(height: 16),72
DropdownButtonFormField<InternetAddressType>(73
initialValue: type,74
items:75
[76
InternetAddressType.any,77
InternetAddressType.IPv4,78
InternetAddressType.IPv6,79
]80
.map(81
(v) => DropdownMenuItem(82
value: v,83
child: Text(84
v == InternetAddressType.any85
? context.tr('system')86
: v.name,87
),88
),89
)90
.toList(),91
onChanged: (v) => setState(() => type = v!),92
),93
const SizedBox(height: 16),94
FilledButton(95
onPressed: busy ? null : probe,96
child: Text(context.tr('runDiagnostics')),97
),98
if (busy) const LinearProgressIndicator(),99
const SizedBox(height: 16),100
Text(context.tr('icmpNote')),101
if (result != null) ...[102
const SizedBox(height: 24),103
Text(context.tr('dnsResults')),104
SelectableText(result!.addresses.join('\n')),105
const SizedBox(height: 16),106
Text('${context.tr('tcpConnect')}: ${result!.tcpMs} ms'),107
],108
if (widget.controller.ssh.connected)109
ListTile(110
title: Text(context.tr('connected')),111
subtitle: Text(112
'${widget.controller.ssh.profile!.host} · ${context.tr('handshake')}: ${widget.controller.ssh.handshakeMs} ms',113
),114
),115
],116
);117
}SHA-256
a0a739d1f5acfda827cdb67a69385bcb44b7f2077b9349c467da9e57ca621b47CH-J Proprietary Software License 1.14 · Šaltinis pateiktas pagal CH-J Proprietary Software License 1.14. Jo prieinamumas nekeičia licencijos sąlygų ir nesuteikia papildomų teisių.
Archyvas SHA-256
c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65