Line data Source code
1 : import 'package:network_tools/src/models/active_host.dart';
2 : import 'package:network_tools/src/models/callbacks.dart';
3 : import 'package:network_tools/src/models/sendable_active_host.dart';
4 :
5 : /// Scans for all hosts in a subnet.
6 : abstract class HostScannerService {
7 1 : HostScannerService() {
8 : _instance = this;
9 : }
10 :
11 1 : static late HostScannerService _instance;
12 :
13 2 : static HostScannerService get instance => _instance;
14 :
15 : /// Devices scan will start from this integer Id
16 : static const int defaultFirstHostId = 1;
17 :
18 : /// Devices scan will stop at this integer id
19 : static const int defaultLastHostId = 254;
20 :
21 : Stream<ActiveHost> getAllPingableDevices(
22 : String subnet, {
23 : int firstHostId = defaultFirstHostId,
24 : int lastHostId = defaultLastHostId,
25 : List<int> hostIds = const [],
26 : int timeoutInSeconds = 1,
27 : ProgressCallback? progressCallback,
28 : bool resultsInAddressAscendingOrder = true,
29 : });
30 :
31 : Stream<SendableActiveHost> getAllSendablePingableDevices(
32 : String subnet, {
33 : int firstHostId = defaultFirstHostId,
34 : int lastHostId = defaultLastHostId,
35 : List<int> hostIds = const [],
36 : int timeoutInSeconds = 1,
37 : ProgressCallback? progressCallback,
38 : bool resultsInAddressAscendingOrder = true,
39 : });
40 :
41 : int validateAndGetLastValidSubnet(
42 : String subnet,
43 : int firstHostId,
44 : int lastHostId,
45 : );
46 :
47 : Stream<ActiveHost> getAllPingableDevicesAsync(
48 : String subnet, {
49 : int firstHostId = defaultFirstHostId,
50 : int lastHostId = defaultLastHostId,
51 : List<int> hostIds = const [],
52 : int timeoutInSeconds = 1,
53 : ProgressCallback? progressCallback,
54 : bool resultsInAddressAscendingOrder = true,
55 : });
56 :
57 : Stream<ActiveHost> scanDevicesForSinglePort(
58 : String subnet,
59 : int port, {
60 : int firstHostId = defaultFirstHostId,
61 : int lastHostId = defaultLastHostId,
62 : Duration timeout = const Duration(milliseconds: 2000),
63 : ProgressCallback? progressCallback,
64 : bool resultsInAddressAscendingOrder = true,
65 : });
66 : }
|