Compare commits

...
Author SHA1 Message Date
Fangliding ca7ede95ed Early reject 2026-11-22 23:09:37 +08:00
Fangliding 4ffdff3313 xudp 2026-11-22 22:27:43 +08:00
Fangliding 49347bad1f Fix vless UDP 443 block 2026-11-22 22:27:37 +08:00
3 changed files with 32 additions and 7 deletions
+1
View File
@@ -223,6 +223,7 @@ func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) {
if ob.Target.Network == net.Network_UDP && ob.Target.Port == 443 {
switch h.udp443 {
case "reject":
proxy.DropUDP(ctx, link.Reader)
test(errors.New("XUDP rejected UDP/443 traffic"))
return
case "skip":
+24
View File
@@ -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))
}
+7 -7
View File
@@ -152,6 +152,13 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
rec := h.server
var conn stat.Connection
account := rec.User.Account.(*vless.MemoryAccount)
if ob.Target.Network == net.Network_UDP && ob.Target.Port == 443 && account.Flow == vless.XRV {
proxy.DropUDP(ctx, link.Reader)
return errors.New("XTLS rejected UDP/443 traffic")
}
if h.testpre > 0 && h.reverse == nil {
h.initpre.Do(func() {
h.preConns = make(chan *ConnExpire)
@@ -233,27 +240,20 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
Port: target.Port,
}
account := request.User.Account.(*vless.MemoryAccount)
requestAddons := &encoding.Addons{
Flow: account.Flow,
}
var input *bytes.Reader
var rawInput **bytes.Buffer
allowUDP443 := false
switch requestAddons.Flow {
case vless.XRV + "-udp443":
allowUDP443 = true
requestAddons.Flow = requestAddons.Flow[:16]
fallthrough
case vless.XRV:
ob.CanSpliceCopy = 2
switch request.Command {
case protocol.RequestCommandUDP:
if !allowUDP443 && request.Port == 443 {
return errors.New("XTLS rejected UDP/443 traffic")
}
case protocol.RequestCommandMux:
fallthrough // let server break Mux connections that contain TCP requests
case protocol.RequestCommandTCP, protocol.RequestCommandRvs: