Remove xray.cone.disabled env var

This commit is contained in:
Meo597
2026-05-10 19:16:30 +08:00
parent 1bdb488c9e
commit 813406c0df
9 changed files with 6 additions and 30 deletions
+1 -7
View File
@@ -273,8 +273,7 @@ type udpWorker struct {
checker *task.Periodic checker *task.Periodic
activeConn map[connID]*udpConn activeConn map[connID]*udpConn
ctx context.Context ctx context.Context
cone bool
} }
func (w *udpWorker) getConnection(id connID) (*udpConn, bool) { 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, src: source,
} }
if originalDest.IsValid() { if originalDest.IsValid() {
if !w.cone {
id.dest = originalDest
}
b.UDP = &originalDest b.UDP = &originalDest
} }
conn, existing := w.getConnection(id) conn, existing := w.getConnection(id)
@@ -418,8 +414,6 @@ func (w *udpWorker) Start() error {
return err return err
} }
w.cone = w.ctx.Value("cone").(bool)
w.checker = &task.Periodic{ w.checker = &task.Periodic{
Interval: time.Minute, Interval: time.Minute,
Execute: w.clean, Execute: w.clean,
-1
View File
@@ -16,7 +16,6 @@ const (
UseReadV = "xray.buf.readv" UseReadV = "xray.buf.readv"
UseFreedomSplice = "xray.buf.splice" UseFreedomSplice = "xray.buf.splice"
UseVmessPadding = "xray.vmess.padding" UseVmessPadding = "xray.vmess.padding"
UseCone = "xray.cone.disabled"
UseStrictJSON = "xray.json.strict" UseStrictJSON = "xray.json.strict"
BufferSize = "xray.ray.buffer.size" BufferSize = "xray.ray.buffer.size"
-3
View File
@@ -49,9 +49,6 @@ func init() {
} }
func GetGlobalID(ctx context.Context) (globalID [8]byte) { 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 && 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") { (inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks" || inbound.Name == "tun") {
h := blake3.New(8, BaseKey) h := blake3.New(8, BaseKey)
-4
View File
@@ -7,7 +7,6 @@ import (
"github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/platform"
"github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/features" "github.com/xtls/xray-core/features"
"github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/dns"
@@ -187,9 +186,6 @@ func NewWithContext(ctx context.Context, config *Config) (*Instance, error) {
} }
func initInstanceWithConfig(config *Config, server *Instance) (bool, error) { func initInstanceWithConfig(config *Config, server *Instance) (bool, error) {
server.ctx = context.WithValue(server.ctx, "cone",
platform.NewEnvFlag(platform.UseCone).GetValue(func() string { return "" }) != "true")
for _, appSettings := range config.App { for _, appSettings := range config.App {
settings, err := appSettings.GetInstance() settings, err := appSettings.GetInstance()
if err != nil { if err != nil {
+1 -3
View File
@@ -25,7 +25,6 @@ type Server struct {
config *ServerConfig config *ServerConfig
validator *Validator validator *Validator
policyManager policy.Manager policyManager policy.Manager
cone bool
} }
// NewServer create a new Shadowsocks server. // NewServer create a new Shadowsocks server.
@@ -47,7 +46,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
config: config, config: config,
validator: validator, validator: validator,
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
cone: ctx.Value("cone").(bool),
} }
return s, nil return s, nil
@@ -185,7 +183,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis
data.UDP = &destination data.UDP = &destination
if !s.cone || dest == nil { if dest == nil {
dest = &destination dest = &destination
} }
+1 -3
View File
@@ -28,7 +28,6 @@ import (
type Server struct { type Server struct {
config *ServerConfig config *ServerConfig
policyManager policy.Manager policyManager policy.Manager
cone bool
udpFilter *UDPFilter udpFilter *UDPFilter
httpServer *http.Server httpServer *http.Server
} }
@@ -39,7 +38,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
s := &Server{ s := &Server{
config: config, config: config,
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
cone: ctx.Value("cone").(bool),
} }
httpConfig := &http.ServerConfig{ httpConfig := &http.ServerConfig{
UserLevel: config.UserLevel, UserLevel: config.UserLevel,
@@ -263,7 +261,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis
payload.UDP = &destination payload.UDP = &destination
if !s.cone || dest == nil { if dest == nil {
dest = &destination dest = &destination
} }
+1 -3
View File
@@ -38,7 +38,6 @@ type Server struct {
policyManager policy.Manager policyManager policy.Manager
validator *Validator validator *Validator
fallbacks map[string]map[string]map[string]*Fallback // or nil fallbacks map[string]map[string]map[string]*Fallback // or nil
cone bool
} }
// NewServer creates a new trojan inbound handler. // NewServer creates a new trojan inbound handler.
@@ -59,7 +58,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
server := &Server{ server := &Server{
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
validator: validator, validator: validator,
cone: ctx.Value("cone").(bool),
} }
if config.Fallbacks != nil { 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) errors.LogInfo(ctx, "tunnelling request to ", destination)
if !s.cone || dest == nil { if dest == nil {
dest = &destination dest = &destination
} }
+1 -3
View File
@@ -52,7 +52,6 @@ func init() {
type Handler struct { type Handler struct {
server *protocol.ServerSpec server *protocol.ServerSpec
policyManager policy.Manager policyManager policy.Manager
cone bool
encryption *encryption.ClientInstance encryption *encryption.ClientInstance
reverse *Reverse reverse *Reverse
@@ -80,7 +79,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
handler := &Handler{ handler := &Handler{
server: server, server: server,
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
cone: ctx.Value("cone").(bool),
} }
a := handler.server.User.Account.(*vless.MemoryAccount) a := handler.server.User.Account.(*vless.MemoryAccount)
@@ -312,7 +310,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
clientReader := link.Reader // .(*pipe.Reader) clientReader := link.Reader // .(*pipe.Reader)
clientWriter := link.Writer // .(*pipe.Writer) clientWriter := link.Writer // .(*pipe.Writer)
trafficState := proxy.NewTrafficState(account.ID.Bytes()) 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.Command = protocol.RequestCommandMux
request.Address = net.DomainAddress("v1.mux.cool") request.Address = net.DomainAddress("v1.mux.cool")
request.Port = net.Port(666) request.Port = net.Port(666)
+1 -3
View File
@@ -31,7 +31,6 @@ import (
type Handler struct { type Handler struct {
server *protocol.ServerSpec server *protocol.ServerSpec
policyManager policy.Manager policyManager policy.Manager
cone bool
} }
// New creates a new VMess outbound handler. // New creates a new VMess outbound handler.
@@ -48,7 +47,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
handler := &Handler{ handler := &Handler{
server: server, server: server,
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
cone: ctx.Value("cone").(bool),
} }
return handler, nil return handler, nil
@@ -148,7 +146,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
} }
}, sessionPolicy.Timeouts.ConnectionIdle) }, 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.Command = protocol.RequestCommandMux
request.Address = net.DomainAddress("v1.mux.cool") request.Address = net.DomainAddress("v1.mux.cool")
request.Port = net.Port(666) request.Port = net.Port(666)