Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

vless udp 好像有点问题 #112

Closed
kingwilliam opened this issue Aug 24, 2020 · 25 comments
Closed

vless udp 好像有点问题 #112

kingwilliam opened this issue Aug 24, 2020 · 25 comments

Comments

@kingwilliam
Copy link

kingwilliam commented Aug 24, 2020

Please answer all the questions with enough information. All issues not following this template will be closed immediately.
If you are not sure if your question is truely a bug in V2Ray, please discuss it here first.

  1. What version of V2Ray are you using (If you deploy different version on server and client, please explicitly point out)?
    v4.27.0

  2. What's your scenario of using V2Ray? E.g., Watching YouTube videos in Chrome via Socks/VMess proxy.
    microsoft remote desktop

  3. What did you see? (Please describe in detail, such as timeout, fake TLS certificate etc)
    vmess:3389tcp+udp可正常运作, vless:只可3389tcp.
    good01

3389udp vless有error.
error01

  1. What's your expectation?
    3389udp vLess可正常运作.

  2. Please attach your configuration file (Mask IP addresses before submit this issue).

Server configuration:

        // server-inbounds-vmess
        {
            "protocol": "vmess",
            "port": 44391,
            "settings": {
                "clients": [{
                        "id": "UUID",
                        "alterId": 64
                    }
                ]
            },
            "streamSettings": {
                "network": "h2",
                "httpSettings": {
                    "host": "{fqdn}",
                    "path": "/path/"
                },
                "security": "none"
            }
        },

        // server-inbounds-vless
        {
            "protocol": "vless",
            "port": 44392,
            "settings": {
                "clients": [{
                        "id": "UUID"
                    }
                ],
                "decryption": "none"
            },
            "streamsettings": {
                "network": "h2",
                "httpSettings": {
                    "host": "{fqdn}",
                    "path": "/path/"
                },
                "security": "none"
            }
        },

Client configuration:

        // "tag": "out-vless_h2"
        {
            "tag": "out-vless_h2",
            "protocol": "vless",
            "settings": {
                "vnext": [{
                        "address": "fqdn",
                        "port": 443,
                        "users": [{
                                "UUID",
                                "encryption": "none"
                            }
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "h2",
                "httpSettings": {
                    "host": "fqdn",
                    "path": "/path/"
                },
                "security": "tls",
                "tlsSettings": {
                    "allowInsecure": false
                }
            }
        },


        //out-vmess_h2
        {
            "tag": "out-vmess_h2",
            "protocol": "vmess",
            "settings": {
                "vnext": [{
                        "address": "fqdn",
                        "port": 443,
                        "users": [{
                                "id": "UUID",
                                "alterId": 64,
                                "security": "aes-128-gcm",
                                "testsEnabled": "VMessAEAD"
                            }
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "h2",
                "httpSettings": {
                    "host": "fqdn",
                    "path": "/path/"
                },
                "security": "tls",
                "tlsSettings": {
                    "allowInsecure": false
                }
            }
        },
  1. Please attach error logs, especially the bottom lines if the file is large. Error log file is usually at /var/log/v2ray/error.log on Linux.

Server error log:

=== [[[ vless ]===

2020/08/24 12:38:21 [Info] [1739102002] v2ray.com/core/proxy/vless/inbound: received request for tcp:192.168.1.1:3389
2020/08/24 12:38:21 [Info] [1739102002] v2ray.com/core/app/dispatcher: taking detour [out-direct] for [tcp:192.168.1.1:3389]
2020/08/24 12:38:21 [Info] [1739102002] v2ray.com/core/proxy/freedom: opening connection to tcp:192.168.1.1:3389
2020/08/24 12:38:21 [Info] [1739102002] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:192.168.1.1:3389
2020/08/24 12:38:25 [Info] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled
2020/08/24 12:38:25 [Info] v2ray.com/core/transport/internet/udp: failed to handle UDP input > io: read/write on closed pipe

2020/08/24 12:38:25 [Info] [3906587314] v2ray.com/core/proxy/vless/inbound: firstLen = 73
2020/08/24 12:38:25 [Info] [3906587314] v2ray.com/core/proxy/vless/inbound: received request for tcp:192.168.1.1:3389
2020/08/24 12:38:25 [Info] [3906587314] v2ray.com/core/app/dispatcher: taking detour [out-direct] for [tcp:192.168.1.1:3389]
2020/08/24 12:38:25 [Info] [3906587314] v2ray.com/core/proxy/freedom: opening connection to tcp:192.168.1.1:3389
2020/08/24 12:38:25 [Info] [3906587314] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:192.168.1.1:3389

2020/08/24 12:38:25 [Info] [1739102002] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vless/inbound: connection ends > context canceled
2020/08/24 12:38:25 [Info] [1739102002] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > context canceled

2020/08/24 12:38:25 [Info] [454248298] v2ray.com/core/proxy/vless/inbound: firstLen = 1258
2020/08/24 12:38:25 [Info] [454248298] v2ray.com/core/proxy/vless/inbound: received request for udp:192.168.1.1:3389
2020/08/24 12:38:25 [Info] [454248298] v2ray.com/core/app/dispatcher: taking detour [out-direct] for [udp:192.168.1.1:3389]
2020/08/24 12:38:25 [Info] [454248298] v2ray.com/core/proxy/freedom: opening connection to udp:192.168.1.1:3389

Client error log:

=== [[[ vless ]===
2020/08/24 12:38:25 [Info] [4219923563] v2ray.com/core/app/dispatcher: taking detour [out-vless_h2] for [tcp:192.168.1.1:3389]
2020/08/24 12:38:25 [Info] [4219923563] v2ray.com/core/proxy/vless/outbound: tunneling request to tcp:192.168.1.1:3389 via tcp:fqdn:443

2020/08/24 12:38:25 [Info] [3881669924] v2ray.com/core/proxy/dokodemo: received request for 192.168.0.56:61423
2020/08/24 12:38:25 [Info] [3881669924] v2ray.com/core/app/dispatcher: taking detour [out-vless_h2] for [udp:192.168.11.1:3389]
2020/08/24 12:38:25 [Info] [3881669924] v2ray.com/core/proxy/vless/outbound: tunneling request to udp:192.168.1.1:3389 via tcp:fqdn:443
  1. Please attach access log. Access log is usually at '/var/log/v2ray/access.log' on Linux.
    // Please attach your server access log here.
  1. Other configurations (such as Nginx) and logs.
    流程: v2client -(tls+h2)-> [internet] -(tls+h2)-> haproxy -(h2c)-> v2server

  2. If V2Ray doesn't run, please attach output from --test.

The command is usually /usr/bin/v2ray/v2ray --test --config /etc/v2ray/config.json, but may vary according to your scenario.

  1. If V2Ray service doesn't run, please attach journal log.

Usual command is journalctl -u v2ray.

Please review your issue before submitting.

@RPRX
Copy link
Contributor

RPRX commented Aug 24, 2020

按照你写的流程,Client 的 port 似乎不应该填 44391

@kingwilliam
Copy link
Author

抱歉, port不是重点(因已随意修改)

@RPRX
Copy link
Contributor

RPRX commented Aug 24, 2020

尝试开启 Mux,看还会不会有问题

@kingwilliam
Copy link
Author

kingwilliam commented Aug 24, 2020

在vless 加入

"mux": {
    "enabled": true,
    "concurrency": 8
}

enable和disable 各测试3次.
!!! 真的可解决问题. !!!
enable 後, 3次connect 都可成功连线.
disable 後, 3次connect 都出现不同的error, 就是连线失败.

请问 h2 不是本身已支援 多路复用吗? 为何还要开启mux?

@RPRX
Copy link
Contributor

RPRX commented Aug 24, 2020

尝试 Mux 只是为了对比测试,我需要研究一下 VLESS 和 Mux 处理 UDP 的不同

@RPRX
Copy link
Contributor

RPRX commented Aug 24, 2020

还请测试下 VLESS + TCP / WS 是否也有这样的问题

@kingwilliam
Copy link
Author

ws 已测试, 有同样问题, 加入mux後就正常.
tcp 晚点测试

@twzchi
Copy link

twzchi commented Aug 29, 2020

VLESS的4.27.0对V2rayNG的兼容会有问题。。。(TCP+TLS)速度不稳定,等待更新
期待FQ下载速度能有所提升~
后来还是用回来Sock+TLS模式
今天看更新了4.27.4还没有去测试。。。。

@xsm1997
Copy link

xsm1997 commented Sep 3, 2020

遇到了同样的问题,在使用VLESS玩手游(失落的龙约)时,无法正常联机,切换VMess或开启Mux后正常。使用VLESS + TCP + TLS配置。

@twzchi
Copy link

twzchi commented Sep 3, 2020

遇到了同样的问题,在使用VLESS玩手游(失落的龙约)时,无法正常联机,切换VMess或开启Mux后正常。使用VLESS + TCP + TLS配置。

今天我看又更新了 ,你是更新的最新版本?(V4.27.5)

@RPRX
Copy link
Contributor

RPRX commented Sep 3, 2020

ws 已测试, 有同样问题, 加入mux後就正常.
tcp 晚点测试

有可能是 MTU 相关问题,把 common/buf/buffer.go 的 Size 改为 1024 试试?

@kingwilliam
Copy link
Author

kingwilliam commented Sep 4, 2020

有可能是 MTU 相关问题,把 common/buf/buffer.go 的 Size 改为 1024 试试?

已测试修改 buffer.go 由2048->1024, client 和 server 双方都更新用buffer 1024的v2ray 情况依旧 没分别.

const (
        // Size of a regular buffer.
        Size = 1024
)

@RPRX
Copy link
Contributor

RPRX commented Sep 5, 2020

发现问题在哪了:不开启 Mux 时传输大的 UDP 包会遇到问题(因为是 UDP over TCP,会被自动分割,接收方就不能一次性收到一个完整的 UDP 包了),开发时以为 V2Ray 的组件自己处理了,测试时及日常使用也难碰到这个问题。修复很简单,开头加两个字节表示长度即可,但这是一个不兼容改动,所以我想试试干脆直接 FullCone。

@RPRX
Copy link
Contributor

RPRX commented Sep 6, 2020

简单研究了一下,目前 v2ray 实现 FullCone 主要存在以下三个问题:

  1. Socks5 入站和 Freedom 出站返回 UDP 包时都扔掉了真实的源地址,需要改
  2. VLESS 需要加一个隧道模式,同时进行本地端口与远程端口的绑定(远程端口资源也需要考虑)
  3. FullCone 与路由冲突,本地路由必须只有一个出口,远程路由也建议尽量只有一个出口

由于以上三个问题的存在,现在的 UDP 模式仍有必要,我会先简单修复 VLESS 现在的 UDP 问题,PREVIEW 3 系列实现 FullCone。

(到时 FullCone 是另一个模式,用户可以自行设置)

@RPRX
Copy link
Contributor

RPRX commented Sep 7, 2020

决定 UDP over TCP 默认使用聚合隧道模式(起名:XUDP),支持实现 FullCone 等各种 NAT 类型,每个包格式如下,往返相同:

1 字节 1 字节 T 字节 2 字节 X 字节
子隧道标识 地址类型 地址和端口 长度 载荷

其中“地址类型”决定“地址和端口”:

\x00,复用该子隧道上一次发的地址和端口,T = 0
\x01,4B IPv4 + 2B 端口,T = 6
\x02,1B 长度 L + LB 域名 + 2B 端口,T = 3 + L
\x03,16B IPv6 + 2B 端口,T = 18

客户端可以配置:
多少秒无通信则丢弃子隧道;一条 TCP 最多同时存在多少子隧道;基于四元组的发包子隧道分配、收包过滤策略(控制 NAT 行为)

服务端可以配置:
多少秒无通信则丢弃子隧道(若绑定了端口则同时解绑);基于子隧道和二元组的发包端口分配、收包过滤策略(控制 NAT 行为)


普通使用场景下,由于默认使用聚合隧道模式,UDP 将会有更低的延迟。打游戏等 UDP 包较多的场景下,建议控制子隧道数量。

当然,不能开启 Mux。另一个我已经做出原型且实测支持浏览各种网站的技术 XTLS(避免 TLS 重复加密)也不能开启 Mux,这两项增强分别针对 UDP 和 TCP,成熟后可以和 Mux 说再见了。不过这两项增强先推出哪个都不太合适,所以目前打算 PREVIEW 2 系列一步到位同时推出(或先推出 XTLS 再推出 XUDP),但由于要写的代码比较多且我最近比较忙,开发可能会停滞一段时间。

@RPRX
Copy link
Contributor

RPRX commented Sep 24, 2020

v4.29.0+,启用 XTLS 时 UDP 应该不存在这个问题了(为了避免炸掉,暂未改变不启用 XTLS 时的行为)。

@zhaoyadong00
Copy link

决定 UDP over TCP 默认使用聚合隧道模式(起名:XUDP),支持实现 FullCone 等各种 NAT 类型,每个包格式如下,往返相同:

1 字节 1 字节 T 字节 2 字节 X 字节
子隧道标识 地址类型 地址和端口 长度 载荷
其中“地址类型”决定“地址和端口”:

\x00,复用该子隧道上一次发的地址和端口,T = 0
\x01,4B IPv4 + 2B 端口,T = 6
\x02,1B 长度 L + LB 域名 + 2B 端口,T = 3 + L
\x03,16B IPv6 + 2B 端口,T = 18

客户端可以配置:
多少秒无通信则丢弃子隧道;一条 TCP 最多同时存在多少子隧道;基于四元组的发包子隧道分配、收包过滤策略(控制 NAT 行为)

服务端可以配置:
多少秒无通信则丢弃子隧道(若绑定了端口则同时解绑);基于子隧道和二元组的发包端口分配、收包过滤策略(控制 NAT 行为)

普通使用场景下,由于默认使用聚合隧道模式,UDP 将会有更低的延迟。打游戏等 UDP 包较多的场景下,建议控制子隧道数量。

当然,不能开启 Mux。另一个我已经做出原型且实测支持浏览各种网站的技术 XTLS(避免 TLS 重复加密)也不能开启 Mux,这两项增强分别针对 UDP 和 TCP,成熟后可以和 Mux 说再见了。不过这两项增强先推出哪个都不太合适,所以目前打算 PREVIEW 2 系列一步到位同时推出(或先推出 XTLS 再推出 XUDP),但由于要写的代码比较多且我最近比较忙,开发可能会停滞一段时间。

那个版本有xudp

@RPRX
Copy link
Contributor

RPRX commented Sep 27, 2020

@zhaoyadong00

目前没有。

@LearZhou
Copy link

v4.29.0版,用VLESS+ws+TLS的方案(當然沒有XTLS了),UDP還是有阻擋問題,確認通過加入mux選項可以緩解。

這個bug修復,是計劃在下一個版本嗎?

@RPRX
Copy link
Contributor

RPRX commented Sep 28, 2020

@LearZhou

预计下个版本将通过 breaking change 修复此问题,同时也是测试版 VLESS 协议本身的唯一一次 breaking。

@RPRX
Copy link
Contributor

RPRX commented Sep 30, 2020

#239

Bleeding 编译完成后可以测试一下。

@RPRX
Copy link
Contributor

RPRX commented Sep 30, 2020

XUDP 则会出现在 VLESS 正式版中。

@XuuKoo
Copy link

XuuKoo commented Oct 2, 2020

我这边测试,用tls+web的方法,vps上只开443端口,netch的NAT测试显示的4,但是把vps所有端口或者1024以上端口都允许的话,NAT等级就是1了。

@kingwilliam
Copy link
Author

v4.30.0 已解决

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants