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.VlessFmt
|
||||||
import com.v2ray.ang.fmt.VmessFmt
|
import com.v2ray.ang.fmt.VmessFmt
|
||||||
import com.v2ray.ang.fmt.WireguardFmt
|
import com.v2ray.ang.fmt.WireguardFmt
|
||||||
|
import com.v2ray.ang.handler.MmkvManager
|
||||||
import com.v2ray.ang.util.HttpUtil
|
import com.v2ray.ang.util.HttpUtil
|
||||||
import com.v2ray.ang.util.JsonUtil
|
import com.v2ray.ang.util.JsonUtil
|
||||||
import com.v2ray.ang.util.Utils
|
import com.v2ray.ang.util.Utils
|
||||||
@@ -470,27 +471,48 @@ object V2rayConfigManager {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DNS inbound
|
if (MmkvManager.decodeSettingsString(AppConfig.PREF_USE_HEV_TUNNEL) == "false") {
|
||||||
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(
|
// DNS inbound
|
||||||
MmkvManager.decodeSettingsString(AppConfig.PREF_LOCAL_DNS_PORT),
|
val remoteDns = SettingsManager.getRemoteDnsServers()
|
||||||
AppConfig.PORT_LOCAL_DNS.toInt()
|
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(
|
} else {
|
||||||
V2rayConfig.InboundBean(
|
//hev-socks5-tunnel dns routing
|
||||||
tag = "dns-in",
|
v2rayConfig.routing.rules.add(
|
||||||
port = localDnsPort,
|
0, RulesBean(
|
||||||
listen = AppConfig.LOOPBACK,
|
type = "field",
|
||||||
protocol = "dokodemo-door",
|
port = "53",
|
||||||
settings = dnsInboundSettings,
|
outboundTag = "dns-out"
|
||||||
sniffing = null
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -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) {
|
} catch (e: Exception) {
|
||||||
Log.e(AppConfig.TAG, "Failed to configure custom local DNS", e)
|
Log.e(AppConfig.TAG, "Failed to configure custom local DNS", e)
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user