Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题概述
若在 MC 客户端使用
--proxyHost
、--proxyPort
参数指定 SOCKS 代理,则 authlib 访问环回地址时不会绕过代理,进而导致 authlib-injector 不可用。故障表现为,进服时报错 Failed to log in: The authentication servers are currently down for maintenance.,客户端日志报错 java.net.SocketException: Unexpected end of file from server。在原版 MC 中,
--proxyHost
、--proxyPort
、--proxyUser
和--proxyPass
这几个参数用于设置访问 Mojang 验证服务所使用的代理,其仅在 authlib 中使用(具体来说,代理设置会被传入 YggdrasilAuthenticationService),不用于其他网络请求,亦不用于多人联机。由于这个代理设置是直接传入 URL.openConnection(Proxy) 方法的,因此不会绕行环回地址。据目前所知,会设置这一参数的启动器仅有 HMCL。如果用户在 HMCL 中开启了 SOCKS 代理,那么 HMCL 就会向游戏添加
--proxyHost
和--proxyPort
参数。如果用户同时使用 authlib-injector,就会出现上述故障。修复方案
如果启动参数包含
--proxyHost
、--proxyPort
、--proxyUser
或--proxyPass
,则将其移除,并打印警告,告知用户 authlib-injector 不兼容--proxyHost
等参数。以下是我选择这一方案的原因:
由于
--proxyHost
等参数设置的代理仅供 authlib 使用,可以推测其在原版 MC 中的使用场景为:通过代理解决连接 Mojang 验证服务不稳定的问题。而在使用 authlib-injector 时,我们连接的是第三方验证服务,而不是 Mojang 验证服务,因此我们大概率不会有这个需求。