Skip to content

Commit

Permalink
improved host scan using ARP
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot committed Sep 18, 2023
1 parent c29bf68 commit 7115334
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions example/host_scan.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:logging/logging.dart';
import '../lib/network_tools.dart';

void main() {
void main() async {
Logger.root.level = Level.FINE;
Logger.root.onRecord.listen((record) {
print(
Expand All @@ -10,12 +10,16 @@ void main() {
});
final log = Logger("host_scan_example");

const String address = '192.168.0.1';
final interface = await NetInterface.firstInterface();
address = interface.networkId;
String subnet = '192.168.0'; //Default network id for home networks

final interface = await NetInterface.localInterface();
final netId = interface?.networkId;
if (netId != null) {
subnet = netId;
}

// or You can also get address using network_info_plus package
// final String? address = await (NetworkInfo().getWifiIP());
final String subnet = address.substring(0, address.lastIndexOf('.'));
log.fine("Starting scan on subnet $subnet");

// You can set [firstHostId] and scan will start from this host in the network.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/device_info/vendor_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class VendorTable {
}

static Future<void> _fetchVendorTable(SendPort sendPort) async {
final input = File('lib/assets/mac-vendors-export.csv').openRead();
final input = File('./lib/assets/mac-vendors-export.csv').openRead();

List<List<dynamic>> fields = await input
.transform(utf8.decoder)
Expand Down

0 comments on commit 7115334

Please sign in to comment.