-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Config: Correctly marshal Address
to JSON
#4021
Conversation
? |
If we just "Marshal" current conf.Config, "address" will be like the below. "address": {
"Address": "example.com"
} or "address": {
"Address": [
127,
0,
0,
1
]
} They are not same with document. I think they will make client developers confused. |
and the |
"name" is used to store descriptive-text. Currently, there is no such field. If not, we must use other field to store it, like "sendThrough", this field will not be used in most cases when developing client. But I think it is better to append a new field "name". |
No need to add it, config file can be freely added invalid fields, the core will ignore them |
I see. The first change has been reverted. |
虽然 extra 的本意是直接复制 json 而不是 marshal,你是想把内存中的配置导出为 json 吗 话说 2d7b0e8 后 test 炸了,但刚刚没找到炸哪了,@Fangliding |
目前 libXray 的分享链接解析结果是基于自定义的 XrayJson 构建的。添加 extra 之后,原则上解析结果应该兼容 xhttpSettings 的所有字段。所以不如直接基于 Xray-core 的 conf.Config 来构建结果(已在 libXray 的 dev 分支实现)。 |
懂了,就是说你开发的那个 iOS APP 对 Xray-core 的使用并不像 v2rayN&G 一样是先写 json,而是直接把 core 当 lib 来调用 然后这个 PR 是为了正确地把内存中的配置导出为分享链接, 但你要注意行为导入导出 extra 时行为要和 core 保持一致 |
目前的实现,libXray 只负责将 extra 填充到对应的字段上(生成分享链接和解析分享链接均是如此),并不会修改 host,path,mode。具体的导入导出逻辑交给客户端去决定(当然,客户端也可以直接把这些字段都交给 core 来决定)。
|
填充到 xhttpSettings 还是 extra?如果是前者,行为就不一致了,具体看 #4000 |
填充到 extra,这次 commit 我完整看过了。 |
Address
to JSON
Because Mr. R has appended new "extra" field to sharing protocol, it's time to use the original config of Xray-core when parsing share links.
This commit contains two modifications.
Maybe we should make more changes in the future, but it is enough currently for VLESS sharing protocol.