Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands: Add convert with two sub-commands #3661

Merged
merged 3 commits into from
Aug 10, 2024
Merged

Conversation

vrnobody
Copy link
Contributor

@vrnobody vrnobody commented Aug 8, 2024

这个 PR 添加两个 convert 子命令

第一个,把 configs 转成 protobuf:

$ ./xray.exe help convert pb
usage: xray convert pb [json file] [json file] ...

Convert multiple json configs to protobuf.

Examples:

    xray convert pb config.json c1.json c2.json c3.json > mix.pb

第二个,把 typedMessage 解成 json:

$ ./xray.exe help convert json
usage: xray convert json [-type] [stdin:] [typedMessage file]

Convert ONE typedMessage to json.

Where typedMessage file need to be in the following format:

{
  "type": "xray.proxy.shadowsocks.Account",
  "value": "CgMxMTEQBg=="
}

Arguments:

        -t, -type
                Inject type infomation.

Examples:

    xray convert json user.tmsg

其中第二个的效果:

$ echo '{"type": "xray.proxy.shadowsocks.Account", "value": "CgMxMTEQBg=="}' | ./xray.exe convert json stdin:
{
  "cipherType": "AES_256_GCM",
  "password": "111"
}

@RPRX
Copy link
Member

RPRX commented Aug 9, 2024

应用场景是?

@Fangliding
Copy link
Member

应用场景是?

处理API的一些输出

@vrnobody
Copy link
Contributor Author

vrnobody commented Aug 9, 2024

应用场景是?

第一条 pb 子命令是看到 cmd 原来就有这些代码,顺带改了下。以前是有些低内存的路由器,在启动时如果有 routing 配置会因为解释 routing 引起内存不足,导致启动失败。现在不知道还有没有这个需要。

第二条 json 子命令和 #3644 有关。可以解开 grpcurl 里面的 TypedMessage。以后的 API 也许 可以直接传个 TypedMessage。

@RPRX RPRX changed the title Add back convert-command. Commands: Add convert with two sub-commands Aug 10, 2024
@RPRX RPRX requested a review from yuhan6665 August 10, 2024 06:41
@yuhan6665 yuhan6665 merged commit f650d87 into XTLS:main Aug 10, 2024
36 checks passed
@yuhan6665
Copy link
Member

感谢!

@vrnobody vrnobody deleted the convert branch August 11, 2024 03:14
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