1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

VLESS UDP over TCP struct breaking change (#239)

具体改变:每个 UDP 载荷前加两字节长度的 length,最大值为 2048-2=2046。若不使用 Mux,服务端与客户端均需升级至 v4.30.0+。这是 VLESS 公测版(0)协议结构本身唯一一次 breaking change,正式版(1)的服务端预计会长期同时支持该版本,第三方客户端的实现应当尽快跟进。
This commit is contained in:
RPRX 2020-09-30 01:39:03 +00:00 committed by GitHub
parent dfed0dc03a
commit 65565572d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -76,7 +76,7 @@ func DecodeHeaderAddons(buffer *buf.Buffer, reader io.Reader) (*Addons, error) {
func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, addons *Addons) buf.Writer { func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, addons *Addons) buf.Writer {
switch addons.Flow { switch addons.Flow {
case vless.XRO: default:
if request.Command == protocol.RequestCommandUDP { if request.Command == protocol.RequestCommandUDP {
return NewMultiLengthPacketWriter(writer.(buf.Writer)) return NewMultiLengthPacketWriter(writer.(buf.Writer))
@ -92,7 +92,7 @@ func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, addons
func DecodeBodyAddons(reader io.Reader, request *protocol.RequestHeader, addons *Addons) buf.Reader { func DecodeBodyAddons(reader io.Reader, request *protocol.RequestHeader, addons *Addons) buf.Reader {
switch addons.Flow { switch addons.Flow {
case vless.XRO: default:
if request.Command == protocol.RequestCommandUDP { if request.Command == protocol.RequestCommandUDP {
return NewLengthPacketReader(reader) return NewLengthPacketReader(reader)
@ -197,7 +197,7 @@ func (r *LengthPacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
mb := make(buf.MultiBuffer, 0, length/buf.Size+1) mb := make(buf.MultiBuffer, 0, length/buf.Size+1)
for length > 0 { for length > 0 {
size := length size := length
if length > buf.Size { if size > buf.Size {
size = buf.Size size = buf.Size
} }
length -= size length -= size

View File

@ -386,7 +386,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
account := request.User.Account.(*vless.MemoryAccount) account := request.User.Account.(*vless.MemoryAccount)
responseAddons := &encoding.Addons{ responseAddons := &encoding.Addons{
Flow: requestAddons.Flow, //Flow: requestAddons.Flow,
} }
switch requestAddons.Flow { switch requestAddons.Flow {
@ -396,7 +396,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
case protocol.RequestCommandMux: case protocol.RequestCommandMux:
return newError(vless.XRO + " doesn't support Mux").AtWarning() return newError(vless.XRO + " doesn't support Mux").AtWarning()
case protocol.RequestCommandUDP: case protocol.RequestCommandUDP:
//return newError(vless.XRO + " doesn't support UDP").AtWarning() return newError(vless.XRO + " doesn't support UDP").AtWarning()
case protocol.RequestCommandTCP: case protocol.RequestCommandTCP:
if xtlsConn, ok := iConn.(*xtls.Conn); ok { if xtlsConn, ok := iConn.(*xtls.Conn); ok {
xtlsConn.RPRX = true xtlsConn.RPRX = true

View File

@ -135,7 +135,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
if requestAddons.Flow == vless.XRO && request.Port == 443 { if requestAddons.Flow == vless.XRO && request.Port == 443 {
return newError(vless.XRO + " stopped UDP/443").AtWarning() return newError(vless.XRO + " stopped UDP/443").AtWarning()
} }
requestAddons.Flow = vless.XRO requestAddons.Flow = ""
case protocol.RequestCommandTCP: case protocol.RequestCommandTCP:
if xtlsConn, ok := iConn.(*xtls.Conn); ok { if xtlsConn, ok := iConn.(*xtls.Conn); ok {
xtlsConn.RPRX = true xtlsConn.RPRX = true