From 9db73ea07bdb72e569d570d46449527dd28f44ac Mon Sep 17 00:00:00 2001 From: ForestL <45709305+ForestL18@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:17:56 +0800 Subject: [PATCH] fix sniffer.sniff config (#455) --- .../clash/core/model/ConfigurationOverride.kt | 32 +++++++++-- .../clash/design/MetaFeatureSettingsDesign.kt | 56 ++++++++++++++++-- design/src/main/res/values-zh/strings.xml | 57 +++++++++---------- design/src/main/res/values/strings.xml | 21 ++++--- 4 files changed, 120 insertions(+), 46 deletions(-) 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 3587a1d87..7d3b222db 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 @@ -179,8 +179,8 @@ data class ConfigurationOverride( @SerialName("enable") var enable: Boolean? = null, - @SerialName("sniffing") - var sniffing: List? = null, + @SerialName("sniff") + var sniff: Sniff = Sniff(), @SerialName("force-dns-mapping") var forceDnsMapping: Boolean? = null, @@ -197,8 +197,11 @@ data class ConfigurationOverride( @SerialName("skip-domain") var skipDomain: List? = null, - @SerialName("port-whitelist") - var portWhitelist: List? = null, + @SerialName("skip-src-address") + var skipSrcAddress: List? = null, + + @SerialName("skip-dst-address") + var skipDstAddress: List? = null, ) @Serializable @@ -222,6 +225,27 @@ data class ConfigurationOverride( var allowPrivateNetwork: Boolean? = null, ) + @Serializable + data class Sniff( + @SerialName("HTTP") + var http: ProtocolConig = ProtocolConig(), + + @SerialName("TLS") + var tls: ProtocolConig = ProtocolConig(), + + @SerialName("QUIC") + var quic: ProtocolConig = ProtocolConig(), + ) + + @Serializable + data class ProtocolConig( + @SerialName("ports") + var ports: List? = null, + + @SerialName("override-destination") + var overrideDestination: Boolean? = null, + ) + override fun writeToParcel(parcel: Parcel, flags: Int) { Parcelizer.encodeToParcel(serializer(), parcel, this) } 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 0d674ca9f..b24a1bb90 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 @@ -137,13 +137,53 @@ class MetaFeatureSettingsDesign( } editableTextList( - value = configuration.sniffer::sniffing, + value = configuration.sniffer.sniff.http::ports, adapter = TextAdapter.String, - title = R.string.sniffing, + title = R.string.sniff_http_ports, placeholder = R.string.dont_modify, configure = snifferDependencies::add, ) + selectableList( + value = configuration.sniffer.sniff.http::overrideDestination, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.sniff_http_override_destination, + configure = snifferDependencies::add, + ) + + editableTextList( + value = configuration.sniffer.sniff.tls::ports, + adapter = TextAdapter.String, + title = R.string.sniff_tls_ports, + placeholder = R.string.dont_modify, + configure = snifferDependencies::add, + ) + + selectableList( + value = configuration.sniffer.sniff.tls::overrideDestination, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.sniff_tls_override_destination, + configure = snifferDependencies::add, + ) + + editableTextList( + value = configuration.sniffer.sniff.quic::ports, + adapter = TextAdapter.String, + title = R.string.sniff_quic_ports, + placeholder = R.string.dont_modify, + configure = snifferDependencies::add, + ) + + selectableList( + value = configuration.sniffer.sniff.quic::overrideDestination, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.sniff_quic_override_destination, + configure = snifferDependencies::add, + ) + selectableList( value = configuration.sniffer::forceDnsMapping, values = booleanValues, @@ -185,9 +225,17 @@ class MetaFeatureSettingsDesign( ) editableTextList( - value = configuration.sniffer::portWhitelist, + value = configuration.sniffer::skipSrcAddress, + adapter = TextAdapter.String, + title = R.string.skip_src_address, + placeholder = R.string.dont_modify, + configure = snifferDependencies::add, + ) + + editableTextList( + value = configuration.sniffer::skipDstAddress, adapter = TextAdapter.String, - title = R.string.port_whitelist, + title = R.string.skip_dst_address, placeholder = R.string.dont_modify, configure = snifferDependencies::add, ) diff --git a/design/src/main/res/values-zh/strings.xml b/design/src/main/res/values-zh/strings.xml index 3c16da479..64e8dea0b 100644 --- a/design/src/main/res/values-zh/strings.xml +++ b/design/src/main/res/values-zh/strings.xml @@ -133,9 +133,9 @@ Fake-IP 至 域名映射 黑名单 白名单 - OFF - Strict - Always + 关闭 + 严格 + 强制开启 排序 布局 单列 @@ -220,40 +220,39 @@ 允许 Ipv6 通过 VpnService 代理 Ipv6 流量 Clash Meta Wiki - Meta Features - Unified Delay - Geodata Mode - TCP Concurrent - Find Process Mode - Sniffer Setting - Sniffer - Sniffer Mode - Force Domain - Skip Domain - Disable Sniffer - Load Sniffer From Config - Override Sniffer Config - GeoX Url Setting - GeoIp Url - MMDB Url - Geosite Url - Prefer h3 - Port Whitelist - Geo Files + Meta 特性 + 统一延迟 + Geodata 模式 + TCP 并发 + 查找进程模式 + 嗅探设置 + 嗅探器 + 嗅探 + 强制 DNS 映射 + 解析纯 IP 连接 + 覆盖目标地址 + 强制解析域名 + 跳过域名 + 跳过源 IP + 跳过目标 IP + GeoX 链接设置 + GeoIp 链接 + MMDB 链接 + Geosite 链接 + H3 优先 + Geo 文件 导入 GeoIP 数据库 - Press to import... 导入 GeoSite 数据库 导入 Country 数据库 + 导入 ASN 数据库 + 点击导入... 导入失败 数据库类型错误 只支持 %1$s 格式的 Geo 数据库 %1$s 已导入 更新配置 %s 成功 更新配置 %1$s 失败:%2$s - External Control + 外部控制 Clash.Meta 服务已启动 Clash.Meta 服务已停止 - Force DNS Mapping - Parse Pure IP - Override Destination - \ 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 85f8a6ba5..2840f209c 100644 --- a/design/src/main/res/values/strings.xml +++ b/design/src/main/res/values/strings.xml @@ -305,13 +305,19 @@ Sniffer Setting Sniffer - Sniffer Mode + Force DNS Mapping + Parse Pure IP + Override Destination Force Domain Skip Domain - Port Whitelist - Disable Sniffer - Load Sniffer From Config - Override Sniffer Config + Skip Src Address + Skip Dst Address + Sniff HTTP Ports + Sniff TLS Ports + Sniff QUIC Ports + Sniff HTTP Override Destination + Sniff TLS Override Destination + Sniff QUIC Override Destination GeoX Url Setting GeoIp Url @@ -322,10 +328,10 @@ https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/release/geosite.dat Geo Files Import GeoIP Database - Press to import... Import GeoSite Database Import Country Database Import ASN Database + Press to import... Import failed Unknown Database format Only %1$s are supported @@ -335,7 +341,4 @@ External Control Clash.Meta service started Clash.Meta service stopped - Force DNS Mapping - Parse Pure IP - Override Destination