Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions infra/conf/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/xtls/xray-core/common/uuid"
"log"
"os"
"path/filepath"
Expand All @@ -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) },
Expand All @@ -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) },
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
Loading