Merge branch 'main' of hiddify-github:hiddify/hiddify-next
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// ignore_for_file: avoid_manual_providers_as_generated_provider_dependency
|
||||
import 'package:hiddify/core/prefs/prefs.dart';
|
||||
import 'package:hiddify/domain/singbox/config_options.dart';
|
||||
import 'package:hiddify/domain/singbox/singbox.dart';
|
||||
import 'package:hiddify/utils/pref_notifier.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
@@ -67,6 +67,42 @@ final enableTunStore = PrefNotifier.provider("enable-tun", _default.enableTun);
|
||||
final setSystemProxyStore =
|
||||
PrefNotifier.provider("set-system-proxy", _default.setSystemProxy);
|
||||
|
||||
// HACK temporary
|
||||
@riverpod
|
||||
List<Rule> rules(RulesRef ref) => switch (ref.watch(regionNotifierProvider)) {
|
||||
Region.ir => [
|
||||
const Rule(
|
||||
id: "id",
|
||||
name: "name",
|
||||
enabled: true,
|
||||
domains: "domain:.ir",
|
||||
ip: "geoip:ir",
|
||||
outbound: RuleOutbound.bypass,
|
||||
),
|
||||
],
|
||||
Region.cn => [
|
||||
const Rule(
|
||||
id: "id",
|
||||
name: "name",
|
||||
enabled: true,
|
||||
domains: "domain:.cn,geosite:cn",
|
||||
ip: "geoip:cn",
|
||||
outbound: RuleOutbound.bypass,
|
||||
),
|
||||
],
|
||||
Region.ru => [
|
||||
const Rule(
|
||||
id: "id",
|
||||
name: "name",
|
||||
enabled: true,
|
||||
domains: "domain:.ru",
|
||||
ip: "geoip:ru",
|
||||
outbound: RuleOutbound.bypass,
|
||||
),
|
||||
],
|
||||
_ => [],
|
||||
};
|
||||
|
||||
@riverpod
|
||||
ConfigOptions configOptions(ConfigOptionsRef ref) => ConfigOptions(
|
||||
executeConfigAsIs:
|
||||
@@ -88,4 +124,5 @@ ConfigOptions configOptions(ConfigOptionsRef ref) => ConfigOptions(
|
||||
clashApiPort: ref.watch(clashApiPortStore),
|
||||
enableTun: ref.watch(enableTunStore),
|
||||
setSystemProxy: ref.watch(setSystemProxyStore),
|
||||
rules: ref.watch(rulesProvider),
|
||||
);
|
||||
|
||||
@@ -179,10 +179,21 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade {
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<Either<CoreServiceFailure, String>> watchLogs() {
|
||||
return singbox
|
||||
.watchLogs(filesEditor.coreLogsPath)
|
||||
.handleExceptions(CoreServiceFailure.unexpected);
|
||||
Stream<Either<CoreServiceFailure, List<String>>> watchLogs() {
|
||||
return singbox.watchLogs(filesEditor.coreLogsPath).handleExceptions(
|
||||
(error, stackTrace) {
|
||||
loggy.warning("error watching logs", error, stackTrace);
|
||||
return CoreServiceFailure.unexpected(error, stackTrace);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<CoreServiceFailure, Unit> clearLogs() {
|
||||
return exceptionHandler(
|
||||
() => singbox.clearLogs().mapLeft(CoreServiceFailure.other).run(),
|
||||
CoreServiceFailure.unexpected,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user