From de92bc0234a6b0a2b36f6580361e2d768d3a8805 Mon Sep 17 00:00:00 2001 From: Hellojack <106379370+H1JK@users.noreply.github.com> Date: Sat, 25 Feb 2023 19:11:23 +0800 Subject: [PATCH] fix: Vision filter Client Hello --- transport/vless/conn.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/transport/vless/conn.go b/transport/vless/conn.go index fd1767cf..4750276e 100644 --- a/transport/vless/conn.go +++ b/transport/vless/conn.go @@ -215,12 +215,19 @@ func (vc *Conn) WriteBuffer(buffer *buf.Buffer) error { return vc.err } } - if vc.writeFilterApplicationData && vc.isTLS { + if vc.writeFilterApplicationData { buffer2 := ReshapeBuffer(buffer) defer buffer2.Release() vc.FilterTLS(buffer.Bytes()) command := commandPaddingContinue - if buffer.Len() > 6 && bytes.Equal(buffer.To(3), tlsApplicationDataStart) || vc.packetsToFilter <= 0 { + if !vc.isTLS { + command = commandPaddingEnd + + // disable XTLS + vc.readProcess = false + vc.writeFilterApplicationData = false + vc.packetsToFilter = 0 + } else if buffer.Len() > 6 && bytes.Equal(buffer.To(3), tlsApplicationDataStart) || vc.packetsToFilter <= 0 { command = commandPaddingEnd if vc.enableXTLS { command = commandPaddingDirect @@ -239,7 +246,7 @@ func (vc *Conn) WriteBuffer(buffer *buf.Buffer) error { //time.Sleep(10 * time.Millisecond) } if buffer2 != nil { - if vc.writeDirect { + if vc.writeDirect || !vc.isTLS { return vc.ExtendedWriter.WriteBuffer(buffer2) } vc.FilterTLS(buffer2.Bytes()) @@ -340,12 +347,7 @@ func (vc *Conn) sendRequest(p []byte) bool { if isVision && !vc.dst.UDP && !vc.dst.Mux { if len(p) == 0 { - WriteWithPadding(buffer, nil, commandPaddingEnd, vc.id) - - // disable XTLS - vc.readProcess = false - vc.writeFilterApplicationData = false - vc.packetsToFilter = 0 + WriteWithPadding(buffer, nil, commandPaddingContinue, vc.id) } else { vc.FilterTLS(p) if vc.isTLS {