mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 06:30:05 +08:00
feat: resolveServer
This commit is contained in:
parent
5d75cbacd4
commit
d81178ce64
@ -32,6 +32,7 @@ object Key {
|
||||
|
||||
const val TRAFFIC_SNIFFING = "trafficSniffing"
|
||||
const val RESOLVE_DESTINATION = "resolveDestination"
|
||||
const val RESOLVE_SERVER = "resolveServer"
|
||||
|
||||
const val BYPASS_LAN = "bypassLan"
|
||||
const val BYPASS_LAN_IN_CORE = "bypassLanInCore"
|
||||
|
||||
@ -84,6 +84,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
|
||||
|
||||
var trafficSniffing by configurationStore.stringToInt(Key.TRAFFIC_SNIFFING) { 1 }
|
||||
var resolveDestination by configurationStore.boolean(Key.RESOLVE_DESTINATION)
|
||||
var resolveServer by configurationStore.boolean(Key.RESOLVE_SERVER)
|
||||
|
||||
// var tcpKeepAliveInterval by configurationStore.stringToInt(Key.TCP_KEEP_ALIVE_INTERVAL) { 15 }
|
||||
var mtu by configurationStore.stringToInt(Key.MTU) { 9000 }
|
||||
|
||||
@ -153,12 +153,11 @@ fun buildConfig(
|
||||
val externalIndexMap = ArrayList<IndexEntity>()
|
||||
val requireTransproxy = if (forTest) false else DataStore.requireTransproxy
|
||||
val ipv6Mode = if (forTest) IPv6Mode.ENABLE else DataStore.ipv6Mode
|
||||
val resolveDestination = DataStore.resolveDestination
|
||||
val alerts = mutableListOf<Pair<Int, String>>()
|
||||
|
||||
fun genDomainStrategy(noAsIs: Boolean): String {
|
||||
return when {
|
||||
!resolveDestination && !noAsIs -> ""
|
||||
!noAsIs -> ""
|
||||
ipv6Mode == IPv6Mode.DISABLE -> "ipv4_only"
|
||||
ipv6Mode == IPv6Mode.PREFER -> "prefer_ipv6"
|
||||
ipv6Mode == IPv6Mode.ONLY -> "ipv6_only"
|
||||
@ -216,7 +215,7 @@ fun buildConfig(
|
||||
tag = "tun-in"
|
||||
stack = if (DataStore.tunImplementation == 1) "system" else "gvisor"
|
||||
endpoint_independent_nat = true
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
domain_strategy = genDomainStrategy(DataStore.resolveDestination)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
when (ipv6Mode) {
|
||||
@ -239,7 +238,7 @@ fun buildConfig(
|
||||
tag = TAG_MIXED
|
||||
listen = bind
|
||||
listen_port = DataStore.mixedPort
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
domain_strategy = genDomainStrategy(DataStore.resolveDestination)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
})
|
||||
@ -252,7 +251,6 @@ fun buildConfig(
|
||||
tag = TAG_TRANS
|
||||
listen = bind
|
||||
listen_port = DataStore.transproxyPort
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
})
|
||||
@ -262,7 +260,6 @@ fun buildConfig(
|
||||
tag = TAG_TRANS
|
||||
listen = bind
|
||||
listen_port = DataStore.transproxyPort
|
||||
domain_strategy = genDomainStrategy(false)
|
||||
sniff = needSniff
|
||||
sniff_override_destination = needSniffOverride
|
||||
})
|
||||
@ -300,7 +297,7 @@ fun buildConfig(
|
||||
val chainTag = "c-$chainId"
|
||||
var muxApplied = false
|
||||
|
||||
var currentDomainStrategy = genDomainStrategy(false)
|
||||
var currentDomainStrategy = genDomainStrategy(DataStore.resolveServer)
|
||||
|
||||
profileList.forEachIndexed { index, proxyEntity ->
|
||||
val bean = proxyEntity.requireBean()
|
||||
|
||||
@ -191,6 +191,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
|
||||
val tunImplementation = findPreference<SimpleMenuPreference>(Key.TUN_IMPLEMENTATION)!!
|
||||
val resolveDestination = findPreference<SwitchPreference>(Key.RESOLVE_DESTINATION)!!
|
||||
val resolveServer = findPreference<SwitchPreference>(Key.RESOLVE_SERVER)!!
|
||||
val acquireWakeLock = findPreference<SwitchPreference>(Key.ACQUIRE_WAKE_LOCK)!!
|
||||
val enableClashAPI = findPreference<SwitchPreference>(Key.ENABLE_CLASH_API)!!
|
||||
enableClashAPI.setOnPreferenceChangeListener { _, newValue ->
|
||||
@ -223,6 +224,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
transproxyMode.onPreferenceChangeListener = reloadListener
|
||||
|
||||
resolveDestination.onPreferenceChangeListener = reloadListener
|
||||
resolveServer.onPreferenceChangeListener = reloadListener
|
||||
tunImplementation.onPreferenceChangeListener = reloadListener
|
||||
acquireWakeLock.onPreferenceChangeListener = reloadListener
|
||||
|
||||
|
||||
@ -477,4 +477,5 @@
|
||||
<string name="mux_type">Mux 协议</string>
|
||||
<string name="sniff_routing">探测结果用于路由判断</string>
|
||||
<string name="sniff_override">探测结果用于目标地址</string>
|
||||
<string name="resolve_server">根据 IPv6 策略解析服务器地址</string>
|
||||
</resources>
|
||||
@ -518,5 +518,6 @@ Anyone can write advanced plugins, which can control NekoBox. please download an
|
||||
<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>
|
||||
<string name="resolve_server">Resolve the server address according to the IPv6 policy</string>
|
||||
|
||||
</resources>
|
||||
@ -116,6 +116,9 @@
|
||||
app:key="resolveDestination"
|
||||
app:summary="@string/resolve_destination_summary"
|
||||
app:title="@string/resolve_destination" />
|
||||
<SwitchPreference
|
||||
app:key="resolveServer"
|
||||
app:title="@string/resolve_server" />
|
||||
<moe.matsuri.nb4a.ui.SimpleMenuPreference
|
||||
app:defaultValue="0"
|
||||
app:entries="@array/ipv6_mode"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user