scan method
Implementation
Future<List<ScanResult>> scan() async {
final results = <ScanResult>[];
final receivePort = ReceivePort();
final hosts = hostRange.getHosts();
if (debug) {
debugPrint('Scanning ${hosts.length} hosts with ${ports.length} ports each');
debugPrint('First ip: ${hosts.first}, Last ip: ${hosts.last}');
debugPrint('----------------------------------------');
}
for (final host in hosts) {
for (final port in ports) {
await Isolate.spawn(
_scanPort,
_ScanParams(host: host, port: port, timeout: timeout, sendPort: receivePort.sendPort, debug: debug),
);
}
}
await for (final result in receivePort) {
results.add(result as ScanResult);
if (results.length == hosts.length * ports.length) {
receivePort.close();
break;
}
}
return results;
}