-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from osociety/sembas-getit-injector
Major upgrade via sembast db and mac-vendor csv
- Loading branch information
Showing
22 changed files
with
318 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,8 @@ | |
**/build/ | ||
|
||
# Generated sources | ||
*.g.dart | ||
*.g.dart | ||
*.config.dart | ||
|
||
# Downloaded files | ||
mac-vendors-export.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:get_it/get_it.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
import 'package:network_tools/injectable.config.dart'; | ||
|
||
final getIt = GetIt.instance; | ||
|
||
@InjectableInit( | ||
initializerName: 'init', // default | ||
preferRelativeImports: true, // default | ||
asExtension: true, // default | ||
) | ||
void configureDependencies() => getIt.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:logging/logging.dart'; | ||
import 'package:network_tools/src/models/arp_data.dart'; | ||
|
||
class ARPTableHelper { | ||
static final arpLogger = Logger("arp-table-logger"); | ||
|
||
static Future<List<ARPData>> buildTable() async { | ||
final arpEntries = <ARPData>[]; | ||
final result = await Process.run('arp', ['-a']); | ||
final entries = const LineSplitter().convert(result.stdout.toString()); | ||
RegExp? pattern; | ||
if (Platform.isMacOS) { | ||
pattern = RegExp( | ||
r'(?<host>[\w.?]*)\s\((?<ip>.*)\)\sat\s(?<mac>.*)\son\s(?<intf>\w+)\sifscope\s*(\w*)\s*\[(?<typ>.*)\]', | ||
); | ||
} else if (Platform.isLinux) { | ||
pattern = RegExp( | ||
r'(?<host>[\w.?]*)\s\((?<ip>.*)\)\sat\s(?<mac>.*)\s\[(?<typ>.*)\]\son\s(?<intf>\w+)', | ||
); | ||
} else { | ||
pattern = RegExp(r'(?<ip>.*)\s(?<mac>.*)\s(?<typ>.*)'); | ||
} | ||
|
||
for (final entry in entries) { | ||
final match = pattern.firstMatch(entry); | ||
if (match != null) { | ||
final arpData = ARPData( | ||
hostname: match.groupNames.contains('host') | ||
? match.namedGroup("host") ?? '' | ||
: '', | ||
iPAddress: match.namedGroup("ip") ?? ARPData.nullIPAddress, | ||
macAddress: match.namedGroup("mac") ?? ARPData.nullMacAddress, | ||
interfaceName: match.groupNames.contains('intf') | ||
? match.namedGroup("intf") ?? '' | ||
: '', | ||
interfaceType: match.namedGroup("typ") ?? ARPData.nullInterfaceType, | ||
); | ||
if (arpData.macAddress != '(incomplete)') { | ||
arpLogger.fine("Adding entry to table -> $arpData"); | ||
arpEntries.add(arpData); | ||
} | ||
} | ||
} | ||
return arpEntries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.