v2fly / v2ray-core

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

V5 格式无法配置 dns expectIPs #3017

Closed nie11kun closed 2 months ago

nie11kun commented 6 months ago

你正在使用哪个版本的 V2Ray?

5.16.1

你的使用场景是什么?

dns 服务器配置 expectIPs

你看到的异常现象是什么?

配置无法启动,有报错

你期待看到的正常表现是怎样的?

使用 V5格式配置 dns expectIPs

请附上你的配置

客户端配置:

{
                "address": {
                    "address": "223.5.5.5", 
                    "port": 53
                },
                "geoDomain": [
                    {
                        "code": "CN",
                        "filePath": "geosite.dat"
                    }
                ],
                "expectIPs": [
                    {
                        "code": "CN",
                        "filePath": "geoip.dat"
                    }
                ]
            }

请附上出错时软件输出的错误日志

客户端错误日志:

.\v2ray.exe test -c .\config.json -format jsonv5
V2Ray 5.16.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.22.2 windows/amd64)
A unified platform for anti-censorship.
Test failed: main/commands: failed to load config: [.\config.json] > infra/conf/v5cfg: unable to build config > infra/conf/v5cfg: failed to parse DNS config > common/registry: unable to parse json content > unknown field "expectIPs" in v2ray.core.app.dns.SimplifiedNameServer

如果 V2Ray 服务运行异常,请附上 journal 日志

povsister commented 6 months ago

扫了一眼,注册在v5 config loader里的config类型为SimplifiedConfig,内部的SimplifiedNameServer定义如下, 所以,很明显,没支持expectIPs。

然后v5json使用的是jsonpb解析,代码又没允许UnknownFields,自然爆炸。 https://github.com/v2fly/v2ray-core/blob/master/common/registry/registry.go#L68

message SimplifiedNameServer {
  v2ray.core.common.net.Endpoint address = 1;
  string client_ip = 5;
  string tag = 7;

  message PriorityDomain {
    DomainMatchingType type = 1;
    string domain = 2;
  }

  message OriginalRule {
    string rule = 1;
    uint32 size = 2;
  }

  repeated PriorityDomain prioritized_domain = 2;
  repeated v2ray.core.app.router.routercommon.GeoIP geoip = 3;
  repeated OriginalRule original_rules = 4;

  v2ray.core.app.dns.fakedns.FakeDnsPoolMulti fake_dns = 11;

  // Deprecated. Use fallback_strategy.
  bool skipFallback = 6 [deprecated = true];

  optional QueryStrategy query_strategy = 8;
  optional CacheStrategy cache_strategy = 9;
  optional FallbackStrategy fallback_strategy = 10;
  repeated v2ray.core.app.router.routercommon.GeoSite geo_domain = 68001;
}
github-actions[bot] commented 2 months ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days