diff --git a/lib/common/utils/connection_checker.dart b/lib/common/utils/connection_checker.dart new file mode 100644 index 00000000..e6d08bea --- /dev/null +++ b/lib/common/utils/connection_checker.dart @@ -0,0 +1,30 @@ +import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart'; + +/// The default parameters for DNS lookups +const Map dnsParameters = { + 'name': 'ya.ru', + 'type': 'A', + 'dnssec': '1', +}; + +/// The default headers for DNS lookups +const Map dnsHeaders = { + 'Accept': 'application/dns-json', + 'Cache-Control': 'no-cache', + 'Content-Type': 'application/json', +}; + +final List defaultAddresses = [ + AddressCheckOptions( + Uri.parse('https://yandex.cloudflare-dns.com/dns-query').replace( + queryParameters: dnsParameters, + ), + headers: dnsHeaders, + ), + AddressCheckOptions( + Uri.parse('https://mozilla.cloudflare-dns.com/dns-query').replace( + queryParameters: dnsParameters, + ), + headers: dnsHeaders, + ), +]; diff --git a/lib/service_locator.dart b/lib/service_locator.dart index f9f3bc53..3731e8f4 100644 --- a/lib/service_locator.dart +++ b/lib/service_locator.dart @@ -3,6 +3,7 @@ import 'package:dio/dio.dart'; import 'package:get_it/get_it.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:rtu_mirea_app/common/oauth.dart'; +import 'package:rtu_mirea_app/common/utils/connection_checker.dart'; import 'package:rtu_mirea_app/data/datasources/app_settings_local.dart'; import 'package:rtu_mirea_app/data/datasources/forum_local.dart'; import 'package:rtu_mirea_app/data/datasources/forum_remote.dart'; @@ -248,7 +249,9 @@ Future setup() async { encryptedSharedPreferences: true, )); getIt.registerLazySingleton(() => secureStorage); - getIt.registerLazySingleton(() => InternetConnectionCheckerPlus()); + getIt.registerLazySingleton(() => + InternetConnectionCheckerPlus.createInstance( + addresses: defaultAddresses)); final PackageInfo packageInfo = await PackageInfo.fromPlatform(); getIt.registerLazySingleton(() => packageInfo); getIt.registerLazySingleton(() => LksOauth2());