Skip to content

Lua: Support inline scripts; Add ./xray base64 encode/decode [-gzip] command - #7132

Merged
RPRX merged 10 commits into
mainfrom
lua-chore
Oct 12, 2026
Merged

RPRX merged 10 commits into
mainfrom
lua-chore

Conversation

@Meo597

@Meo597 Meo597 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

@RPRX

RPRX commented Oct 12, 2026

Copy link
Copy Markdown
Member

如果只是 base64 的话不如先加个正经的 ./xray base64 encode/decode command

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

那就 ./xray base64 [encode|decode] [-gzip]?

@RPRX

RPRX commented Oct 12, 2026

Copy link
Copy Markdown
Member

差不多吧不过我不确定支持可选的 gzip 是否有必要

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

根据测试 #7124 (comment)
几百字节就有收益,随便写写就超了

cli 不比 gui
此命令主要还是为 gzip 服务

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author
# usage: xray base64 encode [-gzip] <input-file | - | stdin:>

$ echo hello world|./xray base64 encode -gzip -
base64+gzip:H4sIAAAAAAAC/8pIzcnJVyjPL8pJ4QIMAC07CK8MAAAA


# usage: xray base64 decode [-gzip] <value | - | stdin:> [output-file]

$ ./xray base64 decode base64+gzip:H4sIAAAAAAAC/8pIzcnJVyjPL8pJ4QIMAC07CK8MAAAA
hello world

非常灵活

@RPRX

RPRX commented Oct 12, 2026

Copy link
Copy Markdown
Member

那换成压缩率更高的方式比如 zstd 吧,可以引入依赖(盲猜已经 indirect 了)

解压缩就一次所以即使慢一些也可以接受,虽然 zstd 宣称反而更快,总之无所谓

@Fangliding

Copy link
Copy Markdown
Member

我之前说gzip的原因是标准库在用 zstd 看了下也因为 utls 的缘故间接依赖了 不过还是得对比一下这两个的实际占用
还有一般写法多是 xxxbase64 或者 "xxx": "base64://"

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

原理上 zstd 肯定完爆毕竟字典窗口更大
放到 lua 脚本收益不会特别明显,毕竟体积放在那了
zstd 既然已经白给了,不用白不用

:// 隐含外部资源的感觉
标准的写法是 data:application/zstd;base64,xxxxxx

zstd,base64;xxxxxx
zstd;base64:xxxxxx

你们挑个顺眼的,我都一样

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author
源码 原始 gzip 9 zstd 最高档
common/base64/encode.go 711 416 422
common/lua/program.go 2,440 1,008 1,033
app/router/router.go 7,072 2,137 2,192
proxy/freedom/freedom.go 23,281 6,542 6,544
infra/conf/transport_method.go 28,982 7,125 7,075
合计 62,486 17,228 17,266

@RPRX

RPRX commented Oct 12, 2026

Copy link
Copy Markdown
Member

和 gzip9 区别不大的话那似乎。。。

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

我看看编译出来的二进制差多少

@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

xray-linux-64-gzip 39,481,468
xray-linux-64-zstd 39,694,460

This reverts commit 0ca1aa3.
@RPRX RPRX changed the title Lua: Support inline scripts and lua encode command Lua: Support inline scripts; Add ./xray base64 encode/decode [-gzip] command Oct 12, 2026
@RPRX
RPRX merged commit 5a64db0 into main Oct 12, 2026
@Meo597
Meo597 deleted the lua-chore branch October 12, 2026 16:59
@Meo597

Meo597 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

带着 lua 脚本到处跑,是自己的还好
要是订阅能下发,或者能包到分享链接
那破坏力...才真的要上 hackernews 了

Medium1992 pushed a commit to Medium1992/Xray-core-fork that referenced this pull request Oct 13, 2026
Upstream since v26.10.10: TUN inbound on Xray's own TCP/IP stack
instead of gVisor (XTLS#7130) and autoSystemDnsToGateway on FreeBSD (XTLS#7123),
Hysteria dial cancellation (XTLS#7119) and cleaner lock release (XTLS#7122),
golang.org/x/net 0.60.0 (XTLS#7133), inline Lua scripts and the base64
command (XTLS#7132), MASQUE client XMUX and Chrome's User-Agent (XTLS#7121).

Conflicts, resolved as follows:
- app/proxyman/inbound/inbound.go: XHTTP inbounds keep accepting
  Mux.Cool TCP sessions (docs/FORK.md); the XUDP-only rule now applies to
  MASQUE alone, as upstream added it there.
- app/router/router.go: upstream's compile-at-Init script engine, with the
  fork's PickRouteTag fields and needsSniffingAttributes reset kept.
- proxy/masque/client.go: upstream's onClose tunnel callback together with
  the fork's bounded ICMP queue; startTunnel takes the callback.
- transport/internet/hysteria/dialer.go: the fork's versions of XTLS#7119 and
  XTLS#7122 stay (docs/FORK.md), including closing the connection before the
  response body on a rejected authentication.
- go.mod, go.sum: the fork's newer x/net 0.61.0, crypto, sync, sys, text,
  tools.

NewXmuxManager keeps the fork's *XmuxConfig parameter; upstream's new
MASQUE and XMUX call sites pass a pointer.
@j2rong4cn

Copy link
Copy Markdown
Contributor

文档还是router:PickOutbound 😅
image

@Meo597

Meo597 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

本来早该改的,杂活干多了就 delay 了。。。

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.

4 participants