mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-14 17:49:15 -04:00
VLESS PREVIEW 2.3
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
func EncodeHeaderAddons(buffer *buf.Buffer, addons *Addons) error {
|
||||
|
||||
switch addons.Flow {
|
||||
case vless.XRO:
|
||||
case vless.XRO, vless.XRD:
|
||||
|
||||
bytes, err := proto.Marshal(addons)
|
||||
if err != nil {
|
||||
|
||||
@@ -158,9 +158,9 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
||||
}
|
||||
|
||||
first := buf.New()
|
||||
first.ReadFrom(connection)
|
||||
defer first.Release()
|
||||
|
||||
firstLen := first.Len()
|
||||
firstLen, _ := first.ReadFrom(connection)
|
||||
newError("firstLen = ", firstLen).AtInfo().WriteToLog(sid)
|
||||
|
||||
reader := &buf.BufferedReader{
|
||||
@@ -172,11 +172,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
||||
var requestAddons *encoding.Addons
|
||||
var err error
|
||||
|
||||
isfb := false
|
||||
apfb := h.fallbacks
|
||||
if apfb != nil {
|
||||
isfb = true
|
||||
}
|
||||
isfb := apfb != nil
|
||||
|
||||
if isfb && firstLen < 18 {
|
||||
err = newError("fallback directly")
|
||||
@@ -379,25 +376,31 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
|
||||
}
|
||||
|
||||
switch requestAddons.Flow {
|
||||
case vless.XRO:
|
||||
if account.Flow == vless.XRO {
|
||||
case vless.XRO, vless.XRD:
|
||||
if account.Flow == vless.XRO || account.Flow == vless.XRD {
|
||||
switch request.Command {
|
||||
case protocol.RequestCommandMux:
|
||||
return newError(vless.XRO + " doesn't support Mux").AtWarning()
|
||||
return newError(requestAddons.Flow + " doesn't support Mux").AtWarning()
|
||||
case protocol.RequestCommandUDP:
|
||||
return newError(vless.XRO + " doesn't support UDP").AtWarning()
|
||||
return newError(requestAddons.Flow + " doesn't support UDP").AtWarning()
|
||||
case protocol.RequestCommandTCP:
|
||||
if xtlsConn, ok := iConn.(*xtls.Conn); ok {
|
||||
xtlsConn.RPRX = true
|
||||
xtlsConn.SHOW = xtls_show
|
||||
xtlsConn.MARK = "XTLS"
|
||||
if requestAddons.Flow == vless.XRD {
|
||||
xtlsConn.DirectMode = true
|
||||
}
|
||||
} else {
|
||||
return newError(`failed to use ` + vless.XRO + `, maybe "security" is not "xtls"`).AtWarning()
|
||||
return newError(`failed to use ` + requestAddons.Flow + `, maybe "security" is not "xtls"`).AtWarning()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return newError(account.ID.String() + " is not able to use " + vless.XRO).AtWarning()
|
||||
return newError(account.ID.String() + " is not able to use " + requestAddons.Flow).AtWarning()
|
||||
}
|
||||
case "":
|
||||
default:
|
||||
return newError("unknown request flow " + requestAddons.Flow).AtWarning()
|
||||
}
|
||||
|
||||
if request.Command != protocol.RequestCommandMux {
|
||||
|
||||
@@ -126,14 +126,19 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||
Flow: account.Flow,
|
||||
}
|
||||
|
||||
allowUDP443 := false
|
||||
switch requestAddons.Flow {
|
||||
case vless.XRO, vless.XRO + "-udp443":
|
||||
case vless.XRO + "-udp443", vless.XRD + "-udp443":
|
||||
allowUDP443 = true
|
||||
requestAddons.Flow = requestAddons.Flow[:16]
|
||||
fallthrough
|
||||
case vless.XRO, vless.XRD:
|
||||
switch request.Command {
|
||||
case protocol.RequestCommandMux:
|
||||
return newError(vless.XRO + " doesn't support Mux").AtWarning()
|
||||
return newError(requestAddons.Flow + " doesn't support Mux").AtWarning()
|
||||
case protocol.RequestCommandUDP:
|
||||
if requestAddons.Flow == vless.XRO && request.Port == 443 {
|
||||
return newError(vless.XRO + " stopped UDP/443").AtInfo()
|
||||
if !allowUDP443 && request.Port == 443 {
|
||||
return newError(requestAddons.Flow + " stopped UDP/443").AtInfo()
|
||||
}
|
||||
requestAddons.Flow = ""
|
||||
case protocol.RequestCommandTCP:
|
||||
@@ -141,10 +146,12 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||
xtlsConn.RPRX = true
|
||||
xtlsConn.SHOW = xtls_show
|
||||
xtlsConn.MARK = "XTLS"
|
||||
if requestAddons.Flow == vless.XRD {
|
||||
xtlsConn.DirectMode = true
|
||||
}
|
||||
} else {
|
||||
return newError(`failed to use ` + vless.XRO + `, maybe "security" is not "xtls"`).AtWarning()
|
||||
return newError(`failed to use ` + requestAddons.Flow + `, maybe "security" is not "xtls"`).AtWarning()
|
||||
}
|
||||
requestAddons.Flow = vless.XRO
|
||||
}
|
||||
default:
|
||||
if _, ok := iConn.(*xtls.Conn); ok {
|
||||
|
||||
@@ -9,4 +9,5 @@ package vless
|
||||
|
||||
const (
|
||||
XRO = "xtls-rprx-origin"
|
||||
XRD = "xtls-rprx-direct"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user