Add reset tunnel option on ios

This commit is contained in:
problematicconsumer
2024-01-18 22:53:17 +03:30
parent 0d1a1147c6
commit 98fca5792a
12 changed files with 71 additions and 6 deletions

View File

@@ -224,6 +224,13 @@ class FFISingboxService with InfraLogger implements SingboxService {
);
}
@override
TaskEither<String, Unit> resetTunnel() {
throw UnimplementedError(
"reset tunnel function unavailable on platform",
);
}
@override
Stream<SingboxStatus> watchStatus() => _status;

View File

@@ -147,6 +147,24 @@ class PlatformSingboxService with InfraLogger implements SingboxService {
);
}
@override
TaskEither<String, Unit> resetTunnel() {
return TaskEither(
() async {
// only available on iOS (and macOS later)
if (!Platform.isIOS) {
throw UnimplementedError(
"reset tunnel function unavailable on platform",
);
}
loggy.debug("resetting tunnel");
await _methodChannel.invokeMethod("reset");
return right(unit);
},
);
}
@override
Stream<List<SingboxOutboundGroup>> watchOutbounds() {
const channel = EventChannel("com.hiddify.app/groups");

View File

@@ -52,6 +52,8 @@ abstract interface class SingboxService {
bool disableMemoryLimit,
);
TaskEither<String, Unit> resetTunnel();
Stream<List<SingboxOutboundGroup>> watchOutbounds();
TaskEither<String, Unit> selectOutbound(String groupTag, String outboundTag);