From 62c5e55317004b6674ada34b86e4b4211a9fd4fc Mon Sep 17 00:00:00 2001 From: Hiddify Date: Thu, 22 Feb 2024 10:05:15 +0100 Subject: [PATCH] fix: exception reporting on failing in getting ip --- lib/features/intro/widget/intro_page.dart | 2 ++ lib/features/proxy/active/active_proxy_notifier.dart | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/features/intro/widget/intro_page.dart b/lib/features/intro/widget/intro_page.dart index 7b3bd359..60d1729a 100644 --- a/lib/features/intro/widget/intro_page.dart +++ b/lib/features/intro/widget/intro_page.dart @@ -130,9 +130,11 @@ class IntroPage extends HookConsumerWidget with PresLogger { await ref .read(localePreferencesProvider.notifier) .changeLocale(regionLocale.locale); + return; } catch (e) { loggy.warning('Could not get the local country code based on timezone'); } + try { final response = await http.get(Uri.parse('https://api.ip.sb/json/')); diff --git a/lib/features/proxy/active/active_proxy_notifier.dart b/lib/features/proxy/active/active_proxy_notifier.dart index c3879dd6..4628ec74 100644 --- a/lib/features/proxy/active/active_proxy_notifier.dart +++ b/lib/features/proxy/active/active_proxy_notifier.dart @@ -52,7 +52,8 @@ class IpInfoNotifier extends _$IpInfoNotifier with AppLogger { .getOrElse( (err) { loggy.warning("error getting proxy ip info", err, StackTrace.current); - throw err; + // throw err; //hiddify: remove exception to be logged + throw const UnknownIp(); }, ).run(); @@ -101,10 +102,15 @@ class ActiveProxyNotifier extends _$ActiveProxyNotifier with AppLogger { final _urlTestThrottler = Throttler(const Duration(seconds: 2)); - Future urlTest(String groupTag) async { + Future urlTest(String groupTag_) async { + var groupTag = groupTag_; _urlTestThrottler( () async { loggy.debug("testing group: [$groupTag]"); + if (!["auto", "select"].contains(groupTag)) { + loggy.warning("only proxy group can do url test"); + groupTag = "select"; + } if (state case AsyncData()) { await ref.read(hapticServiceProvider.notifier).lightImpact(); await ref