traceroute function

Future<List<String>> traceroute(
  1. String host, {
  2. int maxHops = 30,
})

Implementation

Future<List<String>> traceroute(String host, {int maxHops = 30}) async {
  try {
    final proc = await Process.start('traceroute', ['-m', '$maxHops', host]);
    final out = <String>[];
    await for (final line in proc.stdout
        .transform(utf8.decoder)
        .transform(const LineSplitter())) {
      out.add(line);
    }
    await proc.exitCode;
    return out;
  } catch (_) {
    return [];
  }
}