v2fly / v2ray-core

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

jsonv5配置Dokodemo-door时候报错 #2322

Closed lluu131 closed 1 year ago

lluu131 commented 1 year ago

使用如下命令测试 v2ray run -c /usr/local/etc/v2ray/config.json -format jsonv5

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

V2Ray 5.3.0

你的使用场景是什么?

学习及测试V5格式代码

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

V2Ray 5.3.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.20 linux/amd64) A unified platform for anti-censorship. panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x9ff9e2]

goroutine 1 [running]: github.com/v2fly/v2ray-core/v5/proxy/dokodemo.init.1.func2({0x12d11b0, 0xc000177bc0}, {0x109ce60?, 0xc00008af50}) github.com/v2fly/v2ray-core/v5/proxy/dokodemo/dokodemo.go:38 +0x82 github.com/v2fly/v2ray-core/v5/common.CreateObject({0x12d11b0, 0xc000177bc0}, {0x109ce60, 0xc00008af50}) github.com/v2fly/v2ray-core/v5/common/type.go:34 +0x1a2 github.com/v2fly/v2ray-core/v5/app/proxyman/inbound.NewAlwaysOnInboundHandler({0x12d11b0?, 0xc000177bc0}, {0xc0005c4b20, 0x9}, 0xc0005aaa10, {0x109ce60?, 0xc00008af50?}) github.com/v2fly/v2ray-core/v5/app/proxyman/inbound/always.go:52 +0x74 github.com/v2fly/v2ray-core/v5/app/proxyman/inbound.NewHandler({0x12d11b0, 0xc000177bc0}, 0xc0005b3130) github.com/v2fly/v2ray-core/v5/app/proxyman/inbound/inbound.go:162 +0x2e5 github.com/v2fly/v2ray-core/v5/app/proxyman/inbound.init.0.func2({0x12d11b0?, 0xc000177bc0?}, {0x108f0e0?, 0xc0005b3130?}) github.com/v2fly/v2ray-core/v5/app/proxyman/inbound/inbound.go:176 +0x3c github.com/v2fly/v2ray-core/v5/common.CreateObject({0x12d11b0, 0xc000177bc0}, {0x108f0e0, 0xc0005b3130}) github.com/v2fly/v2ray-core/v5/common/type.go:34 +0x1a2 github.com/v2fly/v2ray-core/v5.CreateObjectWithEnvironment(0xc00049cba0?, {0x108f0e0, 0xc0005b3130}, {0x10753c0?, 0xc00049cde0?}) github.com/v2fly/v2ray-core/v5/functions.go:25 +0x8c github.com/v2fly/v2ray-core/v5.AddInboundHandler(0xc0000fb620, 0xc0005b3130) github.com/v2fly/v2ray-core/v5/v2ray.go:103 +0xad github.com/v2fly/v2ray-core/v5.addInboundHandlers(...) github.com/v2fly/v2ray-core/v5/v2ray.go:119 github.com/v2fly/v2ray-core/v5.initInstanceWithConfig(0xc000630c60, 0xc0000fb620) github.com/v2fly/v2ray-core/v5/v2ray.go:236 +0x619 github.com/v2fly/v2ray-core/v5.New(0x7ffe4decde55?) github.com/v2fly/v2ray-core/v5/v2ray.go:167 +0x77 github.com/v2fly/v2ray-core/v5/main/commands.startV2Ray() github.com/v2fly/v2ray-core/v5/main/commands/run.go:205 +0x275 github.com/v2fly/v2ray-core/v5/main/commands.executeRun(0x1a94300, {0xc00003e200, 0x4, 0x4}) github.com/v2fly/v2ray-core/v5/main/commands/run.go:82 +0xca github.com/v2fly/v2ray-core/v5/main/commands/base.Execute() github.com/v2fly/v2ray-core/v5/main/commands/base/execute.go:64 +0x636 main.main() github.com/v2fly/v2ray-core/v5/main/main.go:16 +0x26f

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

运行正常

请附上你的配置

配置如下 { "log": {}, "inbounds": [ { "tag": "tproxy-in", "address" : "", "port": 1111, "protocol": "dokodemo-door", "followRedirect": true, "networks":"tcp,udp", "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ], "metadataOnly": false } } ], "outbounds": [ { ........................省略....................................... }, { "tag": "direct-out", "protocol": "freedom" } ], "router": {}, "other": {} }

mydogshitgold commented 1 year ago

Your configuration seems incorrect. That error message is just counterintuitive. V2Ray should display better error messages instead of panicking.

Also, documentations on v2fly.org seems a bit outdated. When in doubt, prefer referencing protobuf files(e.g. proxy/dokodemo/config.proto) instead of documentation. Or you can try v2ray-jsonschema.

Try this:

  "inbounds": [
    {
      "tag": "tproxy-in",
      "address": "127.0.0.1",
      "port": "1111",
      "protocol": "dokodemo-door",
      "settings": {
        "followRedirect": true,
        "networks": [
          "TCP",
          "UDP"
        ]
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls",
          "quic"
        ],
        "metadataOnly": false
      }
    }
  ],
lluu131 commented 1 year ago

非常感谢,稍晚一点试试

lluu131 commented 1 year ago

Your configuration seems incorrect. That error message is just counterintuitive. V2Ray should display better error messages instead of panicking.

  • inbounds.port is a string, not a number
  • there is no inbounds.networks, you should use inbounds.settings.networks, which is an array of strings
  • followRedirect should be put into inbounds.settings as well.

Also, documentations on v2fly.org seems a bit outdated. When in doubt, prefer referencing protobuf files(e.g. proxy/dokodemo/config.proto) instead of documentation. Or you can try v2ray-jsonschema.

Try this:

  "inbounds": [
    {
      "tag": "tproxy-in",
      "address": "127.0.0.1",
      "port": "1111",
      "protocol": "dokodemo-door",
      "settings": {
        "followRedirect": true,
        "networks": [
          "TCP",
          "UDP"
        ]
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls",
          "quic"
        ],
        "metadataOnly": false
      }
    }
  ],

谢谢,测试成功

dyhkwong commented 1 year ago

It once got fixed (#1923), but some leftovers persist.