Skip to content

Commit

Permalink
Feature: add option to enable sni sniff
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr328 committed Jul 2, 2022
1 parent eb7cd89 commit 7b7ee55
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion core/src/main/golang/native/config/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var processors = []processor{
patchDns,
patchProviders,
patchTun,
patchSniff,
validConfig,
}

Expand Down Expand Up @@ -106,5 +105,7 @@ func process(cfg *config.RawConfig, profileDir string) error {
}
}

log.Debugln("sni-tls: %t", cfg.Experimental.SniffTLSSNI)

return nil
}
4 changes: 0 additions & 4 deletions core/src/main/golang/native/config/process_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ import "github.com/Dreamacro/clash/config"
func patchTun(cfg *config.RawConfig, _ string) error {
return nil
}

func patchSniff(cfg *config.RawConfig, _ string) error {
return nil
}
6 changes: 0 additions & 6 deletions core/src/main/golang/native/config/process_premium.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ func patchTun(cfg *config.RawConfig, _ string) error {

return nil
}

func patchSniff(cfg *config.RawConfig, _ string) error {
cfg.Experimental.SniffTLSSNI = true

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ data class ConfigurationOverride(

@SerialName("clash-for-android")
val app: App = App(),

@SerialName("experimental")
val experimental: Experimental = Experimental()
) : Parcelable {
@Serializable
data class Dns(
Expand Down Expand Up @@ -107,6 +110,12 @@ data class ConfigurationOverride(
var appendSystemDns: Boolean? = null
)

@Serializable
data class Experimental(
@SerialName("sniff-tls-sni")
var sniffTLSSNI: Boolean? = null,
)

@Serializable
enum class DnsEnhancedMode {
@SerialName("normal")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ class OverrideSettingsDesign(
)
}

if (BuildConfig.PREMIUM) {
selectableList(
value = configuration.experimental::sniffTLSSNI,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.sniff_tls_sni,
)
}

selectableList(
value = configuration::logLevel,
values = arrayOf(
Expand Down
1 change: 1 addition & 0 deletions design/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,5 @@
<string name="geoip_fallback_code">GeoIP Fallback 区域代码</string>
<string name="allow_bypass">允许应用绕过</string>
<string name="allow_bypass_summary">允许其他应用绕过 VPN</string>
<string name="sniff_tls_sni">嗅探 TLS 的 SNI</string>
</resources>
1 change: 1 addition & 0 deletions design/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<string name="bind_address">Bind Address</string>
<string name="mode">Mode</string>
<string name="log_level">Log Level</string>
<string name="sniff_tls_sni">Sniff TLS SNI</string>
<string name="ipv6">IPv6</string>
<string name="hosts">Hosts</string>
<string name="sideload_geoip">Sideload GEOIP</string>
Expand Down

0 comments on commit 7b7ee55

Please sign in to comment.