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

[proposal] 使用临时文件传递预获取的元数据 #136

Open
yushijinhun opened this issue Sep 10, 2021 · 1 comment
Open

[proposal] 使用临时文件传递预获取的元数据 #136

yushijinhun opened this issue Sep 10, 2021 · 1 comment

Comments

@yushijinhun
Copy link
Owner

本提案的主要内容:

  • 要求启动器在启动前将 API 元数据存入临时文件中,然后使用 -Dauthlibinjector.prefetch.file= 参数实现元数据预获取。
  • 弃用原先的 -Dauthlibinjector.yggdrasil.prefetched= 参数。

背景

authlib-injector 要求启动器在启动游戏前,从验证服务器获取元数据,并将其 Base64 编码后作为参数传递给 authlib-injector。这一措施可以加快启动速度,同时避免网络不稳定造成的启动失败。

但由于 Base64 编码后的元数据长度很长,可能超出一些平台对命令行长度的限制,进而造成启动失败。例如,auth-demo.yushi.moe 的元数据经过编码后就达到了 1428 个字符,而 Windows 上命令行长度限制从 2048 到 32768 个字符不等(取决于进程创建方式),再加上其他参数就有可能超出限制。

改动

启动器启动游戏前的「配置预获取」流程改为如下:

  1. 创建一个临时文件,将 API 元数据以 UTF-8 编码写入该文件中。
  2. 启动游戏时添加 JVM 参数 -Dauthlibinjector.prefetch.file={临时文件路径}

示例

以验证服务器 auth-demo.yushi.moe 为例,元数据预获取的实现如下:

  1. https://auth-demo.yushi.moe/ 发送 GET 请求,获取 API 元数据(亦可使用缓存的数据):
    {"skinDomains":[".yushi.moe",".prinzeugen.net",...
    
  2. 创建一个临时文件,如 /tmp/tmp.uwwCKnbW1n.json,将上面的元数据以 UTF-8 编码写入此文件。
  3. 启动时添加 JVM 参数 -Dauthlibinjector.prefetch.file=/tmp/tmp.uwwCKnbW1n.json

兼容性

authlib-injector 将继续接受旧的 -Dauthlibinjector.yggdrasil.prefetched= 参数,但会在控制台打印警告。

待讨论事项

  • 临时文件是否需要清理?是否需要添加一个选项,让 authlib-injector 在读取完文件内容后删除临时文件?

/cc @huanghongxun @ZhaiSoul @TT702 @Nsiso @LTCatt

@JustOneSummer
Copy link

临时文件就行了,下次启动覆盖写不需要删除

yushijinhun added a commit that referenced this issue Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants