diff --git a/infra/conf/xray.go b/infra/conf/xray.go index f1d9fb08030a..0b6b1195573f 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/xtls/xray-core/common/uuid" "log" "os" "path/filepath" @@ -22,6 +23,7 @@ import ( var ( inboundConfigLoader = NewJSONConfigLoader(ConfigCreatorCache{ "dokodemo-door": func() interface{} { return new(DokodemoConfig) }, + "tunnel": func() interface{} { return new(DokodemoConfig) }, "http": func() interface{} { return new(HTTPServerConfig) }, "shadowsocks": func() interface{} { return new(ShadowsocksServerConfig) }, "mixed": func() interface{} { return new(SocksServerConfig) }, @@ -34,8 +36,10 @@ var ( outboundConfigLoader = NewJSONConfigLoader(ConfigCreatorCache{ "blackhole": func() interface{} { return new(BlackholeConfig) }, + "block": func() interface{} { return new(BlackholeConfig) }, "loopback": func() interface{} { return new(LoopbackConfig) }, "freedom": func() interface{} { return new(FreedomConfig) }, + "direct": func() interface{} { return new(FreedomConfig) }, "http": func() interface{} { return new(HTTPClientConfig) }, "shadowsocks": func() interface{} { return new(ShadowsocksClientConfig) }, "socks": func() interface{} { return new(SocksClientConfig) }, @@ -249,6 +253,11 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) { return nil, errors.New("failed to build inbound handler for protocol ", c.Protocol).Base(err) } + if c.Tag == "" { + id := uuid.New() + c.Tag = "xray.inbound." + id.String() + } + return &core.InboundHandlerConfig{ Tag: c.Tag, ReceiverSettings: serial.ToTypedMessage(receiverSettings), @@ -348,6 +357,21 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { return nil, errors.New("failed to build outbound handler for protocol ", c.Protocol).Base(err) } + if c.Tag == "" { + switch strings.ToLower(c.Protocol) { + case "vless", "vmess", "trojan", "shadowsocks", "wireguard": + c.Tag = "proxy" + case "freedom", "direct": + c.Tag = "direct" + case "blackhole", "block": + c.Tag = "block" + case "dns": + c.Tag = "dns-out" + default: + id := uuid.New() + c.Tag = "xray.outbound." + id.String() + } + } return &core.OutboundHandlerConfig{ SenderSettings: serial.ToTypedMessage(senderSettings), Tag: c.Tag,