From 798d36a5ef36cae1d091e640f852a5c33a38dc4f Mon Sep 17 00:00:00 2001 From: Hiddify Date: Sun, 17 Mar 2024 19:20:59 +0100 Subject: [PATCH] fix: bug in warp config --- .vscode/launch.json | 4 +- .../notifier/warp_option_notifier.dart | 4 +- .../service/platform_singbox_service.dart | 45 ++++++++++++++++--- libcore | 2 +- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3fcb0f2b..fa9c6ea9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,6 +7,8 @@ "type": "dart", "flutterMode": "debug", "program": "lib/main.dart", + // "args": ["-d","192.168.1.35:36463"] + }, { "name": "Hiddify Dev Release", @@ -36,7 +38,7 @@ "program": "lib/main.dart", "args": [ "--app-id", - "com.hiddify.ios" + "app.hiddify.com" ], "deviceId": "designed-for-ipad", } diff --git a/lib/features/config_option/notifier/warp_option_notifier.dart b/lib/features/config_option/notifier/warp_option_notifier.dart index 31cb58a9..5dcdc2ed 100644 --- a/lib/features/config_option/notifier/warp_option_notifier.dart +++ b/lib/features/config_option/notifier/warp_option_notifier.dart @@ -65,7 +65,9 @@ class WarpOptionNotifier extends _$WarpOptionNotifier with AppLogger { await ref .read(ConfigOptions.warpAccessToken.notifier) .update(warp.accessToken); - + await ref + .read(ConfigOptions.warpWireguardConfig.notifier) + .update(warp.wireguardConfig); return warp.log; }); diff --git a/lib/singbox/service/platform_singbox_service.dart b/lib/singbox/service/platform_singbox_service.dart index e7707efa..e8376584 100644 --- a/lib/singbox/service/platform_singbox_service.dart +++ b/lib/singbox/service/platform_singbox_service.dart @@ -9,14 +9,11 @@ import 'package:hiddify/singbox/model/singbox_outbound.dart'; import 'package:hiddify/singbox/model/singbox_stats.dart'; import 'package:hiddify/singbox/model/singbox_status.dart'; import 'package:hiddify/singbox/model/warp_account.dart'; -import 'package:hiddify/singbox/service/core_singbox_service.dart'; import 'package:hiddify/singbox/service/singbox_service.dart'; import 'package:hiddify/utils/custom_loggers.dart'; import 'package:rxdart/rxdart.dart'; -class PlatformSingboxService extends CoreSingboxService - with InfraLogger - implements SingboxService { +class PlatformSingboxService with InfraLogger implements SingboxService { static const channelPrefix = "com.hiddify.app"; static const methodChannel = MethodChannel("$channelPrefix/method"); @@ -49,13 +46,34 @@ class PlatformSingboxService extends CoreSingboxService TaskEither setup(Directories directories, bool debug) { return TaskEither( () async { - await methodChannel.invokeMethod("setup"); + if (!Platform.isIOS) { + return right(unit); + } + await methodChannel.invokeMethod("setup"); return right(unit); }, ); } + @override + TaskEither validateConfigByPath( + String path, + String tempPath, + bool debug, + ) { + return TaskEither( + () async { + final message = await methodChannel.invokeMethod( + "parse_config", + {"path": path, "tempPath": tempPath, "debug": debug}, + ); + if (message == null || message.isEmpty) return right(unit); + return left(message); + }, + ); + } + @override TaskEither changeOptions(SingboxConfigOption options) { return TaskEither( @@ -70,6 +88,23 @@ class PlatformSingboxService extends CoreSingboxService ); } + @override + TaskEither generateFullConfigByPath(String path) { + return TaskEither( + () async { + loggy.debug("generating full config by path"); + final configJson = await methodChannel.invokeMethod( + "generate_config", + {"path": path}, + ); + if (configJson == null || configJson.isEmpty) { + return left("null response"); + } + return right(configJson); + }, + ); + } + @override TaskEither start( String path, diff --git a/libcore b/libcore index 84e5933d..4bdcb7c4 160000 --- a/libcore +++ b/libcore @@ -1 +1 @@ -Subproject commit 84e5933d9dff3b9d117ce0d7342d6c976465307a +Subproject commit 4bdcb7c4c91dc1114555c902019dda6e04e87c11