diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 2fe0fec551e7..3fe69df5bf82 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -6,6 +6,7 @@ import ( goerrors "errors" "io" "math/big" + "time" "github.com/xtls/xray-core/common/dice" @@ -18,6 +19,7 @@ import ( "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/features/policy" @@ -223,6 +225,19 @@ func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { case "reject": test(errors.New("XUDP rejected UDP/443 traffic").AtInfo()) return + case "drop": + errors.LogInfo(ctx, "XUDP dropped UDP/443 traffic") + ctx, cancel := context.WithCancel(ctx) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + }, time.Duration(30+dice.Roll(61))*time.Second) + go func() { + buf.Copy(link.Reader, buf.Discard, buf.UpdateActivity(timer)) + <-ctx.Done() + common.Interrupt(link.Writer) + common.Interrupt(link.Reader) + }() + return case "skip": goto out } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 91d16118392b..838c72101b02 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -110,7 +110,7 @@ func (m *MuxConfig) Build() (*proxyman.MultiplexingConfig, error) { switch m.XudpProxyUDP443 { case "": m.XudpProxyUDP443 = "reject" - case "reject", "allow", "skip": + case "reject", "allow", "skip", "drop": default: return nil, errors.New(`unknown "xudpProxyUDP443": `, m.XudpProxyUDP443) }