Repository navigation
Config: Support env XRAY_JSON_STRICT=true - #6053
Conversation
|
为啥假设其他人用的远程config就是没注释的 就你家用这个功能其他人不活了? |
Standard JSON serializers (json.Marshal, JSON.stringify, etc.) physically can't emit comments |
|
答非所问 为什么假设所有使用远程下发的人没有和文件一样的注释需求 |
|
How can they use comments if the code doesn't allow them to add them? Again, there's the JSON standard. Many frameworks return response bodies in JSON. They won't allow any comments to be added to it, as that would violate the standard. |
|
这又不是web标准 只是获取一个文件而已 这种情况非常简单 一个人有许多服务器 在一台中心服务器上存放config并配置一个nginx访问 不允许他在这种情况给配置文件写注释? |
|
这个。。。严格来说 Xray-core 所支持的 JSON 本来就不是标准 JSON4,而是允许写注释, 如果是 performance 问题的话需要说明对性能会有多严重的影响,比如内存占用多几百兆,还是启动时间多几十秒(虽然我觉得对于承载 millions of users 的服务器也不差这几百兆,且又不是总是在重启) 如果你们确实需要这项改动,可以加个启动参数,比如 --strict |
|
改成一个环境变量 xray.json.strict 这个为1就跳过自定义解析器就行了 只是看着为了烂机场应用就改默认行为很不爽 |
Sure |
xray.json.strict
|
|
|
环境变量是用 platform.NewEnvFlag 那套东西的 不是直接读 |
|
|
|
xray的flag是要自己解析的 这种事都是环境变量弄 |
sorry, fixed |
|
|
|
因为 ./xray |
|
|
|
参考其它环境变量,改为了 |
xray.json.strictXRAY_JSON_STRICT=true
你为什么讨厌机场? 机场恰恰能暴露xray的很多问题, 很多不起眼的开销会被放大很多, 促使它的改进. 而且他做的还是个开关... |
XTLS/Xray-core#6053 (comment) --------- Co-authored-by: RPRX <[email protected]>
The custom JSON reader strips comments and other non-standard JSON5/JSONC syntax to make local configs human-friendly. On large configs (millions of users) it adds substantial overhead — both from byte-by-byte FSM and from io.TeeReader buffering the entire input.
Enable by env variable:
xray.json.strict=1