CH-J SM Mobileserver management over SSH
Menu
Published source

CH-J SM Mobile

Browse directories and files for a specific application release.

Download source ZIP
CH-J / SM Mobile 134 files
sm-mobile-20261016T050549Z-3678f2a05fa9 Added: · Built:
Files
diagnostics.dart Added: Date not recorded 1.2 KB · 41 lines
Download file
1import 'dart:async';
2import 'dart:io';
3import '../models/server_profile.dart';
5class ProbeResult {
6 final List<String> addresses;
7 final int tcpMs;
8 ProbeResult(this.addresses, this.tcpMs);
9}
11class Diagnostics {
12 Future<ProbeResult> probe(
13 String host,
14 int port, {
15 InternetAddressType type = InternetAddressType.any,
16 }) async {
17 normalizeHost(host);
18 final addresses = await InternetAddress.lookup(
19 host,
20 type: type,
21 ).timeout(const Duration(seconds: 10));
22 final deadline = DateTime.now().add(const Duration(seconds: 10));
23 Object lastError = const SocketException('No address for requested family');
24 for (final address in addresses) {
25 final remaining = deadline.difference(DateTime.now());
26 if (remaining <= Duration.zero) throw TimeoutException('TCP');
27 final watch = Stopwatch()..start();
28 try {
29 final socket = await Socket.connect(address, port, timeout: remaining);
30 socket.destroy();
31 return ProbeResult(
32 addresses.map((a) => a.address).toList(),
33 watch.elapsedMilliseconds,
34 );
35 } catch (e) {
36 lastError = e;
37 }
38 }
39 throw lastError;
40 }
SHA-25647a0ad1903b4272d279f80926c68e826f9e18535bd2a939b4958b38e93489494

CH-J Proprietary Software License 1.14 · Source is provided under the CH-J Proprietary Software License 1.14. Its availability does not change the license terms or grant additional rights.

Archive SHA-256c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65