Skip to content

Conversation

patterniha
Copy link
Collaborator

@patterniha patterniha commented Mar 23, 2025

Wrongly, the source of relative path for certificate files is "command-run" folder: #4531

also, it is not elegant that we put all certificate files in exec folder, so we need environment-variable for certificate files.

therefore, gui/panel can create a folder for certificate files and set certificate-environment-variable to that folder.

also, v2rayNG only has one folder for asset files, so in v2rayNG we can set
geo-environment-variable=certificate-environment-variable and then we can also add certificate files.

///

logic:

if cert/key path is absolute path:
    read from that path
else:
    if we have certificate-environment-variable:
        read from certificate-environment-variable folder
    else:
        read from exec folder

@patterniha patterniha changed the title Add "certificate" environment variable Add "certificate location" environment variable Mar 23, 2025
@RPRX RPRX requested a review from yuhan6665 March 24, 2025 09:53
@RPRX
Copy link
Member

RPRX commented Mar 24, 2025

@patterniha

@patterniha
Copy link
Collaborator Author

patterniha commented Mar 24, 2025

@RPRX

done.

@RPRX
Copy link
Member

RPRX commented Mar 24, 2025

@patterniha

@patterniha
Copy link
Collaborator Author

patterniha commented Mar 24, 2025

@RPRX

done, all you had to do was say rename all "certificate" to "cert" :)

@RPRX RPRX changed the title Add "certificate location" environment variable Env: Add XRAY_LOCATION_CERT variable Mar 24, 2025
@RPRX RPRX merged commit 4acb840 into XTLS:main Mar 24, 2025
35 checks passed
RPRX added a commit that referenced this pull request Mar 24, 2025
#4531 (comment)

Fixes #4531

---------

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
@RPRX
Copy link
Member

RPRX commented Mar 24, 2025

GitHub 自动生成的 release notes 只包括 PR,并不包括直接的 commit,也不包括 2d3210e 这种 force-push,每次都要花些时间手动补,感觉很烦,谁来写个爬虫用正则匹配一下 commits history

@Fangliding
Copy link
Member

直接改readdfile方法去exec folder读一遍没有再fallback去asset目录(默认二进制位置)读一遍就行了 以后类似的东西直接调这个方法还能复用 这还单独搓个出来

@patterniha
Copy link
Collaborator Author

Just change the readdfile method to read it once in the exec folder without fallback to the asset directory (default binary location) and read it once. In the future, similar things can be reused by calling this method directly. This is not a separate one.

we can add "readFileFromExec" function:

func readFileFromExec(file string) ([]byte, error) {
	if filepath.IsAbs(file) {
		return ReadFile(file)
	}
	return ReadFile(filepath.Join(getExecutableDir(), file))
}

But it is not useful for our needs, because we should first check if the file-path is absolute then check the environment-variable and then check the exec folder.

Or maybe I didn't understand what you meant, anyway, you can make any changes you want.

@RPRX
Copy link
Member

RPRX commented Mar 25, 2025

我主要是觉得加个 XRAY_LOCATION_CERT 是可以有的,毕竟 XRAY_LOCATION_ASSET 都有

反正我加这些东西都是从 为了全人类 以及完善 Xray 基础功能的角度切入

@RPRX
Copy link
Member

RPRX commented Mar 25, 2025

比如以后可能再加个 XRAY_LOCATION_LOG(带上 masterKeyLog?),然后它们的共用逻辑可以抽出来、代码复用

好像暂时没其它涉及到 file 的配置项了

话说 masterKeyLog 这东西支持 uTLS 应该没难度吧?文档写的不支持,我升级 REALITY 时顺便看一下

@yuhan6665
Copy link
Member

#2911

@RPRX
Copy link
Member

RPRX commented Mar 31, 2025

#2911

@Fangliding 文档需要更正 masterKeyLog,以及 expectIPs 更名 expectedIPs,以及新增 XRAY_LOCATION_CERT

maoxikun added a commit to maoxikun/Xray-core that referenced this pull request Aug 22, 2025
maoxikun pushed a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
XTLS#4531 (comment)

Fixes XTLS#4531

---------

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
(cherry picked from commit 2d3210e)
maoxikun added a commit to maoxikun/Xray-core that referenced this pull request Aug 23, 2025
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