From f15f7e3c99ce611301a72a8fc56b78bb9149db11 Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Tue, 1 Feb 2022 18:00:49 +0200 Subject: [PATCH 01/10] Added freezed, injectable, bloc, get_it, auto_size_text packages. Started creating bloc files for host scan page --- lib/injection.dart | 23 +++++++++++++++ lib/main.dart | 2 ++ lib/pages/home_page.dart | 2 +- .../{ => host_scan_page}/host_scan_page.dart | 23 +++++++++++---- .../host_scna_bloc/host_scan_bloc.dart | 19 +++++++++++++ .../host_scna_bloc/host_scan_event.dart | 6 ++++ .../host_scna_bloc/host_scan_state.dart | 14 ++++++++++ .../widgets/host_scan_widget.dart | 22 +++++++++++++++ pubspec.yaml | 28 +++++++++++++++++++ 9 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 lib/injection.dart rename lib/pages/{ => host_scan_page}/host_scan_page.dart (87%) create mode 100644 lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart create mode 100644 lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart create mode 100644 lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart create mode 100644 lib/pages/host_scan_page/widgets/host_scan_widget.dart diff --git a/lib/injection.dart b/lib/injection.dart new file mode 100644 index 00000000..2795ab62 --- /dev/null +++ b/lib/injection.dart @@ -0,0 +1,23 @@ +import 'package:get_it/get_it.dart'; +import 'package:injectable/injectable.dart'; +import 'package:vernet/injection.config.dart'; + +final getIt = GetIt.instance; + +/// Saves the current environment for manual use +late String currentEnv; + +@injectableInit +void configureDependencies(String env) { + currentEnv = env; + $initGetIt(getIt, environment: env); +} + +abstract class Env { + static const String test = 'test'; + static const String dev = 'dev'; + static const String prod = 'prod'; + + /// Demo of the app with fake data + static const String demo = 'demo'; +} diff --git a/lib/main.dart b/lib/main.dart index cba14e19..00777287 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import 'package:provider/provider.dart'; import 'package:vernet/api/update_checker.dart'; import 'package:vernet/helper/app_settings.dart'; import 'package:vernet/helper/consent_loader.dart'; +import 'package:vernet/injection.dart'; import 'package:vernet/models/dark_theme_provider.dart'; import 'package:vernet/pages/home_page.dart'; import 'package:vernet/pages/location_consent_page.dart'; @@ -10,6 +11,7 @@ import 'package:vernet/pages/settings_page.dart'; late AppSettings appSettings; Future main() async { + configureDependencies(Env.prod); WidgetsFlutterBinding.ensureInitialized(); final bool allowed = await ConsentLoader.isConsentPageShown(); diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index dbfb0f58..2f47275d 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -9,7 +9,7 @@ import 'package:vernet/models/internet_provider.dart'; import 'package:vernet/models/wifi_info.dart'; import 'package:vernet/pages/dns/dns_page.dart'; import 'package:vernet/pages/dns/reverse_dns_page.dart'; -import 'package:vernet/pages/host_scan_page.dart'; +import 'package:vernet/pages/host_scan_page/host_scan_page.dart'; import 'package:vernet/pages/network_troubleshoot/ping_page.dart'; import 'package:vernet/pages/network_troubleshoot/port_scan_page.dart'; import 'package:vernet/ui/custom_tile.dart'; diff --git a/lib/pages/host_scan_page.dart b/lib/pages/host_scan_page/host_scan_page.dart similarity index 87% rename from lib/pages/host_scan_page.dart rename to lib/pages/host_scan_page/host_scan_page.dart index 6c97c051..57ab636f 100644 --- a/lib/pages/host_scan_page.dart +++ b/lib/pages/host_scan_page/host_scan_page.dart @@ -4,10 +4,14 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:network_info_plus/network_info_plus.dart'; import 'package:network_tools/network_tools.dart'; import 'package:percent_indicator/percent_indicator.dart'; +import 'package:vernet/injection.dart'; import 'package:vernet/main.dart'; +import 'package:vernet/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart'; +import 'package:vernet/pages/host_scan_page/widgets/host_scan_widget.dart'; import 'package:vernet/pages/network_troubleshoot/port_scan_page.dart'; class HostScanPage extends StatefulWidget { @@ -111,7 +115,16 @@ class _HostScanPageState extends State ], ), body: Center( - child: buildListView(context), + child: Column( + children: [ + BlocProvider( + create: (context) => + getIt()..add(const HostScanEvent.initialized()), + child: ConfigureNewCbjCompWidgets(), + ), + buildListView(context), + ], + ), ), ); } @@ -178,12 +191,12 @@ class _HostScanPageState extends State Icon _getHostIcon(String hostIp) { if (hostIp == _ip) { if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) { - return Icon(Icons.computer); + return const Icon(Icons.computer); } - return Icon(Icons.smartphone); + return const Icon(Icons.smartphone); } else if (hostIp == _gatewayIP) { - return Icon(Icons.router); + return const Icon(Icons.router); } - return Icon(Icons.devices); + return const Icon(Icons.devices); } } diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart new file mode 100644 index 00000000..fae77b66 --- /dev/null +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -0,0 +1,19 @@ +import 'package:bloc/bloc.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +part 'host_scan_bloc.freezed.dart'; +part 'host_scan_event.dart'; +part 'host_scan_state.dart'; + +@injectable +class HostScanBloc extends Bloc { + HostScanBloc() : super(HostScanState.initial()) { + on(_initialized); + } + + Future _initialized( + Initialized event, + Emitter emit, + ) async {} +} diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart new file mode 100644 index 00000000..a51b5029 --- /dev/null +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart @@ -0,0 +1,6 @@ +part of 'host_scan_bloc.dart'; + +@freezed +class HostScanEvent with _$HostScanEvent { + const factory HostScanEvent.initialized() = Initialized; +} diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart new file mode 100644 index 00000000..23f5ad9b --- /dev/null +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart @@ -0,0 +1,14 @@ +part of 'host_scan_bloc.dart'; + +@freezed +class HostScanState with _$HostScanState { + factory HostScanState.initial() = _Initial; + + const factory HostScanState.loadInProgress() = _LoadInProgress; + + const factory HostScanState.loadSuccess(String securityBearIp) = _LoadSuccess; + + const factory HostScanState.loadFailure() = _loadFailure; + + const factory HostScanState.error() = Error; +} diff --git a/lib/pages/host_scan_page/widgets/host_scan_widget.dart b/lib/pages/host_scan_page/widgets/host_scan_widget.dart new file mode 100644 index 00000000..114c34fd --- /dev/null +++ b/lib/pages/host_scan_page/widgets/host_scan_widget.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:vernet/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart'; + +class ConfigureNewCbjCompWidgets extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + // return state.map( + // initial: (_) { + // context.read().add( + // ConfigureNewCbjCompEvent.sendHotSpotInformation( + // cbjCompEntityInBuild, + // ), + // ); + // ); + return const SizedBox(); + }, + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index f03fec06..5bb2fe92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,25 +21,53 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: + # Automatically resizes text to fit perfectly within its bounds. + auto_size_text: ^3.0.0 + # Helps implement the BLoC pattern. + bloc: ^8.0.2 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.4 dart_ping: ^6.1.1 flutter: sdk: flutter + # Bloc for state management, replace StatefulWidget + flutter_bloc: ^8.0.1 + # Annotations for freezed + freezed_annotation: ^1.1.0 + # Service locator + get_it: ^7.2.0 + # A composable, multi-platform, Future-based API for HTTP requests. http: ^0.13.4 + # Convenient code generator for get_it + injectable: ^1.5.3 + # Discover network info and configure themselves accordingly network_info_plus: ^2.1.2 + # Helps you discover open ports, devices on subnet and more. network_tools: ^1.0.7 + # Querying information about the application package, such as CFBundleVersion package_info_plus: ^1.3.0 + # Allows you to display progress widgets based on percentage. percent_indicator: ^3.4.0 + # Popup that ask for the requested permission permission_handler: ^8.3.0 + # A wrapper around InheritedWidget to make them easier to use and more reusable. provider: ^6.0.2 + # Reading and writing simple key-value pairs shared_preferences: ^2.0.12 + # Plugin for launching a URL url_launcher: ^6.0.18 dev_dependencies: + # A build system for Dart code generation and modular compilation. + build_runner: + flutter_test: sdk: flutter + # Code generator for unions/pattern-matching/copy. + freezed: ^1.1.1 + # Convenient code generator for get_it. + injectable_generator: ^1.5.3 # Collection of lint rules for Dart and Flutter projects. lint: ^1.8.1 From ec80487d05e050346d0ec567b438dfd2cd532857 Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Tue, 1 Feb 2022 20:08:24 +0200 Subject: [PATCH 02/10] Completed moving host scan to use bloc --- lib/pages/home_page.dart | 2 +- .../host_scan_page/device_in_the_network.dart | 85 +++++++ lib/pages/host_scan_page/host_scan_page.dart | 207 ++---------------- .../host_scna_bloc/host_scan_bloc.dart | 56 ++++- .../host_scna_bloc/host_scan_event.dart | 2 + .../host_scna_bloc/host_scan_state.dart | 8 +- .../widgets/host_scan_widget.dart | 98 +++++++-- pubspec.yaml | 2 +- 8 files changed, 259 insertions(+), 201 deletions(-) create mode 100644 lib/pages/host_scan_page/device_in_the_network.dart diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 2f47275d..12ac8b00 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -89,7 +89,7 @@ class _WifiDetailState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => const HostScanPage(), + builder: (context) => HostScanPage(), ), ); }, diff --git a/lib/pages/host_scan_page/device_in_the_network.dart b/lib/pages/host_scan_page/device_in_the_network.dart new file mode 100644 index 00000000..8da60eba --- /dev/null +++ b/lib/pages/host_scan_page/device_in_the_network.dart @@ -0,0 +1,85 @@ +import 'dart:io'; + +import 'package:dart_ping/dart_ping.dart'; +import 'package:flutter/material.dart'; + +/// Contains all the information of a device in the network including +/// icon, open ports and in the future host name and mDNS name +class DeviceInTheNetwork { + /// Create basic device with default (not the correct) icon + DeviceInTheNetwork({ + required this.ip, + required this.make, + required this.pingData, + this.iconData = Icons.devices, + this.hostId, + }); + + /// Create the object with the correct field and icon + factory DeviceInTheNetwork.createWithAllNecessaryFields({ + required String ip, + required int hostId, + required String make, + required PingData pingData, + required String currentDeviceIp, + required String gatewayIp, + }) { + final IconData iconData = getHostIcon( + currentDeviceIp: currentDeviceIp, + hostIp: ip, + gatewayIp: gatewayIp, + ); + + final String deviceMake = getDeviceMake( + currentDeviceIp: currentDeviceIp, + hostIp: ip, + gatewayIp: gatewayIp, + hostMake: make, + ); + + return DeviceInTheNetwork( + ip: ip, + make: deviceMake, + pingData: pingData, + hostId: hostId, + iconData: iconData, + ); + } + + /// Ip of the device + final String ip; + final String make; + final PingData pingData; + final IconData iconData; + int? hostId; + + static String getDeviceMake({ + required String currentDeviceIp, + required String hostIp, + required String gatewayIp, + required String hostMake, + }) { + if (currentDeviceIp == hostIp) { + return 'This device'; + } else if (gatewayIp == hostIp) { + return 'Router/Gateway'; + } + return hostMake; + } + + static IconData getHostIcon({ + required String currentDeviceIp, + required String hostIp, + required String gatewayIp, + }) { + if (hostIp == currentDeviceIp) { + if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) { + return Icons.computer; + } + return Icons.smartphone; + } else if (hostIp == gatewayIp) { + return Icons.router; + } + return Icons.devices; + } +} diff --git a/lib/pages/host_scan_page/host_scan_page.dart b/lib/pages/host_scan_page/host_scan_page.dart index 57ab636f..cb2be54f 100644 --- a/lib/pages/host_scan_page/host_scan_page.dart +++ b/lib/pages/host_scan_page/host_scan_page.dart @@ -1,202 +1,41 @@ -import 'dart:async'; -import 'dart:collection'; -import 'dart:io'; - import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:network_info_plus/network_info_plus.dart'; -import 'package:network_tools/network_tools.dart'; -import 'package:percent_indicator/percent_indicator.dart'; import 'package:vernet/injection.dart'; -import 'package:vernet/main.dart'; import 'package:vernet/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart'; import 'package:vernet/pages/host_scan_page/widgets/host_scan_widget.dart'; -import 'package:vernet/pages/network_troubleshoot/port_scan_page.dart'; - -class HostScanPage extends StatefulWidget { - const HostScanPage({Key? key}) : super(key: key); - - @override - _HostScanPageState createState() => _HostScanPageState(); -} - -class _HostScanPageState extends State - with TickerProviderStateMixin { - final Set _hosts = {}; - double _progress = 0; - bool _isScanning = false; - StreamSubscription? _streamSubscription; - late String? _ip; - late String? _gatewayIP; - - Future _getDevices() async { - _hosts.clear(); - _ip = await NetworkInfo().getWifiIP(); - _gatewayIP = await NetworkInfo().getWifiGatewayIP(); - - if (_ip != null && _ip!.isNotEmpty) { - final String subnet = _ip!.substring(0, _ip!.lastIndexOf('.')); - setState(() { - _isScanning = true; - }); - - final stream = HostScanner.discover( - subnet, - firstSubnet: appSettings.firstSubnet, - lastSubnet: appSettings.lastSubnet, - progressCallback: (progress) { - if (mounted) { - setState(() { - _progress = progress; - }); - } - }, - ); - - _streamSubscription = stream.listen( - (ActiveHost host) { - setState(() { - _hosts.add(host); - }); - }, - onDone: () { - if (mounted) { - setState(() { - _isScanning = false; - }); - } - }, - onError: (error) { - if (mounted) { - setState(() { - _isScanning = false; - }); - } - }, - ); - } - } - - @override - void initState() { - super.initState(); - _getDevices(); - } - - @override - void dispose() { - super.dispose(); - _streamSubscription?.cancel(); - } +class HostScanPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Scan for Devices'), - actions: [ - if (_isScanning) - Container( - margin: const EdgeInsets.only(right: 20.0), - child: CircularPercentIndicator( - radius: 20.0, - lineWidth: 2.5, - percent: _progress / 100, - backgroundColor: Colors.grey, - progressColor: Colors.white, - ), - ) - else - IconButton( - onPressed: _getDevices, - icon: const Icon(Icons.refresh), - ), - ], + // actions: [ + // if (_isScanning) + // Container( + // margin: const EdgeInsets.only(right: 20.0), + // child: CircularPercentIndicator( + // radius: 20.0, + // lineWidth: 2.5, + // percent: _progress / 100, + // backgroundColor: Colors.grey, + // progressColor: Colors.white, + // ), + // ) + // else + // IconButton( + // onPressed: _getDevices, + // icon: const Icon(Icons.refresh), + // ), + // ], ), body: Center( - child: Column( - children: [ - BlocProvider( - create: (context) => - getIt()..add(const HostScanEvent.initialized()), - child: ConfigureNewCbjCompWidgets(), - ), - buildListView(context), - ], + child: BlocProvider( + create: (context) => + getIt()..add(const HostScanEvent.initialized()), + child: HostScanWidget(), ), ), ); } - - Widget buildListView(BuildContext context) { - if (_progress >= 100 && _hosts.isEmpty) { - return const Text( - 'No host found.\nTry changing first and last subnet in settings', - textAlign: TextAlign.center, - ); - } else if (_isScanning && _hosts.isEmpty) { - return const CircularProgressIndicator.adaptive(); - } - - return Column( - children: [ - Expanded( - child: ListView.builder( - itemCount: _hosts.length, - itemBuilder: (context, index) { - final ActiveHost host = - SplayTreeSet.from(_hosts).toList()[index] as ActiveHost; - return ListTile( - leading: _getHostIcon(host.ip), - title: Text(_getDeviceMake(host)), - subtitle: Text(host.ip), - trailing: IconButton( - tooltip: 'Scan open ports for this target', - icon: const Icon(Icons.radar), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => PortScanPage(target: host.ip), - ), - ); - }, - ), - onLongPress: () { - Clipboard.setData(ClipboardData(text: host.ip)); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('IP copied to clipboard'), - ), - ); - }, - ); - }, - ), - ) - ], - ); - } - - String _getDeviceMake(ActiveHost host) { - if (_ip == host.ip) { - return 'This device'; - } else if (_gatewayIP == host.ip) { - return 'Router/Gateway'; - } - return host.make; - } - - Icon _getHostIcon(String hostIp) { - if (hostIp == _ip) { - if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) { - return const Icon(Icons.computer); - } - return const Icon(Icons.smartphone); - } else if (hostIp == _gatewayIP) { - return const Icon(Icons.router); - } - return const Icon(Icons.devices); - } } diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index fae77b66..5bca8a08 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -1,6 +1,10 @@ import 'package:bloc/bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:injectable/injectable.dart'; +import 'package:network_info_plus/network_info_plus.dart'; +import 'package:network_tools/network_tools.dart'; +import 'package:vernet/main.dart'; +import 'package:vernet/pages/host_scan_page/device_in_the_network.dart'; part 'host_scan_bloc.freezed.dart'; part 'host_scan_event.dart'; @@ -10,10 +14,60 @@ part 'host_scan_state.dart'; class HostScanBloc extends Bloc { HostScanBloc() : super(HostScanState.initial()) { on(_initialized); + on(_startNewScan); } + /// Will contain all the hosts that got discovered in the network, will be use + /// inorder to cancel on dispose of the page. + Stream? hostsDiscoveredInNetwork; + + /// IP of the device in the local network. + String? ip; + + /// Gateway IP of the current network + late String? gatewayIp; + + /// List of all ActiveHost devices that got found in the current scan + List activeHostList = []; + Future _initialized( Initialized event, Emitter emit, - ) async {} + ) async { + emit(const HostScanState.loadInProgress()); + ip = await NetworkInfo().getWifiIP(); + gatewayIp = await NetworkInfo().getWifiGatewayIP(); + + add(const HostScanEvent.startNewScan()); + } + + Future _startNewScan( + StartNewScan event, + Emitter emit, + ) async { + final String subnet = ip!.substring(0, ip!.lastIndexOf('.')); + activeHostList = []; + + hostsDiscoveredInNetwork = HostScanner.discover( + subnet, + firstSubnet: appSettings.firstSubnet, + lastSubnet: appSettings.lastSubnet, + resultsInIpAscendingOrder: false, + ); + + await for (final ActiveHost activeHostFound in hostsDiscoveredInNetwork!) { + final DeviceInTheNetwork tempDeviceInTheNetwork = + DeviceInTheNetwork.createWithAllNecessaryFields( + ip: activeHostFound.ip, + hostId: activeHostFound.hostId, + make: activeHostFound.make, + pingData: activeHostFound.pingData, + currentDeviceIp: ip!, + gatewayIp: gatewayIp!, + ); + activeHostList.add(tempDeviceInTheNetwork); + emit(HostScanState.foundNewDevice(activeHostList)); + } + // emit(HostScanState.loadSuccess(activeHostList)); + } } diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart index a51b5029..88e500f7 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_event.dart @@ -3,4 +3,6 @@ part of 'host_scan_bloc.dart'; @freezed class HostScanEvent with _$HostScanEvent { const factory HostScanEvent.initialized() = Initialized; + + const factory HostScanEvent.startNewScan() = StartNewScan; } diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart index 23f5ad9b..4b35f502 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_state.dart @@ -6,7 +6,13 @@ class HostScanState with _$HostScanState { const factory HostScanState.loadInProgress() = _LoadInProgress; - const factory HostScanState.loadSuccess(String securityBearIp) = _LoadSuccess; + const factory HostScanState.foundNewDevice( + List activeHostList, + ) = FoundNewDevice; + + const factory HostScanState.loadSuccess( + List activeHostList, + ) = LoadSuccess; const factory HostScanState.loadFailure() = _loadFailure; diff --git a/lib/pages/host_scan_page/widgets/host_scan_widget.dart b/lib/pages/host_scan_page/widgets/host_scan_widget.dart index 114c34fd..ec2fc6bd 100644 --- a/lib/pages/host_scan_page/widgets/host_scan_widget.dart +++ b/lib/pages/host_scan_page/widgets/host_scan_widget.dart @@ -1,22 +1,94 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:vernet/pages/host_scan_page/device_in_the_network.dart'; import 'package:vernet/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart'; +import 'package:vernet/pages/network_troubleshoot/port_scan_page.dart'; -class ConfigureNewCbjCompWidgets extends StatelessWidget { +class HostScanWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - // return state.map( - // initial: (_) { - // context.read().add( - // ConfigureNewCbjCompEvent.sendHotSpotInformation( - // cbjCompEntityInBuild, - // ), - // ); - // ); - return const SizedBox(); - }, + return Column( + children: [ + BlocBuilder( + builder: (context, state) { + return state.map( + initial: (_) => Container(), + loadInProgress: (value) { + return Expanded( + child: Container( + margin: const EdgeInsets.all(30), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + CircularProgressIndicator(), + SizedBox( + height: 30, + ), + Text( + 'Searching for devices in your local network', + style: TextStyle( + fontSize: 18, + color: Colors.blue, + ), + ), + ], + ), + ), + ); + }, + foundNewDevice: (FoundNewDevice value) { + final List activeHostList = + value.activeHostList; + + return Expanded( + child: ListView.builder( + itemCount: activeHostList.length, + itemBuilder: (context, index) { + final DeviceInTheNetwork host = activeHostList[index]; + return ListTile( + leading: Icon(host.iconData), + title: Text(host.make), + subtitle: Text(host.ip), + trailing: IconButton( + tooltip: 'Scan open ports for this target', + icon: const Icon(Icons.radar), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PortScanPage(target: host.ip), + ), + ); + }, + ), + onLongPress: () { + Clipboard.setData(ClipboardData(text: host.ip)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('IP copied to clipboard'), + ), + ); + }, + ); + }, + ), + ); + }, + loadFailure: (value) { + return const Text('Failure'); + }, + loadSuccess: (value) { + return const Text('Done'); + }, + error: (Error value) { + return const Text('Error'); + }, + ); + }, + ), + ], ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 5bb2fe92..4324556a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,7 +44,7 @@ dependencies: # Discover network info and configure themselves accordingly network_info_plus: ^2.1.2 # Helps you discover open ports, devices on subnet and more. - network_tools: ^1.0.7 + network_tools: ^1.0.8 # Querying information about the application package, such as CFBundleVersion package_info_plus: ^1.3.0 # Allows you to display progress widgets based on percentage. From 7a13ae6be6a49d69a64398dcc495c645f8525028 Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Tue, 1 Feb 2022 21:28:03 +0200 Subject: [PATCH 03/10] Scan devices now run inside isolate so that the UI will not get stack --- .../host_scna_bloc/host_scan_bloc.dart | 84 +++++++++++++------ .../network_troubleshoot/port_scan_page.dart | 2 +- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index 5bca8a08..096352e5 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -1,4 +1,5 @@ import 'package:bloc/bloc.dart'; +import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:injectable/injectable.dart'; import 'package:network_info_plus/network_info_plus.dart'; @@ -17,16 +18,14 @@ class HostScanBloc extends Bloc { on(_startNewScan); } - /// Will contain all the hosts that got discovered in the network, will be use - /// inorder to cancel on dispose of the page. - Stream? hostsDiscoveredInNetwork; - /// IP of the device in the local network. String? ip; /// Gateway IP of the current network late String? gatewayIp; + String? subnet; + /// List of all ActiveHost devices that got found in the current scan List activeHostList = []; @@ -36,6 +35,7 @@ class HostScanBloc extends Bloc { ) async { emit(const HostScanState.loadInProgress()); ip = await NetworkInfo().getWifiIP(); + subnet = ip!.substring(0, ip!.lastIndexOf('.')); gatewayIp = await NetworkInfo().getWifiGatewayIP(); add(const HostScanEvent.startNewScan()); @@ -45,29 +45,61 @@ class HostScanBloc extends Bloc { StartNewScan event, Emitter emit, ) async { - final String subnet = ip!.substring(0, ip!.lastIndexOf('.')); - activeHostList = []; + activeHostList = await startSearchingDevices(); + emit(HostScanState.foundNewDevice(activeHostList)); - hostsDiscoveredInNetwork = HostScanner.discover( - subnet, - firstSubnet: appSettings.firstSubnet, - lastSubnet: appSettings.lastSubnet, - resultsInIpAscendingOrder: false, - ); - - await for (final ActiveHost activeHostFound in hostsDiscoveredInNetwork!) { - final DeviceInTheNetwork tempDeviceInTheNetwork = - DeviceInTheNetwork.createWithAllNecessaryFields( - ip: activeHostFound.ip, - hostId: activeHostFound.hostId, - make: activeHostFound.make, - pingData: activeHostFound.pingData, - currentDeviceIp: ip!, - gatewayIp: gatewayIp!, - ); - activeHostList.add(tempDeviceInTheNetwork); - emit(HostScanState.foundNewDevice(activeHostList)); - } // emit(HostScanState.loadSuccess(activeHostList)); } + + // TODO: can be improved by returning results from the isolate with a stream + // TODO: and displaying them immediately for each new result. + /// Will search devices in the network inside new isolate + Future> startSearchingDevices() async { + return compute, List>( + (params) async { + final String subnetIsolate = params[0]; + final int firstSubnetIsolate = int.parse(params[1]); + final int lastSubnetIsolate = int.parse(params[2]); + final String currentDeviceIpIsolate = params[3]; + final String gatewayIpIsolate = params[4]; + + final List listOfDevicesTemp = []; + + /// Will contain all the hosts that got discovered in the network, will + /// be use inorder to cancel on dispose of the page. + final Stream hostsDiscoveredInNetwork = + HostScanner.discover( + subnetIsolate, + firstSubnet: firstSubnetIsolate, + lastSubnet: lastSubnetIsolate, + ); + + try { + await for (final ActiveHost activeHostFound + in hostsDiscoveredInNetwork) { + final DeviceInTheNetwork tempDeviceInTheNetwork = + DeviceInTheNetwork.createWithAllNecessaryFields( + ip: activeHostFound.ip, + hostId: activeHostFound.hostId, + make: activeHostFound.make, + pingData: activeHostFound.pingData, + currentDeviceIp: currentDeviceIpIsolate, + gatewayIp: gatewayIpIsolate, + ); + listOfDevicesTemp.add(tempDeviceInTheNetwork); + } + } catch (e) { + print('Error\n$e'); + } + return listOfDevicesTemp; + }, + [ + subnet!, + appSettings.firstSubnet.toString(), + appSettings.lastSubnet.toString(), + ip!, + gatewayIp!, + ], + ); + } } diff --git a/lib/pages/network_troubleshoot/port_scan_page.dart b/lib/pages/network_troubleshoot/port_scan_page.dart index f6e730d6..09628268 100644 --- a/lib/pages/network_troubleshoot/port_scan_page.dart +++ b/lib/pages/network_troubleshoot/port_scan_page.dart @@ -464,7 +464,7 @@ class _PortScanPageState extends State ], ), ), - Divider(height: 4), + const Divider(height: 4), ], ); }, From 77e0aaa50682bab746267ced5569dc4c8768ac4f Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Thu, 3 Feb 2022 15:09:18 +0200 Subject: [PATCH 04/10] Scan devices will now show results as the scan progress an not only all the results only when the scan completes. --- .../host_scna_bloc/host_scan_bloc.dart | 128 +++++++++++------- pubspec.yaml | 2 + 2 files changed, 80 insertions(+), 50 deletions(-) diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index 096352e5..04983242 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -1,7 +1,9 @@ import 'package:bloc/bloc.dart'; +import 'package:dart_ping/dart_ping.dart'; import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:injectable/injectable.dart'; +import 'package:isolate_contactor/isolate_contactor.dart'; import 'package:network_info_plus/network_info_plus.dart'; import 'package:network_tools/network_tools.dart'; import 'package:vernet/main.dart'; @@ -45,61 +47,87 @@ class HostScanBloc extends Bloc { StartNewScan event, Emitter emit, ) async { - activeHostList = await startSearchingDevices(); - emit(HostScanState.foundNewDevice(activeHostList)); + final List paramsTemp = [ + subnet!, + appSettings.firstSubnet.toString(), + appSettings.lastSubnet.toString(), + ]; + final IsolateContactor isolateContactor = + await IsolateContactor.createOwnIsolate(startSearchingDevices); + + isolateContactor.sendMessage(paramsTemp); + + await for (final dynamic message in isolateContactor.onMessage) { + try { + if (message is List) { + final String activeHostFoundIp = message[0] as String; + final int activeHostFoundId = message[1] as int; + final String activeHostFoundMake = message[2] as String; + final PingData activeHostFoundPingData = message[3] as PingData; + + final DeviceInTheNetwork tempDeviceInTheNetwork = + DeviceInTheNetwork.createWithAllNecessaryFields( + ip: activeHostFoundIp, + hostId: activeHostFoundId, + make: activeHostFoundMake, + pingData: activeHostFoundPingData, + currentDeviceIp: ip!, + gatewayIp: gatewayIp!, + ); + + activeHostList.add(tempDeviceInTheNetwork); + emit(const HostScanState.loadInProgress()); + emit(HostScanState.foundNewDevice(activeHostList)); + } + } catch (e) { + emit(const HostScanState.error()); + } + } // emit(HostScanState.loadSuccess(activeHostList)); } - // TODO: can be improved by returning results from the isolate with a stream - // TODO: and displaying them immediately for each new result. /// Will search devices in the network inside new isolate - Future> startSearchingDevices() async { - return compute, List>( - (params) async { - final String subnetIsolate = params[0]; - final int firstSubnetIsolate = int.parse(params[1]); - final int lastSubnetIsolate = int.parse(params[2]); - final String currentDeviceIpIsolate = params[3]; - final String gatewayIpIsolate = params[4]; - - final List listOfDevicesTemp = []; - - /// Will contain all the hosts that got discovered in the network, will - /// be use inorder to cancel on dispose of the page. - final Stream hostsDiscoveredInNetwork = - HostScanner.discover( - subnetIsolate, - firstSubnet: firstSubnetIsolate, - lastSubnet: lastSubnetIsolate, - ); - - try { - await for (final ActiveHost activeHostFound - in hostsDiscoveredInNetwork) { - final DeviceInTheNetwork tempDeviceInTheNetwork = - DeviceInTheNetwork.createWithAllNecessaryFields( - ip: activeHostFound.ip, - hostId: activeHostFound.hostId, - make: activeHostFound.make, - pingData: activeHostFound.pingData, - currentDeviceIp: currentDeviceIpIsolate, - gatewayIp: gatewayIpIsolate, - ); - listOfDevicesTemp.add(tempDeviceInTheNetwork); - } - } catch (e) { - print('Error\n$e'); + static Future startSearchingDevices(dynamic params) async { + final channel = IsolateContactorController(params); + channel.onIsolateMessage.listen((message) async { + List paramsListString = []; + if (message is List) { + paramsListString = message; + } else { + return; + } + + final String subnetIsolate = paramsListString[0]; + final int firstSubnetIsolate = int.parse(paramsListString[1]); + final int lastSubnetIsolate = int.parse(paramsListString[2]); + + /// Will contain all the hosts that got discovered in the network, will + /// be use inorder to cancel on dispose of the page. + final Stream hostsDiscoveredInNetwork = HostScanner.discover( + subnetIsolate, + firstSubnet: firstSubnetIsolate, + lastSubnet: lastSubnetIsolate, + // TODO: check why the results returned in ascending order although I + // TODO: have added "false" here. + resultsInIpAscendingOrder: false, + ); + + try { + await for (final ActiveHost activeHostFound + in hostsDiscoveredInNetwork) { + channel.sendResult( + [ + activeHostFound.ip, + activeHostFound.hostId, + activeHostFound.make, + activeHostFound.pingData, + ], + ); } - return listOfDevicesTemp; - }, - [ - subnet!, - appSettings.firstSubnet.toString(), - appSettings.lastSubnet.toString(), - ip!, - gatewayIp!, - ], - ); + } catch (e) { + print('Error\n$e'); + } + }); } } diff --git a/pubspec.yaml b/pubspec.yaml index 4324556a..73dacd63 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,6 +41,8 @@ dependencies: http: ^0.13.4 # Convenient code generator for get_it injectable: ^1.5.3 + # An easy way to create a new isolate, keep it running and communicate with it. + isolate_contactor: ^1.2.0+1 # Discover network info and configure themselves accordingly network_info_plus: ^2.1.2 # Helps you discover open ports, devices on subnet and more. From 1b53e74d75d721443bfc6f1f3c64d7f942faba17 Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Thu, 3 Feb 2022 16:16:09 +0200 Subject: [PATCH 05/10] Made scan for devices results little bit faster for some reason. --- .../host_scna_bloc/host_scan_bloc.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index 04983242..0ce265e4 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -77,6 +77,14 @@ class HostScanBloc extends Bloc { ); activeHostList.add(tempDeviceInTheNetwork); + activeHostList.sort((a, b) { + final int aIp = + int.parse(a.ip.substring(a.ip.lastIndexOf('.') + 1)); + final int bIp = + int.parse(b.ip.substring(b.ip.lastIndexOf('.') + 1)); + return aIp.compareTo(bIp); + }); + emit(const HostScanState.loadInProgress()); emit(HostScanState.foundNewDevice(activeHostList)); } @@ -108,14 +116,11 @@ class HostScanBloc extends Bloc { subnetIsolate, firstSubnet: firstSubnetIsolate, lastSubnet: lastSubnetIsolate, - // TODO: check why the results returned in ascending order although I - // TODO: have added "false" here. resultsInIpAscendingOrder: false, ); try { - await for (final ActiveHost activeHostFound - in hostsDiscoveredInNetwork) { + hostsDiscoveredInNetwork.listen((activeHostFound) { channel.sendResult( [ activeHostFound.ip, @@ -124,7 +129,7 @@ class HostScanBloc extends Bloc { activeHostFound.pingData, ], ); - } + }); } catch (e) { print('Error\n$e'); } From 8dbd9c6f4e2919fbaec8e6304c9893a3e904e4ad Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Fri, 4 Feb 2022 11:07:17 +0200 Subject: [PATCH 06/10] Not working testing creating multiple isolates for network scan --- .../host_scan_page/device_in_the_network.dart | 17 +++ .../host_scna_bloc/host_scan_bloc.dart | 100 ++++++++---------- 2 files changed, 60 insertions(+), 57 deletions(-) diff --git a/lib/pages/host_scan_page/device_in_the_network.dart b/lib/pages/host_scan_page/device_in_the_network.dart index 8da60eba..bb20aa10 100644 --- a/lib/pages/host_scan_page/device_in_the_network.dart +++ b/lib/pages/host_scan_page/device_in_the_network.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:dart_ping/dart_ping.dart'; import 'package:flutter/material.dart'; +import 'package:network_tools/network_tools.dart'; /// Contains all the information of a device in the network including /// icon, open ports and in the future host name and mDNS name @@ -15,6 +16,22 @@ class DeviceInTheNetwork { this.hostId, }); + /// Create the object from active host with the correct field and icon + factory DeviceInTheNetwork.createFromActiveHost({ + required ActiveHost activeHost, + required String currentDeviceIp, + required String gatewayIp, + }) { + return DeviceInTheNetwork.createWithAllNecessaryFields( + ip: activeHost.ip, + hostId: activeHost.hostId, + make: activeHost.make, + pingData: activeHost.pingData, + currentDeviceIp: currentDeviceIp, + gatewayIp: gatewayIp, + ); + } + /// Create the object with the correct field and icon factory DeviceInTheNetwork.createWithAllNecessaryFields({ required String ip, diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index 0ce265e4..5cac8ba6 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -1,5 +1,6 @@ +import 'dart:async'; + import 'package:bloc/bloc.dart'; -import 'package:dart_ping/dart_ping.dart'; import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:injectable/injectable.dart'; @@ -47,51 +48,47 @@ class HostScanBloc extends Bloc { StartNewScan event, Emitter emit, ) async { - final List paramsTemp = [ - subnet!, - appSettings.firstSubnet.toString(), - appSettings.lastSubnet.toString(), - ]; - - final IsolateContactor isolateContactor = - await IsolateContactor.createOwnIsolate(startSearchingDevices); - - isolateContactor.sendMessage(paramsTemp); - - await for (final dynamic message in isolateContactor.onMessage) { - try { - if (message is List) { - final String activeHostFoundIp = message[0] as String; - final int activeHostFoundId = message[1] as int; - final String activeHostFoundMake = message[2] as String; - final PingData activeHostFoundPingData = message[3] as PingData; - - final DeviceInTheNetwork tempDeviceInTheNetwork = - DeviceInTheNetwork.createWithAllNecessaryFields( - ip: activeHostFoundIp, - hostId: activeHostFoundId, - make: activeHostFoundMake, - pingData: activeHostFoundPingData, - currentDeviceIp: ip!, - gatewayIp: gatewayIp!, - ); - - activeHostList.add(tempDeviceInTheNetwork); - activeHostList.sort((a, b) { - final int aIp = - int.parse(a.ip.substring(a.ip.lastIndexOf('.') + 1)); - final int bIp = - int.parse(b.ip.substring(b.ip.lastIndexOf('.') + 1)); - return aIp.compareTo(bIp); - }); - - emit(const HostScanState.loadInProgress()); - emit(HostScanState.foundNewDevice(activeHostList)); + const int scanRangeForIsolate = 10; + + for (int i = appSettings.firstSubnet; i <= 100; i += scanRangeForIsolate) { + final IsolateContactor isolateContactor = + await IsolateContactor.createOwnIsolate(startSearchingDevices); + + isolateContactor.sendMessage([ + subnet!, + i.toString(), + (i + scanRangeForIsolate).toString(), + ]); + await for (final dynamic message in isolateContactor.onMessage) { + try { + if (message is ActiveHost) { + final DeviceInTheNetwork tempDeviceInTheNetwork = + DeviceInTheNetwork.createFromActiveHost( + activeHost: message, + currentDeviceIp: ip!, + gatewayIp: gatewayIp!, + ); + + activeHostList.add(tempDeviceInTheNetwork); + activeHostList.sort((a, b) { + final int aIp = + int.parse(a.ip.substring(a.ip.lastIndexOf('.') + 1)); + final int bIp = + int.parse(b.ip.substring(b.ip.lastIndexOf('.') + 1)); + return aIp.compareTo(bIp); + }); + emit(const HostScanState.loadInProgress()); + emit(HostScanState.foundNewDevice(activeHostList)); + } else if (message is String && message == 'Done') { + isolateContactor.dispose(); + } + } catch (e) { + emit(const HostScanState.error()); } - } catch (e) { - emit(const HostScanState.error()); } } + print('The end of the scan'); + // emit(HostScanState.loadSuccess(activeHostList)); } @@ -116,23 +113,12 @@ class HostScanBloc extends Bloc { subnetIsolate, firstSubnet: firstSubnetIsolate, lastSubnet: lastSubnetIsolate, - resultsInIpAscendingOrder: false, ); - try { - hostsDiscoveredInNetwork.listen((activeHostFound) { - channel.sendResult( - [ - activeHostFound.ip, - activeHostFound.hostId, - activeHostFound.make, - activeHostFound.pingData, - ], - ); - }); - } catch (e) { - print('Error\n$e'); + await for (final ActiveHost activeHostFound in hostsDiscoveredInNetwork) { + channel.sendResult(activeHostFound); } + channel.sendResult('Done'); }); } } From 3712582e202bf293da5a5b3c70c035a4e1490a20 Mon Sep 17 00:00:00 2001 From: Paras Date: Mon, 7 Feb 2022 23:20:38 +0530 Subject: [PATCH 07/10] edge case fixed for lastsubnet --- .../host_scna_bloc/host_scan_bloc.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index 5cac8ba6..f18738f0 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -48,16 +48,20 @@ class HostScanBloc extends Bloc { StartNewScan event, Emitter emit, ) async { - const int scanRangeForIsolate = 10; - - for (int i = appSettings.firstSubnet; i <= 100; i += scanRangeForIsolate) { + const int scanRangeForIsolate = 51; + for (int i = appSettings.firstSubnet; + i <= appSettings.lastSubnet; + i += scanRangeForIsolate) { final IsolateContactor isolateContactor = await IsolateContactor.createOwnIsolate(startSearchingDevices); - + int limit = i + scanRangeForIsolate; + if (limit >= 254) { + limit = 254; + } isolateContactor.sendMessage([ subnet!, i.toString(), - (i + scanRangeForIsolate).toString(), + limit.toString(), ]); await for (final dynamic message in isolateContactor.onMessage) { try { @@ -106,6 +110,7 @@ class HostScanBloc extends Bloc { final String subnetIsolate = paramsListString[0]; final int firstSubnetIsolate = int.parse(paramsListString[1]); final int lastSubnetIsolate = int.parse(paramsListString[2]); + print('scanning from $firstSubnetIsolate to $lastSubnetIsolate'); /// Will contain all the hosts that got discovered in the network, will /// be use inorder to cancel on dispose of the page. From 42b23d102d41f5e7318b9ef5620acc7ce2cf717b Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Sun, 13 Feb 2022 18:16:34 +0200 Subject: [PATCH 08/10] Fix limit stop at 254 even if the user specified otherwise, fix new code with isolates does not work on build with fdroid --- android/app/src/debug/AndroidManifest.xml | 50 +++++++++++++++++++ android/app/src/profile/AndroidManifest.xml | 50 +++++++++++++++++++ .../host_scna_bloc/host_scan_bloc.dart | 6 +-- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index c6c432c0..65ff0849 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -3,5 +3,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index c6c432c0..65ff0849 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -3,5 +3,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart index f18738f0..6414c722 100644 --- a/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart +++ b/lib/pages/host_scan_page/host_scna_bloc/host_scan_bloc.dart @@ -51,12 +51,12 @@ class HostScanBloc extends Bloc { const int scanRangeForIsolate = 51; for (int i = appSettings.firstSubnet; i <= appSettings.lastSubnet; - i += scanRangeForIsolate) { + i += scanRangeForIsolate + 1) { final IsolateContactor isolateContactor = await IsolateContactor.createOwnIsolate(startSearchingDevices); int limit = i + scanRangeForIsolate; - if (limit >= 254) { - limit = 254; + if (limit >= appSettings.lastSubnet) { + limit = appSettings.lastSubnet; } isolateContactor.sendMessage([ subnet!, From 4651cdb950129636cae9a674c614e320c4272ffc Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Sun, 13 Feb 2022 18:39:48 +0200 Subject: [PATCH 09/10] Updated all packages to the last version --- analysis_options.yaml | 4 ---- pubspec.yaml | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index b148779e..2395de07 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -26,9 +26,5 @@ linter: sort_constructors_first: true - prefer_single_quotes: true - # Good packages document everything public_member_api_docs: true - - lines_longer_than_80_chars: true diff --git a/pubspec.yaml b/pubspec.yaml index 73dacd63..8ce2d829 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,15 +50,15 @@ dependencies: # Querying information about the application package, such as CFBundleVersion package_info_plus: ^1.3.0 # Allows you to display progress widgets based on percentage. - percent_indicator: ^3.4.0 + percent_indicator: ^4.0.0 # Popup that ask for the requested permission permission_handler: ^8.3.0 # A wrapper around InheritedWidget to make them easier to use and more reusable. provider: ^6.0.2 # Reading and writing simple key-value pairs - shared_preferences: ^2.0.12 + shared_preferences: ^2.0.13 # Plugin for launching a URL - url_launcher: ^6.0.18 + url_launcher: ^6.0.20 dev_dependencies: # A build system for Dart code generation and modular compilation. @@ -71,7 +71,7 @@ dev_dependencies: # Convenient code generator for get_it. injectable_generator: ^1.5.3 # Collection of lint rules for Dart and Flutter projects. - lint: ^1.8.1 + lint: ^1.8.2 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec From 0d502a484ac92149aafb34b4765d48e8adfe2006 Mon Sep 17 00:00:00 2001 From: guyluz11 Date: Sun, 13 Feb 2022 19:01:44 +0200 Subject: [PATCH 10/10] Small fix for the radius of CircularPercentIndicator because of braking changes in the new version of percent_indicator --- lib/pages/host_scan_page/host_scan_page.dart | 2 +- lib/pages/network_troubleshoot/port_scan_page.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/host_scan_page/host_scan_page.dart b/lib/pages/host_scan_page/host_scan_page.dart index cb2be54f..d281e103 100644 --- a/lib/pages/host_scan_page/host_scan_page.dart +++ b/lib/pages/host_scan_page/host_scan_page.dart @@ -15,7 +15,7 @@ class HostScanPage extends StatelessWidget { // Container( // margin: const EdgeInsets.only(right: 20.0), // child: CircularPercentIndicator( - // radius: 20.0, + // radius: 10.0, // lineWidth: 2.5, // percent: _progress / 100, // backgroundColor: Colors.grey, diff --git a/lib/pages/network_troubleshoot/port_scan_page.dart b/lib/pages/network_troubleshoot/port_scan_page.dart index 09628268..b763392d 100644 --- a/lib/pages/network_troubleshoot/port_scan_page.dart +++ b/lib/pages/network_troubleshoot/port_scan_page.dart @@ -226,7 +226,7 @@ class _PortScanPageState extends State Container( margin: const EdgeInsets.only(right: 20.0), child: CircularPercentIndicator( - radius: 20.0, + radius: 10.0, lineWidth: 2.5, percent: _progress / 100, backgroundColor: Colors.grey,