1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-12 19:00:43 +00:00

Merge pull request #80 from rprx/master

VLESS PREVIEW 1.3
This commit is contained in:
RPRX 2020-08-04 13:30:23 +00:00 committed by GitHub
commit a4d411b085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,33 +121,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
first := buf.New()
first.ReadFrom(connection)
var fallback uint32
var addrport string
var unixpath string
var proxyver uint32
if h.fallback != nil {
fallback = 1
addrport = h.addrport
unixpath = h.fallback.Unix
proxyver = h.fallback.Xver
}
if h.fallback_h2 != nil {
iConn := connection
if statConn, ok := iConn.(*internet.StatCouterConnection); ok {
iConn = statConn.Connection
}
if tlsConn, ok := iConn.(*tls.Conn); ok {
if tlsConn.ConnectionState().NegotiatedProtocol == "h2" {
fallback = 2
addrport = h.addrport_h2
unixpath = h.fallback_h2.Unix
proxyver = h.fallback_h2.Xver
}
}
}
sid := session.ExportIDToError(ctx)
newError("firstLen = ", first.Len()).AtInfo().WriteToLog(sid)
@ -161,7 +134,12 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
var err error
var pre *buf.Buffer
if fallback > 0 && first.Len() < 18 {
fallback := 0
if h.fallback != nil {
fallback = 1
}
if fallback == 1 && first.Len() < 18 {
err = newError("fallback directly")
} else {
request, requestAddons, err, pre = encoding.DecodeRequestHeader(reader, h.validator)
@ -172,11 +150,33 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
if err != nil {
if fallback > 0 {
if fallback == 1 {
if h.fallback_h2 != nil {
iConn := connection
if statConn, ok := iConn.(*internet.StatCouterConnection); ok {
iConn = statConn.Connection
}
if tlsConn, ok := iConn.(*tls.Conn); ok {
if tlsConn.ConnectionState().NegotiatedProtocol == "h2" {
fallback = 2
}
}
}
var addrport string
var unixpath string
var proxyver uint32
switch fallback {
case 1:
addrport = h.addrport
unixpath = h.fallback.Unix
proxyver = h.fallback.Xver
newError("fallback starts").Base(err).AtInfo().WriteToLog(sid)
case 2:
addrport = h.addrport_h2
unixpath = h.fallback_h2.Unix
proxyver = h.fallback_h2.Xver
newError("fallback_h2 starts").Base(err).AtInfo().WriteToLog(sid)
}