v2fly / v2ray-core

A platform for building proxies to bypass network restrictions.
https://v2fly.org
MIT License
28.33k stars 4.53k forks source link

dns domainMatcher won't be loaded #2374

Closed ghost closed 1 year ago

ghost commented 1 year ago

What version of V2Ray are you using?

v5.4.0

What's your scenario of using V2Ray?

Apple Platform Client based V2Ray-Core

What problems have you encountered?

dns domainMatcher won't be loaded

Please attach your configuration here

Client configuration:

{
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ],
    "inbounds": [
        {
            "port": 30001,
            "protocol": "socks",
            "tag": "socks",
            "settings": {
                "udpEnabled": true,
                "packetEncoding": "Packet"
            }
        }
    ],
    "dns": {
        "nameServer": [
            {
                "address": {
                    "address": "114.114.114.114"
                }
            }
        ],
        "domainMatcher": "mph"
    },
    "log": {
        "error": {
            "level": "Debug",
            "type": "Console"
        },
        "access": {
            "level": "Debug",
            "type": "Console"
        }
    }
}

Please attach error logs here

Client error log:

V2Ray 5.4.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.20.1 darwin/arm64)
A unified platform for anti-censorship.
2023/03/03 16:52:12 [Debug] app/log: Logger started
2023/03/03 16:52:12 [Debug] app/dns: New 
2023/03/03 16:52:12 [Info] app/dns: DNS: created UDP client initialized for 114.114.114.114:53
2023/03/03 16:52:12 [Debug] app/dns: establishDomainRules 
2023/03/03 16:52:12 [Debug] app/dns: using default domain matcher
2023/03/03 16:52:12 [Debug] app/proxyman/inbound: creating stream worker on 0.0.0.0:30001
2023/03/03 16:52:12 [Info] transport/internet/tcp: listening TCP on 0.0.0.0:30001
2023/03/03 16:52:12 [Info] transport/internet/udp: listening UDP on 0.0.0.0:30001
2023/03/03 16:52:12 [Warning] V2Ray 5.4.0 started

As the log shows, I set the dns domainMatcher to "mph", but it still uses "default" domain matcher.

I inserted a log print at dns New function and establishDomainRules function, and I found that the config.DomainMatcher was empty.

I try to find the problematic code, but I'm new to golang and lack of knowledge about protobuf, then I'm failed. Now I open an issue here.

mydogshitgold commented 1 year ago

Good catch.

fullConfig.DomainMatcher has been forgotten.

https://github.com/v2fly/v2ray-core/blob/aa32199bf31591315008bcb949d0d934ee1d6196/app/dns/dns.go#L468-L480

mydogshitgold commented 1 year ago

Adding DomainMatcher: simplifiedConfig.DomainMatcher in fullConfig should work. Would you mind creating a pull request?

ghost commented 1 year ago

OK, I'll try.

ghost commented 1 year ago

@mydogshitgold , I have submited a PR to fix it.