Skip to content

Commit

Permalink
fix: bug in warp config
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Mar 17, 2024
1 parent a50a0d9 commit 798d36a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"type": "dart",
"flutterMode": "debug",
"program": "lib/main.dart",
// "args": ["-d","192.168.1.35:36463"]

},
{
"name": "Hiddify Dev Release",
Expand Down Expand Up @@ -36,7 +38,7 @@
"program": "lib/main.dart",
"args": [
"--app-id",
"com.hiddify.ios"
"app.hiddify.com"
],
"deviceId": "designed-for-ipad",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
45 changes: 40 additions & 5 deletions lib/singbox/service/platform_singbox_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -49,13 +46,34 @@ class PlatformSingboxService extends CoreSingboxService
TaskEither<String, Unit> 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<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
TaskEither<String, Unit> changeOptions(SingboxConfigOption options) {
return TaskEither(
Expand All @@ -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
TaskEither<String, Unit> start(
String path,
Expand Down
2 changes: 1 addition & 1 deletion libcore

0 comments on commit 798d36a

Please sign in to comment.