mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 06:30:05 +08:00
Migrate from dns-out to hijack-dns
This commit is contained in:
parent
bb53000282
commit
573ad36fea
@ -38,7 +38,6 @@ object Key {
|
||||
const val ALLOW_ACCESS = "allowAccess"
|
||||
const val SPEED_INTERVAL = "speedInterval"
|
||||
const val SHOW_DIRECT_SPEED = "showDirectSpeed"
|
||||
const val LOCAL_DNS_PORT = "portLocalDns"
|
||||
|
||||
const val APPEND_HTTP_PROXY = "appendHttpProxy"
|
||||
|
||||
|
||||
@ -123,19 +123,11 @@ object DataStore : OnPreferenceDataStoreChangeListener {
|
||||
var mixedPort: Int
|
||||
get() = getLocalPort(Key.MIXED_PORT, 2080)
|
||||
set(value) = saveLocalPort(Key.MIXED_PORT, value)
|
||||
var localDNSPort: Int
|
||||
get() = getLocalPort(Key.LOCAL_DNS_PORT, 6450)
|
||||
set(value) {
|
||||
saveLocalPort(Key.LOCAL_DNS_PORT, value)
|
||||
}
|
||||
|
||||
fun initGlobal() {
|
||||
fun initGlobal() {
|
||||
if (configurationStore.getString(Key.MIXED_PORT) == null) {
|
||||
mixedPort = mixedPort
|
||||
}
|
||||
if (configurationStore.getString(Key.LOCAL_DNS_PORT) == null) {
|
||||
localDNSPort = localDNSPort
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -46,9 +46,6 @@ const val TAG_DIRECT = "direct"
|
||||
const val TAG_BYPASS = "bypass"
|
||||
const val TAG_BLOCK = "block"
|
||||
|
||||
const val TAG_DNS_IN = "dns-in"
|
||||
const val TAG_DNS_OUT = "dns-out"
|
||||
|
||||
const val LOCALHOST = "127.0.0.1"
|
||||
|
||||
class ConfigBuildResult(
|
||||
@ -637,22 +634,6 @@ fun buildConfig(
|
||||
type = "direct"
|
||||
}.asMap())
|
||||
|
||||
if (!forTest) {
|
||||
inbounds.add(0, Inbound_DirectOptions().apply {
|
||||
type = "direct"
|
||||
tag = TAG_DNS_IN
|
||||
listen = bind
|
||||
listen_port = DataStore.localDNSPort
|
||||
override_address = "8.8.8.8"
|
||||
override_port = 53
|
||||
})
|
||||
|
||||
outbounds.add(Outbound().apply {
|
||||
type = "dns"
|
||||
tag = TAG_DNS_OUT
|
||||
}.asMap())
|
||||
}
|
||||
|
||||
// Bypass Lookup for the first profile
|
||||
bypassDNSBeans.forEach {
|
||||
var serverAddr = it.serverAddress
|
||||
@ -726,12 +707,12 @@ fun buildConfig(
|
||||
} else {
|
||||
// built-in DNS rules
|
||||
route.rules.add(0, Rule_DefaultOptions().apply {
|
||||
inbound = listOf(TAG_DNS_IN)
|
||||
outbound = TAG_DNS_OUT
|
||||
protocol = listOf("dns")
|
||||
action = "hijack-dns"
|
||||
})
|
||||
route.rules.add(0, Rule_DefaultOptions().apply {
|
||||
port = listOf(53)
|
||||
outbound = TAG_DNS_OUT
|
||||
action = "hijack-dns"
|
||||
})
|
||||
if (DataStore.bypassLanInCore) {
|
||||
route.rules.add(Rule_DefaultOptions().apply {
|
||||
|
||||
@ -252,9 +252,6 @@ fun HysteriaBean.buildHysteria1Config(port: Int, cacheFile: (() -> File)?): Stri
|
||||
if (connectionReceiveWindow > 0) put("recv_window", connectionReceiveWindow)
|
||||
if (disableMtuDiscovery) put("disable_mtu_discovery", true)
|
||||
|
||||
// hy 1.2.0 (不兼容)
|
||||
put("resolver", "udp://127.0.0.1:" + DataStore.localDNSPort)
|
||||
|
||||
put("hop_interval", hopInterval)
|
||||
}.toStringPretty()
|
||||
}
|
||||
|
||||
@ -75,7 +75,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
val allowAccess = findPreference<Preference>(Key.ALLOW_ACCESS)!!
|
||||
val appendHttpProxy = findPreference<SwitchPreference>(Key.APPEND_HTTP_PROXY)!!
|
||||
|
||||
val portLocalDns = findPreference<EditTextPreference>(Key.LOCAL_DNS_PORT)!!
|
||||
val showDirectSpeed = findPreference<SwitchPreference>(Key.SHOW_DIRECT_SPEED)!!
|
||||
val ipv6Mode = findPreference<Preference>(Key.IPV6_MODE)!!
|
||||
val trafficSniffing = findPreference<Preference>(Key.TRAFFIC_SNIFFING)!!
|
||||
@ -121,7 +120,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
portLocalDns.setOnBindEditTextListener(EditTextPreferenceModifiers.Port)
|
||||
mixedPort.setOnBindEditTextListener(EditTextPreferenceModifiers.Port)
|
||||
|
||||
val metedNetwork = findPreference<Preference>(Key.METERED_NETWORK)!!
|
||||
@ -174,7 +172,6 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
directDns.onPreferenceChangeListener = reloadListener
|
||||
enableDnsRouting.onPreferenceChangeListener = reloadListener
|
||||
|
||||
portLocalDns.onPreferenceChangeListener = reloadListener
|
||||
ipv6Mode.onPreferenceChangeListener = reloadListener
|
||||
allowAccess.onPreferenceChangeListener = reloadListener
|
||||
|
||||
|
||||
@ -433,7 +433,7 @@
|
||||
<string name="create_shortcut">ایجاد میانبر</string>
|
||||
<string name="app_tls_version">حداقل اشتراک نسخه TLS</string>
|
||||
<string name="hop_interval">فاصله پرش بندر (ثانیه)</string>
|
||||
<string name="dns_network">نوع پرس و جو DNS</string>
|
||||
<string name="dns_network_select">نوع پرس و جو DNS</string>
|
||||
<string name="show_bottom_bar">نمایش نوار پایین مانند SagerNet</string>
|
||||
<string name="utls_fingerprint">اثر انگشت uTLS</string>
|
||||
</resources>
|
||||
|
||||
@ -187,10 +187,6 @@
|
||||
app:key="mixedPort"
|
||||
app:title="@string/port_proxy"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<EditTextPreference
|
||||
app:key="portLocalDns"
|
||||
app:title="@string/port_local_dns"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="appendHttpProxy"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user