pingServer method

  1. @override
Future<VpnPingResult> pingServer({
  1. required String host,
  2. required int port,
  3. Duration timeout = const Duration(seconds: 3),
  4. bool useTls = false,
  5. String? tlsServerName,
  6. bool allowInsecure = false,
})
override

Performs ping over TCP/TLS through native platform implementation.

Implementation

@override
/// Performs ping over TCP/TLS through native platform implementation.
Future<VpnPingResult> pingServer({
  required String host,
  required int port,
  Duration timeout = const Duration(seconds: 3),
  bool useTls = false,
  String? tlsServerName,
  bool allowInsecure = false,
}) async {
  final dynamic raw = await methodChannel
      .invokeMethod<dynamic>('pingServer', <String, Object?>{
        'host': host,
        'port': port,
        'timeoutMs': timeout.inMilliseconds,
        'useTls': useTls,
        'tlsServerName': tlsServerName,
        'allowInsecure': allowInsecure,
      });
  if (raw is Map<Object?, Object?>) {
    return VpnPingResult.fromMap(raw, host: host, port: port);
  }
  return VpnPingResult.failure(
    host: host,
    port: port,
    error: 'Invalid ping response',
  );
}