Skip to content

Commit

Permalink
Use either authlib-injector or system properties, not both
Browse files Browse the repository at this point in the history
Resolves #154

In 1.20+, authlib-injector wants to intercept
https://api.minecraftservices.com/publickeys [0], but if we override the
services server using -Dminecraft.api.services.host, the request does
not get intercepted.

That's not an issue for API servers that implement the /publickeys
route, but Ely.by does not. A decent solution is to not set these
-Dminecraft.api.*.host system properties when authlib-injector is
available, since authlib-injector expects authlib to make requests to
Mojang's API servers.

[0] yushijinhun/authlib-injector@18a0ce2
  • Loading branch information
evan-goode committed Mar 18, 2024
1 parent 99cb414 commit 8f254cb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions launcher/minecraft/MinecraftInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,7 @@ QStringList MinecraftInstance::processAuthArgs(AuthSessionPtr session) const
{
QStringList args;
if (session->uses_custom_api_servers) {
args << "-Dminecraft.api.env=custom";
args << "-Dminecraft.api.auth.host=" + session->auth_server_url;
args << "-Dminecraft.api.account.host=" + session->account_server_url;
args << "-Dminecraft.api.session.host=" + session->session_server_url;
args << "-Dminecraft.api.services.host=" + session->services_server_url;
bool using_authlib_injector = false;
auto agents = m_components->getProfile()->getAgents();
for (auto agent : agents) {
if (agent->library()->artifactPrefix() == "moe.yushi:authlibinjector") {
Expand All @@ -562,9 +558,18 @@ QStringList MinecraftInstance::processAuthArgs(AuthSessionPtr session) const
if (session->authlib_injector_metadata != "") {
args << "-Dauthlibinjector.yggdrasil.prefetched=" + session->authlib_injector_metadata;
}
using_authlib_injector = true;
break;
}
}
if (!using_authlib_injector) {
qDebug() << "authlib-injector not found, setting -Dminecraft.api.*.host system properties.";
args << "-Dminecraft.api.env=custom";
args << "-Dminecraft.api.auth.host=" + session->auth_server_url;
args << "-Dminecraft.api.account.host=" + session->account_server_url;
args << "-Dminecraft.api.session.host=" + session->session_server_url;
args << "-Dminecraft.api.services.host=" + session->services_server_url;
}
}
return args;
}
Expand Down

0 comments on commit 8f254cb

Please sign in to comment.