From 5255a0de81bccd6e7749a136d5db0cc9fbff8688 Mon Sep 17 00:00:00 2001 From: djoeni Date: Sat, 16 Jul 2022 05:59:21 +0700 Subject: [PATCH] Feature: add prefer h3 dns --- build.gradle.kts | 2 +- .../clash/core/model/ConfigurationOverride.kt | 6 +++ .../clash/design/MetaFeatureSettingsDesign.kt | 52 ++++++++++++++++++- .../clash/design/OverrideSettingsDesign.kt | 8 +++ design/src/main/res/values-zh-rHK/strings.xml | 2 + design/src/main/res/values-zh-rTW/strings.xml | 2 + design/src/main/res/values-zh/strings.xml | 2 + design/src/main/res/values/strings.xml | 3 +- 8 files changed, 74 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d81ec615..30d5a1a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,7 +40,7 @@ subprojects { minSdk = 21 targetSdk = 31 - versionName = "2.5.11-pre01" + versionName = "2.5.11-pre02" versionCode = 205011 resValue("string", "release_name", "v$versionName") diff --git a/core/src/main/java/com/github/kr328/clash/core/model/ConfigurationOverride.kt b/core/src/main/java/com/github/kr328/clash/core/model/ConfigurationOverride.kt index 55f9e868..8961065e 100644 --- a/core/src/main/java/com/github/kr328/clash/core/model/ConfigurationOverride.kt +++ b/core/src/main/java/com/github/kr328/clash/core/model/ConfigurationOverride.kt @@ -73,6 +73,9 @@ data class ConfigurationOverride( @SerialName("enable") var enable: Boolean? = null, + @SerialName("prefer-h3") + var preferH3: Boolean? = null, + @SerialName("listen") var listen: String? = null, @@ -150,6 +153,9 @@ data class ConfigurationOverride( @SerialName("skip-domain") var skipDomain: List? = null, + + @SerialName("port-whitelist") + var portWhitelist: List? = null, ) @Serializable diff --git a/design/src/main/java/com/github/kr328/clash/design/MetaFeatureSettingsDesign.kt b/design/src/main/java/com/github/kr328/clash/design/MetaFeatureSettingsDesign.kt index e2b941a8..8403a496 100644 --- a/design/src/main/java/com/github/kr328/clash/design/MetaFeatureSettingsDesign.kt +++ b/design/src/main/java/com/github/kr328/clash/design/MetaFeatureSettingsDesign.kt @@ -93,6 +93,47 @@ class MetaFeatureSettingsDesign( title = R.string.enable_process, ) + category(R.string.dns) + + val dnsDependencies: MutableList = mutableListOf() + + val dns = selectableList( + value = configuration.dns::enable, + values = arrayOf( + null, + true, + false + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.force_enable, + R.string.use_built_in, + ), + title = R.string.strategy + ) { + listener = OnChangedListener { + if (configuration.dns.enable == false) { + dnsDependencies.forEach { + it.enabled = false + } + } else { + dnsDependencies.forEach { + it.enabled = true + } + } + } + } + + selectableList( + value = configuration.dns::preferH3, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.prefer_h3, + configure = dnsDependencies::add, + ) + + dns.listener?.onChanged() + category(R.string.sniffer_setting) val snifferDependencies: MutableList = mutableListOf() @@ -148,8 +189,16 @@ class MetaFeatureSettingsDesign( configure = snifferDependencies::add, ) - sniffer.listener?.onChanged() + editableTextList( + value = configuration.sniffer::portWhitelist, + adapter = TextAdapter.String, + title = R.string.port_whitelist, + placeholder = R.string.dont_modify, + configure = snifferDependencies::add, + ) + sniffer.listener?.onChanged() +/* category(R.string.geox_url_setting) val geoxurlDependencies: MutableList = mutableListOf() @@ -180,6 +229,7 @@ class MetaFeatureSettingsDesign( empty = R.string.geosite_url, configure = geoxurlDependencies::add, ) +*/ } binding.content.addView(screen.root) diff --git a/design/src/main/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt b/design/src/main/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt index 72c6c95f..8622cbaa 100644 --- a/design/src/main/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt +++ b/design/src/main/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt @@ -271,6 +271,14 @@ class OverrideSettingsDesign( } } + selectableList( + value = configuration.dns::preferH3, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.prefer_h3, + configure = dnsDependencies::add, + ) + editableText( value = configuration.dns::listen, adapter = NullableTextAdapter.String, diff --git a/design/src/main/res/values-zh-rHK/strings.xml b/design/src/main/res/values-zh-rHK/strings.xml index 50db4af3..28ab1d70 100644 --- a/design/src/main/res/values-zh-rHK/strings.xml +++ b/design/src/main/res/values-zh-rHK/strings.xml @@ -228,4 +228,6 @@ GeoIp Url MMDB Url Geosite Url + Prefer h3 + Port Whitelist \ No newline at end of file diff --git a/design/src/main/res/values-zh-rTW/strings.xml b/design/src/main/res/values-zh-rTW/strings.xml index fd6fbdcc..e0ffe755 100644 --- a/design/src/main/res/values-zh-rTW/strings.xml +++ b/design/src/main/res/values-zh-rTW/strings.xml @@ -228,4 +228,6 @@ GeoIp Url MMDB Url Geosite Url + Prefer h3 + Port Whitelist diff --git a/design/src/main/res/values-zh/strings.xml b/design/src/main/res/values-zh/strings.xml index 2b780f5b..4bc2cc95 100644 --- a/design/src/main/res/values-zh/strings.xml +++ b/design/src/main/res/values-zh/strings.xml @@ -231,4 +231,6 @@ GeoIp Url MMDB Url Geosite Url + Prefer h3 + Port Whitelist \ No newline at end of file diff --git a/design/src/main/res/values/strings.xml b/design/src/main/res/values/strings.xml index 576bc26e..2fce0942 100644 --- a/design/src/main/res/values/strings.xml +++ b/design/src/main/res/values/strings.xml @@ -132,7 +132,7 @@ General DNS - + Prefer h3 HTTP Port Socks Port Redirect Port @@ -286,6 +286,7 @@ Sniffer Mode Force Domain Skip Domain + Port Whitelist Disable Sniffer Load Sniffer From Config Override Sniffer Config