mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Техническая возможность использования своей JVM
This commit is contained in:
parent
8d7db40909
commit
ecb904035a
7 changed files with 48 additions and 3 deletions
|
@ -99,6 +99,8 @@ public static final class Config extends ConfigObject {
|
|||
public final String whitelistRejectString;
|
||||
|
||||
public final boolean genMappings;
|
||||
public final boolean isUsingWrapper;
|
||||
public final boolean isDownloadJava;
|
||||
|
||||
public ListConfigEntry mirrors;
|
||||
public final String binaryName;
|
||||
|
@ -142,6 +144,9 @@ private Config(BlockConfigEntry block, Path coredir,LaunchServer server) {
|
|||
binaryName = block.getEntryValue("binaryName", StringConfigEntry.class);
|
||||
projectName = block.hasEntry("projectName") ? block.getEntryValue("projectName", StringConfigEntry.class) : "Minecraft";
|
||||
compress = block.getEntryValue("compress", BooleanConfigEntry.class);
|
||||
|
||||
isUsingWrapper = block.getEntryValue("isUsingWrapper", BooleanConfigEntry.class);
|
||||
isDownloadJava = block.getEntryValue("isDownloadJava", BooleanConfigEntry.class);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,6 +88,16 @@ public void setClientPort(int port) {
|
|||
body.append(port);
|
||||
body.append(";");
|
||||
}
|
||||
public void setUsingWrapper(boolean b) {
|
||||
body.append("this.isUsingWrapper = ");
|
||||
body.append(b ? "true" : "false");
|
||||
body.append(";");
|
||||
}
|
||||
public void setDownloadJava(boolean b) {
|
||||
body.append("this.isDownloadJava = ");
|
||||
body.append(b ? "true" : "false");
|
||||
body.append(";");
|
||||
}
|
||||
|
||||
public ClassPool getPool() {
|
||||
return pool;
|
||||
|
|
|
@ -174,6 +174,8 @@ private void stdBuild() throws IOException {
|
|||
jaConfigurator.setProjectName(server.config.projectName);
|
||||
jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey());
|
||||
jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512));
|
||||
jaConfigurator.setUsingWrapper(server.config.isUsingWrapper);
|
||||
jaConfigurator.setDownloadJava(server.config.isDownloadJava);
|
||||
server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
|
||||
try (ZipInputStream input = new ZipInputStream(
|
||||
IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) {
|
||||
|
|
|
@ -7,6 +7,9 @@ authRateLimit: 2;
|
|||
authRateLimitMilis: 5000;
|
||||
authRejectString: "Вы превысили лимит авторизаций. Подождите некоторое время перед повторной попыткой";
|
||||
|
||||
isUsingWrapper: true;
|
||||
isDownloadJava: false;
|
||||
|
||||
# White list testers
|
||||
whitelistRejectString: "Вас нет в белом списке";
|
||||
|
||||
|
|
|
@ -162,7 +162,10 @@ public void write(HOutput output) throws IOException {
|
|||
private static final String SOCKET_HOST = "127.0.0.1";
|
||||
private static final int SOCKET_PORT = Launcher.getConfig().clientPort;
|
||||
private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump";
|
||||
private static final boolean isUsingWrapper = true;
|
||||
private static final boolean isUsingWrapper = Launcher.getConfig().isUsingWrapper;
|
||||
private static final boolean isDownloadJava = Launcher.getConfig().isDownloadJava;
|
||||
|
||||
private static Path JavaBinPath;
|
||||
@SuppressWarnings("unused")
|
||||
private static final Set<PosixFilePermission> BIN_POSIX_PERMISSIONS = Collections.unmodifiableSet(EnumSet.of(
|
||||
PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, // Owner
|
||||
|
@ -227,6 +230,10 @@ private static void addClientArgs(Collection<String> args, ClientProfile profile
|
|||
Collections.addAll(args, "--height", Integer.toString(params.height));
|
||||
}
|
||||
}
|
||||
@LauncherAPI
|
||||
public static void setJavaBinPath(Path javaBinPath) {
|
||||
JavaBinPath = javaBinPath;
|
||||
}
|
||||
|
||||
private static void addClientLegacyArgs(Collection<String> args, ClientProfile profile, Params params) {
|
||||
args.add(params.pp.username);
|
||||
|
@ -288,7 +295,6 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
|
|||
private static Process process = null;
|
||||
@LauncherAPI
|
||||
public static Process launch(
|
||||
|
||||
SignedObjectHolder<HashedDir> assetHDir, SignedObjectHolder<HashedDir> clientHDir,
|
||||
SignedObjectHolder<ClientProfile> profile, Params params, boolean pipeOutput) throws Throwable {
|
||||
// Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars)
|
||||
|
@ -331,9 +337,17 @@ public static Process launch(
|
|||
checkJVMBitsAndVersion();
|
||||
// Fill CLI arguments
|
||||
List<String> args = new LinkedList<>();
|
||||
boolean wrapper = isUsingWrapper() && Launcher.isUsingAvanguard();
|
||||
boolean wrapper = isUsingWrapper();
|
||||
Path javaBin;
|
||||
if (wrapper) javaBin = JVMHelper.JVM_BITS == 64 ? AvanguardStarter.wrap64 : AvanguardStarter.wrap32;
|
||||
else if(isDownloadJava)
|
||||
{
|
||||
//Linux и Mac не должны скачивать свою JVM
|
||||
if(JVMHelper.OS_TYPE == OS.MUSTDIE)
|
||||
javaBin = IOHelper.resolveJavaBin(JavaBinPath);
|
||||
else
|
||||
javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java");
|
||||
}
|
||||
else
|
||||
javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java");
|
||||
args.add(javaBin.toString());
|
||||
|
|
|
@ -6,6 +6,8 @@ public class AutogenConfig {
|
|||
public int port;
|
||||
public int clientPort;
|
||||
private boolean isInitModules;
|
||||
public boolean isUsingWrapper;
|
||||
public boolean isDownloadJava; //Выставление этого флага требует модификации runtime части
|
||||
public String secretKeyClient;
|
||||
|
||||
AutogenConfig() {
|
||||
|
|
|
@ -42,6 +42,9 @@ public static AutogenConfig getAutogenConfig() {
|
|||
@LauncherAPI
|
||||
public final Map<String, byte[]> runtime;
|
||||
|
||||
public final boolean isUsingWrapper;
|
||||
public final boolean isDownloadJava;
|
||||
|
||||
@LauncherAPI
|
||||
public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException {
|
||||
String localAddress = config.address;
|
||||
|
@ -51,6 +54,8 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
|
|||
projectname = config.projectname;
|
||||
clientPort = config.clientPort;
|
||||
secretKeyClient = config.secretKeyClient;
|
||||
isDownloadJava = config.isDownloadJava;
|
||||
isUsingWrapper = config.isUsingWrapper;
|
||||
// Read signed runtime
|
||||
int count = input.readLength(0);
|
||||
Map<String, byte[]> localResources = new HashMap<>(count);
|
||||
|
@ -75,6 +80,8 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
|
|||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||
this.projectname = projectname;
|
||||
this.clientPort = 32148;
|
||||
isUsingWrapper = true;
|
||||
isDownloadJava = false;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
|
@ -85,6 +92,8 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
|
|||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||
this.projectname = "Minecraft";
|
||||
this.clientPort = 32148;
|
||||
isUsingWrapper = true;
|
||||
isDownloadJava = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue