2dust / v2rayNG

A V2Ray client for Android, support Xray core and v2fly core
https://1.2345345.xyz
GNU General Public License v3.0
35.24k stars 5.43k forks source link

custom DNS settings in custom config do not work at all when "local dns" is enabled #3670

Open mmmray opened 1 week ago

mmmray commented 1 week ago

在提出问题前请先自行排除服务器端问题,同时也请通过搜索确认是否有人提出过相同问题。

预期行为 (expected behavior)

DNS settings can be customized using JSON subs, just like with regular core.

实际行为 (actual behavior)

When using a JSON subscription or custom JSON config with dns section, and enabling the "enable local dns" option, v2rayNG fails all DNS queries by timeout/hang.

复现方法 (reproduction method)

contents of json subscription:

[
  {
    "inbounds": [
      {
        "listen": "127.0.0.1",
        "port": 2080,
        "protocol": "socks",
        "settings": {
          "udp": true
        }
      }
    ],
    "routing": {},
    "log": {
      "loglevel": "warning"
    },
    "dns": {
      "servers": [
        "1.1.1.1"
      ],
      "queryStrategy": "UseIPv4",
      "tag": "dns-in"
    },
    "outbounds": [
      // redacted
    ],
    "remarks": "test"
  }
]
  1. host above as a file somewhere for subs, add an outbound, add it to v2rayNG
  2. "enable local DNS" in settings (keep everything else as-is)
  3. observe dig google.com hanging in termux, similar behavior from chrome (tried with/without chrome's DoH)
  4. disabling "enable local DNS" fixes it again

日志信息

There are no relevant logs. The core starts successfully and then no logs are printed. The log output is identical to when it works (step 4) vs when it doesn't work (step 3).

通过`adb logcat -s com.v2ray.ang GoLog V2rayConfigUtilGoLog Main`获取日志。请自行删减日志中可能出现的敏感信息。 如果问题可重现,建议先执行`adb logcat -c`清空系统日志再执行上述命令,再操作重现问题。 ``` 10-08 10:19:11.284 4525 4525 I GoLog : start core 10-08 10:19:11.290 4525 4547 I GoLog : [Warning] core: Xray 24.9.30 started 10-08 10:19:11.335 4525 4525 D com.v2ray.ang: [/data/app/com.v2ray.ang-DfSxD05GmpgnNrmw36O_Kw==/lib/arm64/libtun2socks.so, --netif-ipaddr, 26.26.26.2, --netif-netmask, 255.255.255.252, --socks-server-addr, 127.0.0.1:10808, --tunmtu, 1500, --sock-path, sock_path, --enable-udprelay, --loglevel, notice, --dnsgw, 127.0.0.1:10853] 10-08 10:19:11.340 4525 4525 D com.v2ray.ang: Process[pid=7083, hasExited=false] 10-08 10:19:11.340 4525 4525 D com.v2ray.ang: /data/user/0/com.v2ray.ang/files/sock_path 10-08 10:19:11.341 4525 7084 D com.v2ray.ang: libtun2socks.so check 10-08 10:19:11.355 4525 4525 D com.v2ray.ang: runPlugin 10-08 10:19:11.391 4525 4573 D com.v2ray.ang: sendFd tries: 0 10-08 10:19:13.950 4525 4555 I GoLog : Using Prepared: 188.114.96.10 ```

环境信息

v2rayng 1.9.6, tested with two completely different servers and protocols, one of them has no server side routing

额外信息(可选)

changing the dns server in the json config makes no difference

the same config works ok when launched with core directly (checking with curl -x socks5h://..)

realartin commented 1 week ago

it's true

realartin commented 1 week ago

also we need that dns query will be resolve trough proxy tunnel it self !

2dust commented 1 week ago

https://github.com/2dust/v2rayNG/blob/819ff2995a268d486e29b481fc7f13fa1e799dcd/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/V2rayConfigUtil.kt#L240

Check the code here, there are some changes to the configuration file when this is enabled.

Using the in-app function Export full configuration to clipboard you can see the full configuration

mmmray commented 6 days ago

i'm not able to see these changes when using Export full configuration. Are you saying this is expected behavior or should I look into this code to fix the bug?