Skip to content

Commit 5708edd

Browse files
authored
VLESS PREVIEW 1.3
1 parent e425876 commit 5708edd

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

proxy/vless/inbound/inbound.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
121121
first := buf.New()
122122
first.ReadFrom(connection)
123123

124-
var fallback uint32
125-
var addrport string
126-
var unixpath string
127-
var proxyver uint32
128-
129-
if h.fallback != nil {
130-
fallback = 1
131-
addrport = h.addrport
132-
unixpath = h.fallback.Unix
133-
proxyver = h.fallback.Xver
134-
}
135-
136-
if h.fallback_h2 != nil {
137-
iConn := connection
138-
if statConn, ok := iConn.(*internet.StatCouterConnection); ok {
139-
iConn = statConn.Connection
140-
}
141-
if tlsConn, ok := iConn.(*tls.Conn); ok {
142-
if tlsConn.ConnectionState().NegotiatedProtocol == "h2" {
143-
fallback = 2
144-
addrport = h.addrport_h2
145-
unixpath = h.fallback_h2.Unix
146-
proxyver = h.fallback_h2.Xver
147-
}
148-
}
149-
}
150-
151124
sid := session.ExportIDToError(ctx)
152125
newError("firstLen = ", first.Len()).AtInfo().WriteToLog(sid)
153126

@@ -161,7 +134,12 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
161134
var err error
162135
var pre *buf.Buffer
163136

164-
if fallback > 0 && first.Len() < 18 {
137+
fallback := 0
138+
if h.fallback != nil {
139+
fallback = 1
140+
}
141+
142+
if fallback == 1 && first.Len() < 18 {
165143
err = newError("fallback directly")
166144
} else {
167145
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
172150

173151
if err != nil {
174152

175-
if fallback > 0 {
153+
if fallback == 1 {
154+
if h.fallback_h2 != nil {
155+
iConn := connection
156+
if statConn, ok := iConn.(*internet.StatCouterConnection); ok {
157+
iConn = statConn.Connection
158+
}
159+
if tlsConn, ok := iConn.(*tls.Conn); ok {
160+
if tlsConn.ConnectionState().NegotiatedProtocol == "h2" {
161+
fallback = 2
162+
}
163+
}
164+
}
165+
166+
var addrport string
167+
var unixpath string
168+
var proxyver uint32
169+
176170
switch fallback {
177171
case 1:
172+
addrport = h.addrport
173+
unixpath = h.fallback.Unix
174+
proxyver = h.fallback.Xver
178175
newError("fallback starts").Base(err).AtInfo().WriteToLog(sid)
179176
case 2:
177+
addrport = h.addrport_h2
178+
unixpath = h.fallback_h2.Unix
179+
proxyver = h.fallback_h2.Xver
180180
newError("fallback_h2 starts").Base(err).AtInfo().WriteToLog(sid)
181181
}
182182

0 commit comments

Comments
 (0)