From ce074ce572d4e20460df33e21f8e411b3cb03839 Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Thu, 19 Nov 2026 19:25:41 +0800 Subject: [PATCH] Env: Remove `XRAY_CONE_DISABLED` (#6110) https://github.com/XTLS/Xray-core/pull/6057#issuecomment-4364744151 https://github.com/XTLS/Xray-core/pull/6075#issuecomment-4395258425 https://github.com/XTLS/Xray-core/pull/6110#issuecomment-7003152469 --- app/proxyman/inbound/worker.go | 8 +------- common/platform/platform.go | 1 - common/xudp/xudp.go | 3 --- core/xray.go | 2 -- proxy/shadowsocks/server.go | 4 +--- proxy/socks/server.go | 4 +--- proxy/trojan/server.go | 4 +--- proxy/vless/outbound/outbound.go | 4 +--- proxy/vmess/outbound/outbound.go | 4 +--- 9 files changed, 6 insertions(+), 28 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 4a3bb6d55..310151705 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -273,8 +273,7 @@ type udpWorker struct { checker *task.Periodic activeConn map[connID]*udpConn - ctx context.Context - cone bool + ctx context.Context } func (w *udpWorker) getConnection(id connID) (*udpConn, bool) { @@ -316,9 +315,6 @@ func (w *udpWorker) callback(b *buf.Buffer, source net.Destination, originalDest src: source, } if originalDest.IsValid() { - if !w.cone { - id.dest = originalDest - } b.UDP = &originalDest } conn, existing := w.getConnection(id) @@ -418,8 +414,6 @@ func (w *udpWorker) Start() error { return err } - w.cone = w.ctx.Value("cone").(bool) - w.checker = &task.Periodic{ Interval: time.Minute, Execute: w.clean, diff --git a/common/platform/platform.go b/common/platform/platform.go index ce7c323db..5fdfe56d5 100644 --- a/common/platform/platform.go +++ b/common/platform/platform.go @@ -16,7 +16,6 @@ const ( UseReadV = "xray.buf.readv" UseFreedomSplice = "xray.buf.splice" UseVmessPadding = "xray.vmess.padding" - UseCone = "xray.cone.disabled" UseStrictJSON = "xray.json.strict" BufferSize = "xray.ray.buffer.size" diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index 30841b1e1..2a8ec056f 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -63,9 +63,6 @@ func init() { } func GetGlobalID(ctx context.Context) (globalID [8]byte) { - if cone := ctx.Value("cone"); cone == nil || !cone.(bool) { // cone is nil only in some unit tests - return - } if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.Network == net.Network_UDP && (inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks" || inbound.Name == "tun") { h := blake3.New(8, ensureBaseKey()) diff --git a/core/xray.go b/core/xray.go index 794ce8fff..85a3f3a95 100644 --- a/core/xray.go +++ b/core/xray.go @@ -192,8 +192,6 @@ func initInstanceWithConfig(config *Config, server *Instance) (bool, error) { if err := platform.ReloadEnvSettings(); err != nil { return true, errors.New("failed to reload environment settings").Base(err) } - server.ctx = context.WithValue(server.ctx, "cone", - platform.NewEnvFlag(platform.UseCone).GetValue(func() string { return "" }) != "true") for _, appSettings := range config.App { settings, err := appSettings.GetInstance() diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index 7c965b9f6..b15f66433 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -25,7 +25,6 @@ type Server struct { config *ServerConfig validator *Validator policyManager policy.Manager - cone bool } // NewServer create a new Shadowsocks server. @@ -47,7 +46,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { config: config, validator: validator, policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - cone: ctx.Value("cone").(bool), } return s, nil @@ -185,7 +183,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis data.UDP = &destination - if !s.cone || dest == nil { + if dest == nil { dest = &destination } diff --git a/proxy/socks/server.go b/proxy/socks/server.go index eb7f8e30e..2c2ced638 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -29,7 +29,6 @@ import ( type Server struct { config *ServerConfig policyManager policy.Manager - cone bool httpServer *http.Server } @@ -39,7 +38,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { s := &Server{ config: config, policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - cone: ctx.Value("cone").(bool), } httpConfig := &http.ServerConfig{ UserLevel: config.UserLevel, @@ -277,7 +275,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis payload.UDP = &destination - if !s.cone || dest == nil { + if dest == nil { dest = &destination } diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 8fd19beb2..ca7b6bf0e 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -38,7 +38,6 @@ type Server struct { policyManager policy.Manager validator *Validator fallbacks map[string]map[string]map[string]*Fallback // or nil - cone bool } // NewServer creates a new trojan inbound handler. @@ -59,7 +58,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { server := &Server{ policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), validator: validator, - cone: ctx.Value("cone").(bool), } if config.Fallbacks != nil { @@ -302,7 +300,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, sessionPolicy policy.Sess } errors.LogInfo(ctx, "tunnelling request to ", destination) - if !s.cone || dest == nil { + if dest == nil { dest = &destination } diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 3f6b4b191..9a685a22a 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -50,7 +50,6 @@ func init() { type Handler struct { server *protocol.ServerSpec policyManager policy.Manager - cone bool encryption *encryption.ClientInstance reverse *Reverse @@ -78,7 +77,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) { handler := &Handler{ server: server, policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - cone: ctx.Value("cone").(bool), } a := handler.server.User.Account.(*vless.MemoryAccount) @@ -300,7 +298,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte clientReader := link.Reader // .(*pipe.Reader) clientWriter := link.Writer // .(*pipe.Writer) trafficState := proxy.NewTrafficState(account.ID.Bytes()) - if request.Command == protocol.RequestCommandUDP && (requestAddons.Flow == vless.XRV || (h.cone && request.Port != 53 && request.Port != 443)) { + if request.Command == protocol.RequestCommandUDP && (requestAddons.Flow == vless.XRV || (request.Port != 53 && request.Port != 443)) { request.Command = protocol.RequestCommandMux request.Address = net.DomainAddress("v1.mux.cool") request.Port = net.Port(666) diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index a475dac92..8765bb9c1 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -32,7 +32,6 @@ import ( type Handler struct { server *protocol.ServerSpec policyManager policy.Manager - cone bool } // New creates a new VMess outbound handler. @@ -49,7 +48,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) { handler := &Handler{ server: server, policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - cone: ctx.Value("cone").(bool), } return handler, nil @@ -143,7 +141,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } }, sessionPolicy.Timeouts.ConnectionIdle) - if request.Command == protocol.RequestCommandUDP && h.cone && request.Port != 53 && request.Port != 443 { + if request.Command == protocol.RequestCommandUDP && request.Port != 53 && request.Port != 443 { request.Command = protocol.RequestCommandMux request.Address = net.DomainAddress("v1.mux.cool") request.Port = net.Port(666)