fix hev-socks5-tunnel CustomLocalDns route (#4806)
* fix hev-socks5-tunnel dns route * update
This commit is contained in:
@@ -24,6 +24,7 @@ import com.v2ray.ang.fmt.TrojanFmt
|
||||
import com.v2ray.ang.fmt.VlessFmt
|
||||
import com.v2ray.ang.fmt.VmessFmt
|
||||
import com.v2ray.ang.fmt.WireguardFmt
|
||||
import com.v2ray.ang.handler.MmkvManager
|
||||
import com.v2ray.ang.util.HttpUtil
|
||||
import com.v2ray.ang.util.JsonUtil
|
||||
import com.v2ray.ang.util.Utils
|
||||
@@ -470,27 +471,48 @@ object V2rayConfigManager {
|
||||
)
|
||||
}
|
||||
|
||||
// DNS inbound
|
||||
val remoteDns = SettingsManager.getRemoteDnsServers()
|
||||
if (v2rayConfig.inbounds.none { e -> e.protocol == "dokodemo-door" && e.tag == "dns-in" }) {
|
||||
val dnsInboundSettings = V2rayConfig.InboundBean.InSettingsBean(
|
||||
address = if (Utils.isPureIpAddress(remoteDns.first())) remoteDns.first() else AppConfig.DNS_PROXY,
|
||||
port = 53,
|
||||
network = "tcp,udp"
|
||||
)
|
||||
if (MmkvManager.decodeSettingsString(AppConfig.PREF_USE_HEV_TUNNEL) == "false") {
|
||||
|
||||
val localDnsPort = Utils.parseInt(
|
||||
MmkvManager.decodeSettingsString(AppConfig.PREF_LOCAL_DNS_PORT),
|
||||
AppConfig.PORT_LOCAL_DNS.toInt()
|
||||
// DNS inbound
|
||||
val remoteDns = SettingsManager.getRemoteDnsServers()
|
||||
if (v2rayConfig.inbounds.none { e -> e.protocol == "dokodemo-door" && e.tag == "dns-in" }) {
|
||||
val dnsInboundSettings = V2rayConfig.InboundBean.InSettingsBean(
|
||||
address = if (Utils.isPureIpAddress(remoteDns.first())) remoteDns.first() else AppConfig.DNS_PROXY,
|
||||
port = 53,
|
||||
network = "tcp,udp"
|
||||
)
|
||||
|
||||
val localDnsPort = Utils.parseInt(
|
||||
MmkvManager.decodeSettingsString(AppConfig.PREF_LOCAL_DNS_PORT),
|
||||
AppConfig.PORT_LOCAL_DNS.toInt()
|
||||
)
|
||||
v2rayConfig.inbounds.add(
|
||||
V2rayConfig.InboundBean(
|
||||
tag = "dns-in",
|
||||
port = localDnsPort,
|
||||
listen = AppConfig.LOOPBACK,
|
||||
protocol = "dokodemo-door",
|
||||
settings = dnsInboundSettings,
|
||||
sniffing = null
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// DNS routing tag
|
||||
v2rayConfig.routing.rules.add(
|
||||
0, RulesBean(
|
||||
inboundTag = arrayListOf("dns-in"),
|
||||
outboundTag = "dns-out",
|
||||
domain = null
|
||||
)
|
||||
)
|
||||
v2rayConfig.inbounds.add(
|
||||
V2rayConfig.InboundBean(
|
||||
tag = "dns-in",
|
||||
port = localDnsPort,
|
||||
listen = AppConfig.LOOPBACK,
|
||||
protocol = "dokodemo-door",
|
||||
settings = dnsInboundSettings,
|
||||
sniffing = null
|
||||
} else {
|
||||
//hev-socks5-tunnel dns routing
|
||||
v2rayConfig.routing.rules.add(
|
||||
0, RulesBean(
|
||||
type = "field",
|
||||
port = "53",
|
||||
outboundTag = "dns-out"
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -507,15 +529,6 @@ object V2rayConfigManager {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// DNS routing tag
|
||||
v2rayConfig.routing.rules.add(
|
||||
0, RulesBean(
|
||||
inboundTag = arrayListOf("dns-in"),
|
||||
outboundTag = "dns-out",
|
||||
domain = null
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e(AppConfig.TAG, "Failed to configure custom local DNS", e)
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user