Skip to content

Commit

Permalink
VLESS PREVIEW 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
RPRX authored Aug 4, 2020
1 parent e425876 commit 5708edd
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions proxy/vless/inbound/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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)
}

Expand Down

0 comments on commit 5708edd

Please sign in to comment.