-
-
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 #120 from osociety/flutter_port_scan
Flutter package is moved to new repo
- Loading branch information
Showing
36 changed files
with
1,599 additions
and
261 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
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 |
---|---|---|
|
@@ -29,5 +29,6 @@ | |
.packages | ||
.pub-cache/ | ||
.pub/ | ||
build/ | ||
**/coverage/ | ||
**/build/ | ||
|
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,101 @@ | ||
# Change Log | ||
|
||
## 3.2.2 | ||
|
||
1. Supporting changes for network_tools_flutter | ||
|
||
## 3.2.1 | ||
|
||
1. Now GHA runs tests against 3 platforms windows, ubuntu, macos | ||
2. Code coverage is fixed so that it's visible in codecov portal. | ||
|
||
## 3.2.0 | ||
|
||
1. getAllPingableDevicesAsync runs inside isolate to find all devices in a network. | ||
2. Bug fixes and improvements | ||
|
||
## 3.1.0 | ||
|
||
Web Support and bug fixes for mDns devices giving error in getting IP | ||
|
||
## 3.0.0+3 | ||
|
||
Refactoring for field names | ||
|
||
## 3.0.0+2 | ||
|
||
This release is only meant to test Github Actions for Dart Package publishing. It's same as v3.0.0. Nothing changed. | ||
|
||
## 3.0.0+1 | ||
|
||
This release is only meant to test Github Actions for Dart Package publishing. It's same as v3.0.0. Nothing changed. | ||
|
||
## 3.0.0 | ||
|
||
**Breaking change** Change most of the methods names | ||
|
||
* HostScanner.discover to HostScanner.getAllPingableDevices | ||
* HostScanner.discoverPort to HostScanner.scanDevicesForSinglePort | ||
* PortScanner.discover to PortScanner.scanPortsForSingleDevice | ||
|
||
Ip field in ActiveHost is now InternetAddress type instead of string which improve handling of IPv6. | ||
|
||
ActiveHost now contains host name of the address if exist. | ||
|
||
Better naming of methods | ||
|
||
Bug fixes and improvements | ||
|
||
## 2.1.0 | ||
|
||
Added partly support for searching mdns devices. | ||
|
||
## 2.0.0 | ||
|
||
**Breaking change** Bump minimum dart version to 2.17.0. | ||
|
||
Updated dart_ping package version to 7.0.1. | ||
|
||
Updated test package version to 1.21.4. | ||
|
||
## 1.0.8 | ||
|
||
Fixes | ||
|
||
Add logs using logging package #13. | ||
|
||
Even more points in pub.dev page #20. | ||
|
||
## 1.0.7 | ||
|
||
Fixed | ||
|
||
Saving the response time from each device #9. | ||
|
||
Example crash on Windows #14. | ||
|
||
Bump package version #15. | ||
|
||
## 0.0.6 | ||
|
||
Resolved issue #9 and #10. | ||
|
||
## 0.0.5 | ||
|
||
Resolved issue #1. | ||
|
||
## 0.0.4 | ||
|
||
Single and Custom Port Scan added. | ||
|
||
## 0.0.3 | ||
|
||
Subnet and Port range added. | ||
|
||
## 0.0.2 | ||
|
||
Added example and followed pub conventions. | ||
|
||
## 0.0.1 | ||
|
||
PortScanner and HostScanner. |
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,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2021, Elliot Alderson | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,35 @@ | ||
# Defines a default set of lint rules enforced for | ||
# projects at Google. For details and rationale, | ||
# see https://github.com/dart-lang/pedantic#enabled-lints. | ||
#include: package:pedantic/analysis_options.yaml | ||
|
||
# lint analysis | ||
include: package:lint/analysis_options.yaml | ||
|
||
|
||
analyzer: | ||
errors: | ||
missing_required_param: error | ||
missing_return: error | ||
must_be_immutable: error | ||
exclude: | ||
- "**/*.g.dart" | ||
- "**/*.freezed.dart" | ||
- "**/*.pb.dart" | ||
- "**/*.pbenum.dart" | ||
- "**/*.pbgrpc.dart" | ||
- "**/*.pbjson.dart" | ||
- "**/*.gr.dart" | ||
- "**/*.md" | ||
- "example/**" | ||
|
||
linter: | ||
rules: | ||
# Use parameter order as in json response | ||
always_put_required_named_parameters_first: true | ||
|
||
avoid_classes_with_only_static_members: false | ||
|
||
sort_constructors_first: true | ||
|
||
avoid_relative_lib_imports: false |
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,40 @@ | ||
import 'package:intl/intl.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:network_tools/network_tools.dart'; | ||
|
||
void main() { | ||
Logger.root.level = Level.FINE; | ||
Logger.root.onRecord.listen((record) { | ||
print( | ||
'${DateFormat.Hms().format(record.time)}: ${record.level.name}: ${record.loggerName}: ${record.message}', | ||
); | ||
}); | ||
final log = Logger("host_scan_example"); | ||
|
||
const String address = '192.168.1.1'; | ||
// 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('.')); | ||
|
||
// You can set [firstHostId] and scan will start from this host in the network. | ||
// Similarly set [lastHostId] and scan will end at this host in the network. | ||
final stream = HostScanner.getAllPingableDevicesAsync( | ||
subnet, | ||
// firstHostId: 1, | ||
// lastHostId: 254, | ||
progressCallback: (progress) { | ||
log.finer('Progress for host discovery : $progress'); | ||
}, | ||
); | ||
|
||
stream.listen( | ||
(ActiveHost host) async { | ||
//Same host can be emitted multiple times | ||
//Use Set<ActiveHost> instead of List<ActiveHost> | ||
log.fine('Found device: ${await host.toStringFull()}'); | ||
}, | ||
onDone: () { | ||
log.fine('Scan completed'); | ||
}, | ||
); // Don't forget to cancel the stream when not in use. | ||
} |
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,5 @@ | ||
void main() { | ||
print("Run host scan : 'dart example/host_scan.dart'"); | ||
print("Run port scan : 'dart example/port_scan.dart'"); | ||
print("Run mdns scan : 'dart example/mdns_scan.dart'"); | ||
} |
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,10 @@ | ||
import 'package:network_tools/network_tools.dart'; | ||
|
||
Future<void> main() async { | ||
for (final ActiveHost activeHost in await MdnsScanner.searchMdnsDevices()) { | ||
final MdnsInfo? mdnsInfo = await activeHost.mdnsInfo; | ||
print( | ||
'Address: ${activeHost.address}, Port: ${mdnsInfo!.mdnsPort}, ServiceType: ${mdnsInfo.mdnsServiceType}, MdnsName: ${mdnsInfo.getOnlyTheStartOfMdnsName()}, Mdns Device Name: ${mdnsInfo.mdnsSrvTarget}', | ||
); | ||
} | ||
} |
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,66 @@ | ||
import 'package:intl/intl.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:network_tools/network_tools.dart'; | ||
|
||
void main() { | ||
Logger.root.level = Level.FINE; | ||
Logger.root.onRecord.listen((record) { | ||
print( | ||
'${DateFormat.Hms().format(record.time)}: ${record.level.name}: ${record.loggerName}: ${record.message}', | ||
); | ||
}); | ||
|
||
const String address = '192.168.1.1'; | ||
// 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('.')); | ||
|
||
// [New] Scan for a single open port in a subnet | ||
// You can set [firstHostId] and scan will start from this host in the network. | ||
// Similarly set [lastHostId] and scan will end at this host in the network. | ||
final stream2 = HostScanner.scanDevicesForSinglePort( | ||
subnet, | ||
53, | ||
// firstHostId: 1, | ||
// lastHostId: 254, | ||
progressCallback: (progress) { | ||
log.finer('Progress for port discovery on host : $progress'); | ||
}, | ||
); | ||
|
||
stream2.listen( | ||
(activeHost) { | ||
final OpenPort deviceWithOpenPort = activeHost.openPort[0]; | ||
if (deviceWithOpenPort.isOpen) { | ||
log.fine( | ||
'Found open port: ${deviceWithOpenPort.port} on ${activeHost.address}', | ||
); | ||
} | ||
}, | ||
onDone: () { | ||
log.fine('Port Scan completed'); | ||
}, | ||
); // Don't forget to cancel the stream when not in use. | ||
|
||
const String target = '192.168.1.1'; | ||
PortScanner.scanPortsForSingleDevice( | ||
target, | ||
// Scan will start from this port. | ||
// startPort: 1, | ||
endPort: 9400, | ||
progressCallback: (progress) { | ||
log.finer('Progress for port discovery : $progress'); | ||
}, | ||
).listen( | ||
(activeHost) { | ||
final OpenPort deviceWithOpenPort = activeHost.openPort[0]; | ||
|
||
if (deviceWithOpenPort.isOpen) { | ||
log.fine('Found open port: ${deviceWithOpenPort.port}'); | ||
} | ||
}, | ||
onDone: () { | ||
log.fine('Port Scan from 1 to 9400 completed'); | ||
}, | ||
); | ||
} |
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 @@ | ||
/// Network tools base library | ||
library network_tools; | ||
|
||
//TODO: add dartdocs | ||
export 'src/host_scanner.dart'; | ||
export 'src/mdns_scanner/mdns_scanner.dart'; | ||
export 'src/models/active_host.dart'; | ||
export 'src/models/callbacks.dart'; | ||
export 'src/models/mdns_info.dart'; | ||
export 'src/models/open_port.dart'; | ||
export 'src/models/sendable_active_host.dart'; | ||
export 'src/port_scanner.dart'; |
Oops, something went wrong.