Skip to content

Commit

Permalink
Merge pull request #39 from osociety/dev
Browse files Browse the repository at this point in the history
Dev -> Main
  • Loading branch information
git-elliot authored Mar 16, 2024
2 parents 9f34501 + c14877c commit a49b31d
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 100 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 2.0.0
1. Unified framework for network_tools and network_tools_flutter

**Breaking change** Replace these occurences in your project

* HostScannerFlutter to HostScannerService.instance
* PortScannerFlutter to PortScannerService.instance


## 1.0.5

1. scanPortsForSingleDevice and customDiscover supports async mode now.
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ This package will add support for flutter features which is out of the scope of
## Getting started

## Usage
Add dependency in pubspec.yml
Add dependency in pubspec.yml, path_provider dependency is also needed

```yml
dependencies:
flutter:
sdk: flutter

network_tools_flutter: ^1.0.4
path_provider: ^2.1.2
```
Import package in your project
```dart
import 'package:network_tools_flutter/network_tools_flutter.dart';
```
Use HostScannerFlutter and PortScannerFlutter for your flutter projects. See example directory for illustration.
## Additional information
And initialize the pacakge in the main function
```dart
await configureNetworkToolsFlutter((await getApplicationDocumentsDirectory()).path);
```

You can use same APIs but need to import from network_tools_flutter. All APIs from network_tools are automatically imported by network_tools_flutter. So just import network_tools_flutter in your flutter app.
From here please follow the documentation of [network_tools](https://pub.dev/packages/network_tools) as they are the same.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ analyzer:
- "**/*.pbjson.dart"
- "**/*.gr.dart"
- "**/*.md"
- "example/**"

linter:
rules:
Expand Down
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import 'package:path_provider/path_provider.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final appDocDirectory = await getApplicationDocumentsDirectory();
await configureNetworkTools(appDocDirectory.path, enableDebugging: true);
await configureNetworkToolsFlutter(appDocDirectory.path,
enableDebugging: true);
runApp(const MyApp());
}

Expand Down
5 changes: 4 additions & 1 deletion example/lib/pages/pingable_devices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ class _PingableDevicesState extends State<PingableDevices> {
if (netInt == null) {
return;
}
HostScannerFlutter.getAllPingableDevices(netInt.networkId).listen((host) {
HostScannerService.instance
.getAllPingableDevices(netInt.networkId)
.listen((host) {
setState(() {
activeHosts.add(host);
});
}).onError((e) {
// ignore: avoid_print
print('Error $e');
});
});
Expand Down
5 changes: 4 additions & 1 deletion example/lib/pages/port_scanner_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ class _PortScannerPageState extends State<PortScannerPage> {
}
String subnet =
netInt.ipAddress.substring(0, netInt.ipAddress.lastIndexOf('.'));
HostScanner.scanDevicesForSinglePort(subnet, 53).listen((host) {
HostScannerService.instance
.scanDevicesForSinglePort(subnet, 53)
.listen((host) {
setState(() {
activeHosts.add(host);
});
}).onError((e) {
// ignore: avoid_print
print('Error $e');
});
});
Expand Down
100 changes: 54 additions & 46 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
charcode:
dependency: transitive
description:
name: charcode
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
url: "https://pub.dev"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -69,10 +61,10 @@ packages:
dependency: transitive
description:
name: csv
sha256: "016b31a51a913744a0a1655c74ff13c9379e1200e246a03d96c81c5d9ed297b5"
sha256: "63ed2871dd6471193dffc52c0e6c76fb86269c00244d244297abbb355c84a86e"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "5.1.1"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -85,10 +77,10 @@ packages:
dependency: transitive
description:
name: dart_ping
sha256: dd3a93d9b986565cb2fadd0c9277cf9880298634ccc9588e353e63c6f736a386
sha256: "2f5418d0a5c64e53486caaac78677b25725b1e13c33c5be834ce874ea18bd24f"
url: "https://pub.dev"
source: hosted
version: "9.0.0"
version: "9.0.1"
dart_ping_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -155,22 +147,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
get_it:
dependency: transitive
description:
name: get_it
sha256: f79870884de16d689cf9a7d15eedf31ed61d750e813c538a6efb92660fea83c3
url: "https://pub.dev"
source: hosted
version: "7.6.4"
http:
dependency: transitive
description:
name: http
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.2.0"
http_parser:
dependency: transitive
description:
Expand All @@ -179,14 +163,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
injectable:
dependency: transitive
description:
name: injectable
sha256: "5217c45fec809286a7b1b4fbcbd70aab1662bf18d9eb207490df421323f7883f"
url: "https://pub.dev"
source: hosted
version: "2.3.0"
intl:
dependency: transitive
description:
Expand All @@ -203,6 +179,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.8.1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -223,57 +223,57 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.11.0"
multicast_dns:
dependency: transitive
description:
name: multicast_dns
sha256: f4fd1c3365171fac5160afcb1a283001d3413dee5fd41c61d80888952d609379
sha256: "316cc47a958d4bd3c67bd238fe8b44fdfb6133bad89cb191c0c3bd3edb14e296"
url: "https://pub.dev"
source: hosted
version: "0.3.2+4"
version: "0.3.2+6"
network_tools:
dependency: transitive
description:
name: network_tools
sha256: "84cd355e2d9db58456a05b7ebd4021fcbe42241043b7e6157bff2a0853054dd4"
sha256: c7543a957006047d4b6e7442c2cc0f592a1dd6572a6c1024301bc11dc53d45de
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "5.0.0"
network_tools_flutter:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.0.4"
version: "1.0.5"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -342,10 +342,10 @@ packages:
dependency: transitive
description:
name: process_run
sha256: ceacfac6d566a36c895d64edc7e429efb2d6b6303b5e28d5c13bc59fe6e8974e
sha256: cad2c57a34f8313a4182e34e31e0b2f12972eef3d0930cdc7ab3240bb8cad380
url: "https://pub.dev"
source: hosted
version: "0.13.1"
version: "0.14.1+3"
pub_semver:
dependency: transitive
description:
Expand Down Expand Up @@ -455,6 +455,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
web:
dependency: transitive
description:
Expand Down Expand Up @@ -488,5 +496,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.7.0"
3 changes: 1 addition & 2 deletions lib/network_tools_flutter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
library network_tools_flutter;

export 'src/host_scanner_flutter.dart';
export 'src/port_scanner_flutter.dart';
export 'package:network_tools/network_tools.dart';
export 'package:network_tools_flutter/src/configure_flutter.dart';
39 changes: 39 additions & 0 deletions lib/src/configure_flutter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:logging/logging.dart';
import 'package:network_tools/network_tools.dart' as pacakges_page;
// ignore: implementation_imports
import 'package:network_tools/src/network_tools_utils.dart';
// ignore: implementation_imports
import 'package:network_tools/src/services/arp_service.dart';
// ignore: implementation_imports
import 'package:network_tools/src/services/impls/arp_service_sembast_impl.dart';
import 'package:network_tools_flutter/src/services_impls/host_scanner_service_flutter_impl.dart';
import 'package:network_tools_flutter/src/services_impls/port_scanner_service_flutter_impl.dart';

Future<void> configureNetworkToolsFlutter(
String dbDirectory, {
bool enableDebugging = false,
}) async {
pacakges_page.enableDebugging = enableDebugging;
pacakges_page.dbDirectory = dbDirectory;

if (pacakges_page.enableDebugging) {
Logger.root.level = Level.FINE;
Logger.root.onRecord.listen((record) {
if (record.loggerName == log.name) {
// ignore: avoid_print
print(
'${record.time.toLocal()}: ${record.level.name}: ${record.loggerName}: ${record.message}',
);
}
});
}

/// Setting dart native classes implementations
ARPServiceSembastImpl();
HostScannerServiceFlutterImpl();
PortScannerServiceFlutterImpl();

final arpService = await ARPService.instance.open();
await arpService.buildTable();
await pacakges_page.VendorTable.createVendorTableMap();
}
Loading

0 comments on commit a49b31d

Please sign in to comment.