Skip to content

Comments

Easier Configuration: add 3 alias, add default tag for inbounds and outbounds#4967

Closed
patterniha wants to merge 2 commits intoXTLS:mainfrom
patterniha:alias
Closed

Easier Configuration: add 3 alias, add default tag for inbounds and outbounds#4967
patterniha wants to merge 2 commits intoXTLS:mainfrom
patterniha:alias

Conversation

@patterniha
Copy link
Collaborator

add alias:

tunnel for dokodemo-door
direct for freedom
block for blackhole

add default inbounds and outbounds tag:

outbounds:

	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()
		}
	}

inbounds:

	if c.Tag == "" {
		id := uuid.New()
		c.Tag = "xray.inbound." + id.String()
	}

@patterniha patterniha changed the title Easier Config: add 3 alias, add default tag for inbounds and outbounds Easier Configuration: add 3 alias, add default tag for inbounds and outbounds Aug 1, 2025
@Fangliding
Copy link
Member

我还是那句话 太多别名只会让交流更不方便(一个人说dokodemo-door一个人说tunnel)同时代码更难读(外面一个名字里面一个名字)
还有默认tag更没必要了 还有你就没想过几个出站会冲突吗

@RPRX
Copy link
Member

RPRX commented Aug 1, 2025

前两个别名我写了还没 commit,黑洞的别名 block 我顺便加上吧,默认 tag 没必要

@RPRX RPRX closed this Aug 1, 2025
@patterniha
Copy link
Collaborator Author

patterniha commented Aug 1, 2025

default tag is applied when c.Tag == "", so when a user has multiple-outbounds, they outbounds-tag is not "".

So it doesn't matter if both tags are "" or "proxy".

@RPRX
Copy link
Member

RPRX commented Aug 1, 2025

总之这种隐式 tag 还是不要加比较好,配置文件看起来不直观了,@Fangliding 之前想加默认 freedom 出站也被我 close 了

@RPRX
Copy link
Member

RPRX commented Aug 1, 2025

VR 起的这几个原名挺浪漫的,就是不太直观,理性的名也应当有,这些别名刚加进来是别名,有朝一日让它们把原名给夺舍掉

@RPRX
Copy link
Member

RPRX commented Aug 1, 2025

总之加这些别名能使配置文件读起来更直观,但加隐式 tag 或默认 freedom 出站会使配置文件读起来一头雾水

@patterniha
Copy link
Collaborator Author

@RPRX

but now users should set:

"protocol": "direct",
"tag": "direct"

but it is redundant and not elegant.

anyway, it is not important and depending on opinion.

@RPRX
Copy link
Member

RPRX commented Aug 1, 2025

默认 tag 加了,用户得重新读文档才能知道,并且路由、balancer 等有 tag 前缀匹配什么的,可能会给用户造成意想不到的麻烦

RPRX added a commit that referenced this pull request Aug 1, 2025
@patterniha patterniha deleted the alias branch August 1, 2025 12:14
maoxikun pushed a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
…TLS#4968)

dokodemo-door -> tunnel
freedom -> direct
blackhole -> block

XTLS#4966 (comment)
XTLS#4967 (comment)
(cherry picked from commit 116cd70)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants