scanPorts method

Future<List<PortCheckResult>> scanPorts({
  1. required String host,
  2. List<int> ports = const <int>[80, 443],
  3. Duration? timeout,
  4. int concurrency = 12,
})

并发扫描多个端口 / Scans multiple ports with bounded concurrency.

Implementation

Future<List<PortCheckResult>> scanPorts({
  required String host,
  List<int> ports = const <int>[80, 443],
  Duration? timeout,
  int concurrency = 12,
}) async {
  return ports
      .map(
        (port) => PortCheckResult(
          host: host,
          port: port,
          isOpen: false,
          responseTime: Duration.zero,
          errorMessage:
              'TCP port scanning is not available on the web platform.',
          timestamp: DateTime.now(),
        ),
      )
      .toList(growable: false);
}