From 210516d5edfc3bef938871de8459cb2dba222b2e Mon Sep 17 00:00:00 2001 From: Fangliding Date: Thu, 5 Nov 2026 16:32:23 +0800 Subject: [PATCH] Fix vless UDP 443 block --- proxy/drop.go | 24 ++++++++++++++++++++++++ proxy/vless/outbound/outbound.go | 1 + 2 files changed, 25 insertions(+) create mode 100644 proxy/drop.go diff --git a/proxy/drop.go b/proxy/drop.go new file mode 100644 index 000000000..b6df202ee --- /dev/null +++ b/proxy/drop.go @@ -0,0 +1,24 @@ +package proxy + +import ( + "context" + "math/rand/v2" + "time" + + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/signal" +) + +// wait to drain all the possible incoming UDP data +// because re-established QUIC UDP may bypass the sniffer +func DropUDP(ctx context.Context, reader buf.Reader) { + ctx, cancel := context.WithCancel(ctx) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + }, time.Duration(30+rand.N(60))*time.Second) + context.AfterFunc(ctx, func() { + common.Interrupt(reader) + }) + buf.Copy(reader, buf.Discard, buf.UpdateActivity(timer)) +} diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 8e0e78e16..bb6ca833f 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -291,6 +291,7 @@ func (h *Handler) process(ctx context.Context, link *transport.Link, dialer inte switch request.Command { case protocol.RequestCommandUDP: if !allowUDP443 && request.Port == 443 { + proxy.DropUDP(ctx, link.Reader) return nil, nil, errors.New("XTLS rejected UDP/443 traffic") } case protocol.RequestCommandTCP, protocol.RequestCommandMux, protocol.RequestCommandRvs: