Change proxies flow

This commit is contained in:
problematicconsumer
2023-08-29 19:32:31 +03:30
parent 375cb8a945
commit e8eb55ac8d
15 changed files with 335 additions and 229 deletions

View File

@@ -98,6 +98,42 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
);
}
@override
Stream<Either<CoreServiceFailure, List<OutboundGroup>>> watchOutbounds() {
return singbox.watchOutbounds().map((event) {
return (jsonDecode(event) as List).map((e) {
return OutboundGroup.fromJson(e as Map<String, dynamic>);
}).toList();
}).handleExceptions(
(error, stackTrace) {
loggy.warning("error watching outbounds", error, stackTrace);
return CoreServiceFailure.unexpected(error, stackTrace);
},
);
}
@override
TaskEither<CoreServiceFailure, Unit> selectOutbound(
String groupTag,
String outboundTag,
) {
return exceptionHandler(
() => singbox
.selectOutbound(groupTag, outboundTag)
.mapLeft(CoreServiceFailure.other)
.run(),
CoreServiceFailure.unexpected,
);
}
@override
TaskEither<CoreServiceFailure, Unit> urlTest(String groupTag) {
return exceptionHandler(
() => singbox.urlTest(groupTag).mapLeft(CoreServiceFailure.other).run(),
CoreServiceFailure.unexpected,
);
}
@override
Stream<Either<CoreServiceFailure, CoreStatus>> watchCoreStatus() {
return singbox.watchStatus().map((event) {