CH-J SM Mobilebainisteoireacht freastalaí SSH
Roghchlár
Foinse foilsithe

CH-J SM Mobile

Brabhsáil comhadlanna agus comhaid chun feidhmchlár áirithe a scaoileadh.

Íosluchtaigh foinse ZIP
CH-J / SM Mobile 134 Comhaid
sm-mobile-20261016T050549Z-3678f2a05fa9 Suimigh: · Tógtha:
Comhaid
diagnostics.dart Suimigh: Dáta gan taifeadadh 1.2 KB · 41 líne
Íosluchtaigh comhad
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 · Tá Foinse ar fáil faoin CH-J Proprietary Software License 1.14. Ní chuireann a infhaighteacht a athrú ar na téarmaí ceadúnais nó cearta breise a dheonú.

Cartlann SHA-256c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65