From fbbda9329092dd3cd3fb2d1212a122069a928fed Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Thu, 5 Oct 2023 21:28:52 +0330 Subject: [PATCH 1/5] Add new protocols to link parser --- lib/domain/singbox/proxy_type.dart | 1 + lib/utils/link_parsers.dart | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/domain/singbox/proxy_type.dart b/lib/domain/singbox/proxy_type.dart index a6db3c27..b77cadd4 100644 --- a/lib/domain/singbox/proxy_type.dart +++ b/lib/domain/singbox/proxy_type.dart @@ -4,6 +4,7 @@ enum ProxyType { dns("DNS"), socks("SOCKS"), http("HTTP"), + shadowsocks("Shadowsocks"), vmess("VMess"), trojan("Trojan"), naive("Naive"), diff --git a/lib/utils/link_parsers.dart b/lib/utils/link_parsers.dart index ad79d87d..378ea4e3 100644 --- a/lib/utils/link_parsers.dart +++ b/lib/utils/link_parsers.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:hiddify/domain/clash/clash.dart'; +import 'package:hiddify/domain/singbox/singbox.dart'; import 'package:hiddify/utils/validators.dart'; typedef ProfileLink = ({String url, String name}); @@ -9,7 +9,15 @@ typedef ProfileLink = ({String url, String name}); abstract class LinkParser { // protocols schemas static const protocols = {'clash', 'clashmeta', 'sing-box', 'hiddify'}; - static const rawProtocols = {'vmess', 'vless', 'trojan', 'ss', 'tuic'}; + static const rawProtocols = { + 'ss', + 'vmess', + 'vless', + 'trojan', + 'tuic', + 'hysteria2', + 'ssh', + }; static ProfileLink? parse(String link) { return simple(link) ?? deep(link); @@ -32,10 +40,13 @@ abstract class LinkParser { final fragment = uri.hasFragment ? Uri.decodeComponent(uri.fragment) : null; final name = switch (uri.scheme) { - 'ss' => fragment ?? ProxyType.shadowSocks.label, - 'vless' => fragment ?? ProxyType.vless.label, - 'tuic' => fragment ?? ProxyType.tuic.label, + 'ss' => fragment ?? ProxyType.shadowsocks.label, 'vmess' => ProxyType.vmess.label, + 'vless' => fragment ?? ProxyType.vless.label, + 'trojan' => fragment ?? ProxyType.trojan.label, + 'tuic' => fragment ?? ProxyType.tuic.label, + 'hy2' || 'hysteria2' => fragment ?? ProxyType.hysteria.label, + 'ssh' => fragment ?? ProxyType.ssh.label, _ => null, }; if (name != null) { From 3aa8273210d42981ad2342ee5529f6d4c3499e26 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Thu, 5 Oct 2023 21:49:36 +0330 Subject: [PATCH 2/5] Add ignore app update version --- lib/features/about/view/about_page.dart | 3 ++- lib/features/common/app_update_notifier.dart | 20 +++++++++++++++++++- lib/features/common/new_version_dialog.dart | 10 ++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/features/about/view/about_page.dart b/lib/features/about/view/about_page.dart index d8630f15..d7fc055d 100644 --- a/lib/features/about/view/about_page.dart +++ b/lib/features/about/view/about_page.dart @@ -24,7 +24,8 @@ class AboutPage extends HookConsumerWidget { (_, next) async { if (!context.mounted) return; switch (next) { - case AppUpdateStateAvailable(:final versionInfo): + case AppUpdateStateAvailable(:final versionInfo) || + AppUpdateStateIgnored(:final versionInfo): return NewVersionDialog( appInfo.presentVersion, versionInfo, diff --git a/lib/features/common/app_update_notifier.dart b/lib/features/common/app_update_notifier.dart index d55c3b9f..dcfe4743 100644 --- a/lib/features/common/app_update_notifier.dart +++ b/lib/features/common/app_update_notifier.dart @@ -6,6 +6,7 @@ import 'package:hiddify/data/data_providers.dart'; import 'package:hiddify/domain/app/app.dart'; import 'package:hiddify/features/common/new_version_dialog.dart'; import 'package:hiddify/services/service_providers.dart'; +import 'package:hiddify/utils/pref_notifier.dart'; import 'package:hiddify/utils/utils.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; @@ -20,6 +21,8 @@ class AppUpdateState with _$AppUpdateState { const factory AppUpdateState.error(AppFailure error) = AppUpdateStateError; const factory AppUpdateState.available(RemoteVersionInfo versionInfo) = AppUpdateStateAvailable; + const factory AppUpdateState.ignored(RemoteVersionInfo versionInfo) = + AppUpdateStateIgnored; const factory AppUpdateState.notAvailable() = AppUpdateStateNotAvailable; } @@ -31,6 +34,12 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger { return const AppUpdateState.initial(); } + Pref get _ignoreReleasePref => Pref( + ref.read(sharedPreferencesProvider), + 'ignored_release_version', + null, + ); + Future check() async { loggy.debug("checking for update"); state = const AppUpdateState.checking(); @@ -54,7 +63,10 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger { return state = AppUpdateState.error(err); }, (remote) { - if (remote.version.compareTo(currentVersion) > 0) { + if (remote.version == _ignoreReleasePref.getValue()) { + loggy.debug("ignored release [${remote.version}]"); + return state = AppUpdateStateIgnored(remote); + } else if (remote.version.compareTo(currentVersion) > 0) { loggy.debug("new version available: $remote"); return state = AppUpdateState.available(remote); } @@ -66,6 +78,12 @@ class AppUpdateNotifier extends _$AppUpdateNotifier with AppLogger { ).run(); } + Future ignoreRelease(RemoteVersionInfo versionInfo) async { + loggy.debug("ignoring release [${versionInfo.version}]"); + await _ignoreReleasePref.update(versionInfo.version); + state = AppUpdateStateIgnored(versionInfo); + } + Future _schedule() async { loggy.debug("scheduling app update checker"); return ref.read(cronServiceProvider).schedule( diff --git a/lib/features/common/new_version_dialog.dart b/lib/features/common/new_version_dialog.dart index 20ef11e0..197b32c4 100644 --- a/lib/features/common/new_version_dialog.dart +++ b/lib/features/common/new_version_dialog.dart @@ -3,6 +3,7 @@ import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hiddify/core/core_providers.dart'; import 'package:hiddify/domain/app/app.dart'; +import 'package:hiddify/features/common/app_update_notifier.dart'; import 'package:hiddify/utils/utils.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -11,7 +12,6 @@ class NewVersionDialog extends HookConsumerWidget with PresLogger { NewVersionDialog( this.currentVersion, this.newVersion, { - // super.key, this.canIgnore = true, }) : super(key: _dialogKey); @@ -79,9 +79,11 @@ class NewVersionDialog extends HookConsumerWidget with PresLogger { actions: [ if (canIgnore) TextButton( - onPressed: () { - // TODO add prefs for ignoring version - context.pop(); + onPressed: () async { + await ref + .read(appUpdateNotifierProvider.notifier) + .ignoreRelease(newVersion); + if (context.mounted) context.pop(); }, child: Text(t.appUpdate.ignoreBtnTxt), ), From c96a1ebb20566f3551badd0175e3ad2f52b155db Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Thu, 5 Oct 2023 22:47:24 +0330 Subject: [PATCH 3/5] Fix bugs --- lib/data/repository/core_facade_impl.dart | 2 +- .../repository/profiles_repository_impl.dart | 2 +- lib/features/about/view/about_page.dart | 19 ++++++++++--------- lib/features/intro/view/intro_page.dart | 2 +- .../proxies/notifier/proxies_notifier.dart | 2 +- .../settings/view/per_app_proxy_page.dart | 2 +- lib/services/singbox/ffi_singbox_service.dart | 16 ++++++++-------- .../singbox/mobile_singbox_service.dart | 2 +- lib/utils/sentry_loggy_integration.dart | 2 +- libcore | 2 +- 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/data/repository/core_facade_impl.dart b/lib/data/repository/core_facade_impl.dart index 7600957b..5c83f87d 100644 --- a/lib/data/repository/core_facade_impl.dart +++ b/lib/data/repository/core_facade_impl.dart @@ -137,7 +137,7 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade { }).toList(); }).handleExceptions( (error, stackTrace) { - loggy.warning("error watching outbounds", error, stackTrace); + loggy.error("error watching outbounds", error, stackTrace); return CoreServiceFailure.unexpected(error, stackTrace); }, ); diff --git a/lib/data/repository/profiles_repository_impl.dart b/lib/data/repository/profiles_repository_impl.dart index afc14ae0..cc05cd30 100644 --- a/lib/data/repository/profiles_repository_impl.dart +++ b/lib/data/repository/profiles_repository_impl.dart @@ -40,7 +40,7 @@ class ProfilesRepositoryImpl Stream> watchActiveProfile() { return profilesDao.watchActiveProfile().handleExceptions( (error, stackTrace) { - loggy.warning("error watching active profile", error, stackTrace); + loggy.error("error watching active profile", error, stackTrace); return ProfileUnexpectedFailure(error, stackTrace); }, ); diff --git a/lib/features/about/view/about_page.dart b/lib/features/about/view/about_page.dart index d7fc055d..036abdc7 100644 --- a/lib/features/about/view/about_page.dart +++ b/lib/features/about/view/about_page.dart @@ -109,15 +109,16 @@ class AboutPage extends HookConsumerWidget { .check(); }, ), - ListTile( - title: Text(t.settings.general.openWorkingDir), - trailing: const Icon(Icons.arrow_outward_outlined), - onTap: () async { - final path = - ref.read(filesEditorServiceProvider).workingDir.uri; - await UriUtils.tryLaunch(path); - }, - ), + if (PlatformUtils.isDesktop) + ListTile( + title: Text(t.settings.general.openWorkingDir), + trailing: const Icon(Icons.arrow_outward_outlined), + onTap: () async { + final path = + ref.read(filesEditorServiceProvider).workingDir.uri; + await UriUtils.tryLaunch(path); + }, + ), ], ), ), diff --git a/lib/features/intro/view/intro_page.dart b/lib/features/intro/view/intro_page.dart index 1ded6d56..54204917 100644 --- a/lib/features/intro/view/intro_page.dart +++ b/lib/features/intro/view/intro_page.dart @@ -73,7 +73,7 @@ class IntroPage extends HookConsumerWidget with PresLogger { try { await Sentry.close(); } catch (error, stackTrace) { - loggy.warning( + loggy.error( "could not disable analytics", error, stackTrace, diff --git a/lib/features/proxies/notifier/proxies_notifier.dart b/lib/features/proxies/notifier/proxies_notifier.dart index abbd8912..e7904397 100644 --- a/lib/features/proxies/notifier/proxies_notifier.dart +++ b/lib/features/proxies/notifier/proxies_notifier.dart @@ -123,7 +123,7 @@ class ProxiesNotifier extends _$ProxiesNotifier with AppLogger { loggy.debug("testing group: [$groupTag]"); if (state case AsyncData()) { await ref.read(coreFacadeProvider).urlTest(groupTag).getOrElse((err) { - loggy.warning("error testing group", err); + loggy.error("error testing group", err); throw err; }).run(); } diff --git a/lib/features/settings/view/per_app_proxy_page.dart b/lib/features/settings/view/per_app_proxy_page.dart index afcebe82..18fc3ef0 100644 --- a/lib/features/settings/view/per_app_proxy_page.dart +++ b/lib/features/settings/view/per_app_proxy_page.dart @@ -26,7 +26,7 @@ Future> installedPackagesInfo( .watch(platformSettingsProvider) .getInstalledPackages() .getOrElse((err) { - _logger.warning("error getting installed packages", err); + _logger.error("error getting installed packages", err); throw err; }).run(); } diff --git a/lib/services/singbox/ffi_singbox_service.dart b/lib/services/singbox/ffi_singbox_service.dart index 21488eee..e2f75d9c 100644 --- a/lib/services/singbox/ffi_singbox_service.dart +++ b/lib/services/singbox/ffi_singbox_service.dart @@ -191,7 +191,7 @@ class FFISingboxService _logger.debug("stopping status command client"); final err = _box.stopCommandClient(1).cast().toDartString(); if (err.isNotEmpty) { - _logger.warning("error stopping status client"); + _logger.error("error stopping status client"); } receiver.close(); _statusStream = null; @@ -200,12 +200,12 @@ class FFISingboxService (event) { if (event case String _) { if (event.startsWith('error:')) { - loggy.warning("[status client] error received: $event"); + loggy.error("[status client] error received: $event"); throw event.replaceFirst('error:', ""); } return event; } - loggy.warning("[status client] unexpected type, msg: $event"); + loggy.error("[status client] unexpected type, msg: $event"); throw "invalid type"; }, ); @@ -215,7 +215,7 @@ class FFISingboxService .cast() .toDartString(); if (err.isNotEmpty) { - loggy.warning("error starting status command: $err"); + loggy.error("error starting status command: $err"); throw err; } @@ -231,7 +231,7 @@ class FFISingboxService _logger.debug("stopping group command client"); final err = _box.stopCommandClient(4).cast().toDartString(); if (err.isNotEmpty) { - _logger.warning("error stopping group client"); + _logger.error("error stopping group client"); } receiver.close(); _groupsStream = null; @@ -240,12 +240,12 @@ class FFISingboxService (event) { if (event case String _) { if (event.startsWith('error:')) { - loggy.warning("[group client] error received: $event"); + loggy.error("[group client] error received: $event"); throw event.replaceFirst('error:', ""); } return event; } - loggy.warning("[group client] unexpected type, msg: $event"); + loggy.error("[group client] unexpected type, msg: $event"); throw "invalid type"; }, ); @@ -255,7 +255,7 @@ class FFISingboxService .cast() .toDartString(); if (err.isNotEmpty) { - loggy.warning("error starting group command: $err"); + loggy.error("error starting group command: $err"); throw err; } diff --git a/lib/services/singbox/mobile_singbox_service.dart b/lib/services/singbox/mobile_singbox_service.dart index a4bc5b91..83d1e1cc 100644 --- a/lib/services/singbox/mobile_singbox_service.dart +++ b/lib/services/singbox/mobile_singbox_service.dart @@ -120,7 +120,7 @@ class MobileSingboxService if (event case String _) { return event; } - loggy.warning("[group client] unexpected type, msg: $event"); + loggy.error("[group client] unexpected type, msg: $event"); throw "invalid type"; }, ); diff --git a/lib/utils/sentry_loggy_integration.dart b/lib/utils/sentry_loggy_integration.dart index e9b20563..5fc05ba3 100644 --- a/lib/utils/sentry_loggy_integration.dart +++ b/lib/utils/sentry_loggy_integration.dart @@ -7,7 +7,7 @@ class SentryLoggyIntegration extends LoggyPrinter implements Integration { SentryLoggyIntegration({ LogLevel minBreadcrumbLevel = LogLevel.info, - LogLevel minEventLevel = LogLevel.warning, + LogLevel minEventLevel = LogLevel.error, }) : _minBreadcrumbLevel = minBreadcrumbLevel, _minEventLevel = minEventLevel; diff --git a/libcore b/libcore index 75e342b6..dced5a30 160000 --- a/libcore +++ b/libcore @@ -1 +1 @@ -Subproject commit 75e342b6bacca604b4cc19b397aa29124e5c2338 +Subproject commit dced5a30d0cf32c5ced6f002f63008f6fe450101 From ac670a58c313a3eaf874aaa14beeb85697d86a56 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Thu, 5 Oct 2023 22:48:11 +0330 Subject: [PATCH 4/5] Add proxy tag sanitization --- dependencies.properties | 2 +- lib/domain/singbox/outbounds.dart | 5 +++++ lib/features/proxies/widgets/proxy_tile.dart | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dependencies.properties b/dependencies.properties index 631acaac..9bc4ec32 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1 +1 @@ -core.version=0.4.1 \ No newline at end of file +core.version=0.5.0 \ No newline at end of file diff --git a/lib/domain/singbox/outbounds.dart b/lib/domain/singbox/outbounds.dart index f934ab7e..a9871256 100644 --- a/lib/domain/singbox/outbounds.dart +++ b/lib/domain/singbox/outbounds.dart @@ -21,6 +21,8 @@ class OutboundGroup with _$OutboundGroup { @freezed class OutboundGroupItem with _$OutboundGroupItem { + const OutboundGroupItem._(); + @JsonSerializable(fieldRename: FieldRename.kebab) const factory OutboundGroupItem({ required String tag, @@ -28,6 +30,9 @@ class OutboundGroupItem with _$OutboundGroupItem { required int urlTestDelay, }) = _OutboundGroupItem; + String get sanitizedTag => + tag.replaceFirst(RegExp(r"\ยง[^]*"), "").trimRight(); + factory OutboundGroupItem.fromJson(Map json) => _$OutboundGroupItemFromJson(json); } diff --git a/lib/features/proxies/widgets/proxy_tile.dart b/lib/features/proxies/widgets/proxy_tile.dart index 251038be..e4ed134a 100644 --- a/lib/features/proxies/widgets/proxy_tile.dart +++ b/lib/features/proxies/widgets/proxy_tile.dart @@ -21,7 +21,7 @@ class ProxyTile extends HookConsumerWidget { return ListTile( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), title: Text( - proxy.tag, + proxy.sanitizedTag, overflow: TextOverflow.ellipsis, ), leading: Padding( From a60cc7a5a2f9960e1dc620f0c2ff93cfd7818dcb Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Thu, 5 Oct 2023 22:54:36 +0330 Subject: [PATCH 5/5] release: version 0.8.0 --- changelog.md | 26 +++++++++++++++++++++++++- pubspec.yaml | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index cdabb407..ea09d264 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,31 @@ # Changelog -## 0.7.2 (2023-10-04) +## 0.8.0 (2023-10-05) + +#### New + +* Add russian lang. + +#### Other + +* Add proxy tag sanitization. + +* Fix bugs. + +* Add ignore app update version. + +* Add new protocols to link parser. + +* Auto update translations on release. + +* Update translation. + +* Remove param in ru translation. + + + +## v0.7.2 (2023-10-04) #### Other diff --git a/pubspec.yaml b/pubspec.yaml index fa09d274..b6398935 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: hiddify description: A Proxy Frontend. publish_to: "none" -version: 0.7.2+702 +version: 0.8.0+800 environment: sdk: ">=3.0.5 <4.0.0"