Merge branch 'main' of hiddify-github:hiddify/hiddify-next

This commit is contained in:
Hiddify
2023-10-24 11:26:57 +02:00
parent 45d3243d9e
commit aa946deebd
38 changed files with 668 additions and 1686 deletions

View File

@@ -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),
);