mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-18 22:20:06 +08:00
improve sniff option
This commit is contained in:
parent
a18bbc3b22
commit
f35ca31360
@ -30,7 +30,6 @@ object Key {
|
||||
const val INDIVIDUAL = "individual"
|
||||
const val METERED_NETWORK = "meteredNetwork"
|
||||
|
||||
const val DOMAIN_STRATEGY = "domainStrategy"
|
||||
const val TRAFFIC_SNIFFING = "trafficSniffing"
|
||||
const val RESOLVE_DESTINATION = "resolveDestination"
|
||||
|
||||
|
||||
@ -82,8 +82,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
|
||||
var nightTheme by configurationStore.stringToInt(Key.NIGHT_THEME)
|
||||
var serviceMode by configurationStore.string(Key.SERVICE_MODE) { Key.MODE_VPN }
|
||||
|
||||
// var domainStrategy by configurationStore.string(Key.DOMAIN_STRATEGY) { "AsIs" }
|
||||
var trafficSniffing by configurationStore.boolean(Key.TRAFFIC_SNIFFING) { true }
|
||||
var trafficSniffing by configurationStore.stringToInt(Key.TRAFFIC_SNIFFING) { 1 }
|
||||
var resolveDestination by configurationStore.boolean(Key.RESOLVE_DESTINATION)
|
||||
|
||||
// var tcpKeepAliveInterval by configurationStore.stringToInt(Key.TCP_KEEP_ALIVE_INTERVAL) { 15 }
|
||||
|
||||
@ -159,7 +159,8 @@ fun buildConfig(
|
||||
.mapNotNull { dns -> dns.trim().takeIf { it.isNotBlank() && !it.startsWith("#") } }
|
||||
val enableDnsRouting = DataStore.enableDnsRouting
|
||||
val useFakeDns = DataStore.enableFakeDns && !forTest && DataStore.ipv6Mode != IPv6Mode.ONLY
|
||||
val needSniff = DataStore.trafficSniffing
|
||||
val needSniff = DataStore.trafficSniffing > 0
|
||||
val needSniffOverride = DataStore.trafficSniffing == 2
|
||||
val externalIndexMap = ArrayList<IndexEntity>()
|
||||
val requireTransproxy = if (forTest) false else DataStore.requireTransproxy
|
||||
val ipv6Mode = if (forTest) IPv6Mode.ENABLE else DataStore.ipv6Mode
|
||||
@ -225,9 +226,10 @@ fun buildConfig(
|
||||
type = "tun"
|
||||
tag = "tun-in"
|
||||
stack = if (DataStore.tunImplementation == 1) "system" else "gvisor"
|
||||
sniff = needSniff
|
||||
endpoint_independent_nat = true
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
when (ipv6Mode) {
|
||||
IPv6Mode.DISABLE -> {
|
||||
inet4_address = listOf(VpnService.PRIVATE_VLAN4_CLIENT + "/28")
|
||||
@ -249,16 +251,8 @@ fun buildConfig(
|
||||
listen = bind
|
||||
listen_port = DataStore.mixedPort
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
if (needSniff) {
|
||||
sniff = true
|
||||
// destOverride = when {
|
||||
// useFakeDns && !trafficSniffing -> listOf("fakedns")
|
||||
// useFakeDns -> listOf("fakedns", "http", "tls", "quic")
|
||||
// else -> listOf("http", "tls", "quic")
|
||||
// }
|
||||
// metadataOnly = useFakeDns && !trafficSniffing
|
||||
// routeOnly = true
|
||||
}
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
})
|
||||
}
|
||||
|
||||
@ -269,8 +263,9 @@ fun buildConfig(
|
||||
tag = TAG_TRANS
|
||||
listen = bind
|
||||
listen_port = DataStore.transproxyPort
|
||||
sniff = needSniff
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
})
|
||||
} else {
|
||||
inbounds.add(Inbound_RedirectOptions().apply {
|
||||
@ -278,8 +273,9 @@ fun buildConfig(
|
||||
tag = TAG_TRANS
|
||||
listen = bind
|
||||
listen_port = DataStore.transproxyPort
|
||||
sniff = needSniff
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
val portLocalDns = findPreference<EditTextPreference>(Key.LOCAL_DNS_PORT)!!
|
||||
val showDirectSpeed = findPreference<SwitchPreference>(Key.SHOW_DIRECT_SPEED)!!
|
||||
val ipv6Mode = findPreference<Preference>(Key.IPV6_MODE)!!
|
||||
// val domainStrategy = findPreference<Preference>(Key.DOMAIN_STRATEGY)!!
|
||||
val trafficSniffing = findPreference<Preference>(Key.TRAFFIC_SNIFFING)!!
|
||||
|
||||
val muxConcurrency = findPreference<EditTextPreference>(Key.MUX_CONCURRENCY)!!
|
||||
@ -203,7 +202,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
mixedPort.onPreferenceChangeListener = reloadListener
|
||||
appendHttpProxy.onPreferenceChangeListener = reloadListener
|
||||
showDirectSpeed.onPreferenceChangeListener = reloadListener
|
||||
// domainStrategy.onPreferenceChangeListener = reloadListener
|
||||
trafficSniffing.onPreferenceChangeListener = reloadListener
|
||||
muxConcurrency.onPreferenceChangeListener = reloadListener
|
||||
tcpKeepAliveInterval.onPreferenceChangeListener = reloadListener
|
||||
|
||||
@ -475,4 +475,6 @@
|
||||
<string name="log_level_help">长按设置项以设置缓冲区大小。</string>
|
||||
<string name="test_concurrency">测试并发</string>
|
||||
<string name="mux_type">Mux 协议</string>
|
||||
<string name="sniff_routing">探测结果用于路由判断</string>
|
||||
<string name="sniff_override">探测结果用于目标地址</string>
|
||||
</resources>
|
||||
@ -517,4 +517,10 @@
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="traffic_sniffing_values">
|
||||
<item>@string/off</item>
|
||||
<item>@string/sniff_routing</item>
|
||||
<item>@string/sniff_override</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
||||
@ -516,5 +516,7 @@ Anyone can write advanced plugins, which can control NekoBox. please download an
|
||||
<string name="tls_camouflage_settings">TLS Camouflage Settings</string>
|
||||
<string name="test_concurrency">Test concurrency</string>
|
||||
<string name="mux_type">Mux protocol</string>
|
||||
<string name="sniff_routing">Sniff result for routing</string>
|
||||
<string name="sniff_override">Sniff result for destination</string>
|
||||
|
||||
</resources>
|
||||
@ -103,11 +103,14 @@
|
||||
<SwitchPreference
|
||||
app:key="bypassLanInCore"
|
||||
app:title="@string/bypass_lan_in_core" />
|
||||
<SwitchPreference
|
||||
app:defaultValue="true"
|
||||
<moe.matsuri.nb4a.ui.SimpleMenuPreference
|
||||
app:defaultValue="1"
|
||||
app:entries="@array/traffic_sniffing_values"
|
||||
app:entryValues="@array/int_array_3"
|
||||
app:icon="@drawable/ic_baseline_manage_search_24"
|
||||
app:key="trafficSniffing"
|
||||
app:title="@string/traffic_sniffing" />
|
||||
app:title="@string/traffic_sniffing"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreference
|
||||
app:icon="@drawable/baseline_wrap_text_24"
|
||||
app:key="resolveDestination"
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
var outdated string
|
||||
|
||||
func GetBuildTime() int64 {
|
||||
buildDate := 20230526
|
||||
buildDate := 20230527
|
||||
buildTime, _ := time.Parse("20060102", strconv.Itoa(buildDate))
|
||||
return buildTime.Unix()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user