fix: bug in warp config

This commit is contained in:
Hiddify
2024-03-17 19:20:59 +01:00
parent a50a0d92d7
commit 798d36a5ef
4 changed files with 47 additions and 8 deletions

4
.vscode/launch.json vendored
View File

@@ -7,6 +7,8 @@
"type": "dart", "type": "dart",
"flutterMode": "debug", "flutterMode": "debug",
"program": "lib/main.dart", "program": "lib/main.dart",
// "args": ["-d","192.168.1.35:36463"]
}, },
{ {
"name": "Hiddify Dev Release", "name": "Hiddify Dev Release",
@@ -36,7 +38,7 @@
"program": "lib/main.dart", "program": "lib/main.dart",
"args": [ "args": [
"--app-id", "--app-id",
"com.hiddify.ios" "app.hiddify.com"
], ],
"deviceId": "designed-for-ipad", "deviceId": "designed-for-ipad",
} }

View File

@@ -65,7 +65,9 @@ class WarpOptionNotifier extends _$WarpOptionNotifier with AppLogger {
await ref await ref
.read(ConfigOptions.warpAccessToken.notifier) .read(ConfigOptions.warpAccessToken.notifier)
.update(warp.accessToken); .update(warp.accessToken);
await ref
.read(ConfigOptions.warpWireguardConfig.notifier)
.update(warp.wireguardConfig);
return warp.log; return warp.log;
}); });

View File

@@ -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_stats.dart';
import 'package:hiddify/singbox/model/singbox_status.dart'; import 'package:hiddify/singbox/model/singbox_status.dart';
import 'package:hiddify/singbox/model/warp_account.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/singbox/service/singbox_service.dart';
import 'package:hiddify/utils/custom_loggers.dart'; import 'package:hiddify/utils/custom_loggers.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
class PlatformSingboxService extends CoreSingboxService class PlatformSingboxService with InfraLogger implements SingboxService {
with InfraLogger
implements SingboxService {
static const channelPrefix = "com.hiddify.app"; static const channelPrefix = "com.hiddify.app";
static const methodChannel = MethodChannel("$channelPrefix/method"); static const methodChannel = MethodChannel("$channelPrefix/method");
@@ -49,13 +46,34 @@ class PlatformSingboxService extends CoreSingboxService
TaskEither<String, Unit> setup(Directories directories, bool debug) { TaskEither<String, Unit> setup(Directories directories, bool debug) {
return TaskEither( return TaskEither(
() async { () async {
await methodChannel.invokeMethod("setup"); if (!Platform.isIOS) {
return right(unit);
}
await methodChannel.invokeMethod("setup");
return right(unit); return right(unit);
}, },
); );
} }
@override
TaskEither<String, Unit> validateConfigByPath(
String path,
String tempPath,
bool debug,
) {
return TaskEither(
() async {
final message = await methodChannel.invokeMethod<String>(
"parse_config",
{"path": path, "tempPath": tempPath, "debug": debug},
);
if (message == null || message.isEmpty) return right(unit);
return left(message);
},
);
}
@override @override
TaskEither<String, Unit> changeOptions(SingboxConfigOption options) { TaskEither<String, Unit> changeOptions(SingboxConfigOption options) {
return TaskEither( return TaskEither(
@@ -70,6 +88,23 @@ class PlatformSingboxService extends CoreSingboxService
); );
} }
@override
TaskEither<String, String> generateFullConfigByPath(String path) {
return TaskEither(
() async {
loggy.debug("generating full config by path");
final configJson = await methodChannel.invokeMethod<String>(
"generate_config",
{"path": path},
);
if (configJson == null || configJson.isEmpty) {
return left("null response");
}
return right(configJson);
},
);
}
@override @override
TaskEither<String, Unit> start( TaskEither<String, Unit> start(
String path, String path,

Submodule libcore updated: 84e5933d9d...4bdcb7c4c9