[FEATURE] Указание guardType

This commit is contained in:
Gravit 2019-04-12 05:15:05 +07:00
parent 3c0de3727d
commit 0201c8d474
7 changed files with 37 additions and 46 deletions

View file

@ -131,20 +131,16 @@ public AuthProviderPair getAuthProviderPair() {
public NettyConfig netty;
public GuardLicenseConf guardLicense;
public boolean compress;
public String whitelistRejectString;
public boolean genMappings;
public boolean isUsingWrapper;
public boolean isDownloadJava;
public LauncherConf launcher;
public boolean isWarningMissArchJava;
public boolean enabledProGuard;
public boolean enabledRadon;
public boolean stripLineNumbers;
public boolean deleteTempFiles;
public boolean enableRcon;
public String startScript;
@ -242,6 +238,11 @@ public static class ExeConf {
public String txtProductVersion;
}
public class LauncherConf
{
public String guardType;
}
public class NettyConfig {
public boolean clientEnabled;
public String launcherURL;

View file

@ -83,6 +83,12 @@ public void setSecretKey(String key) {
body.append("\";");
}
public void setGuardType(String key) {
body.append("this.guardType = \"");
body.append(key);
body.append("\";");
}
public void setEnv(LauncherConfig.LauncherEnvironment env) {
int i = 2;
switch (env) {
@ -111,18 +117,6 @@ public void setClientPort(int 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 void setWarningMissArchJava(boolean b) {
body.append("this.isWarningMissArchJava = ");
body.append(b ? "true" : "false");

View file

@ -134,9 +134,8 @@ public Path process(Path inputJar) throws IOException {
jaConfigurator.setProjectName(server.config.projectName);
jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey());
jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512));
jaConfigurator.setUsingWrapper(server.config.isUsingWrapper);
jaConfigurator.setGuardType(server.config.launcher.guardType);
jaConfigurator.setWarningMissArchJava(server.config.isWarningMissArchJava);
jaConfigurator.setDownloadJava(server.config.isDownloadJava);
jaConfigurator.setEnv(server.config.env);
server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
reader.getCp().add(new JarFile(inputJar.toFile()));

View file

@ -139,8 +139,6 @@ 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 = Launcher.getConfig().isUsingWrapper;
private static final boolean isDownloadJava = Launcher.getConfig().isDownloadJava;
private static Path JavaBinPath;
@SuppressWarnings("unused")
@ -165,10 +163,6 @@ public static class ClientUserProperties {
String[] cloakDigest;
}
public static boolean isDownloadJava() {
return isDownloadJava;
}
public static Path getJavaBinPath() {
return JavaBinPath;
}
@ -265,11 +259,6 @@ public static boolean isLaunched() {
return Launcher.LAUNCHED.get();
}
public static boolean isUsingWrapper() {
return JVMHelper.OS_TYPE == OS.MUSTDIE && isUsingWrapper;
}
private static void launch(ClientProfile profile, Params params) throws Throwable {
// Add client args
Collection<String> args = new LinkedList<>();

View file

@ -1,5 +1,7 @@
package ru.gravit.launcher.guard;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.client.ClientLauncher;
import java.nio.file.Path;
@ -8,11 +10,22 @@ public class LauncherGuardManager {
public static LauncherGuardInterface guard;
public static void initGuard(boolean clientInstance) {
if (ClientLauncher.isUsingWrapper()) {
guard = new LauncherWrapperGuard();
} else if (ClientLauncher.isDownloadJava()) {
guard = new LauncherJavaGuard();
} else guard = new LauncherNoGuard();
LauncherConfig config = Launcher.getConfig();
switch (config.guardType)
{
case "wrapper":
{
guard = new LauncherWrapperGuard();
}
case "java":
{
guard = new LauncherJavaGuard();
}
default:
{
guard = new LauncherNoGuard();
}
}
guard.init(clientInstance);
}

View file

@ -6,8 +6,7 @@ public class AutogenConfig {
public int clientPort;
@SuppressWarnings("unused")
private boolean isInitModules;
public boolean isUsingWrapper;
public boolean isDownloadJava; //Выставление этого флага требует модификации runtime части
public String guardType;
public String secretKeyClient;
public String guardLicenseName;
public String guardLicenseKey;

View file

@ -30,15 +30,13 @@ public static AutogenConfig getAutogenConfig() {
@LauncherAPI
public final Map<String, byte[]> runtime;
public final boolean isUsingWrapper;
public final boolean isDownloadJava;
public final boolean isWarningMissArchJava;
public boolean isNettyEnabled;
public final String guardLicenseName;
public final String guardLicenseKey;
public final String guardLicenseEncryptKey;
public final String guardType;
@LauncherAPI
public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException {
@ -46,11 +44,11 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
projectname = config.projectname;
clientPort = config.clientPort;
secretKeyClient = config.secretKeyClient;
isDownloadJava = config.isDownloadJava;
isUsingWrapper = config.isUsingWrapper;
isWarningMissArchJava = config.isWarningMissArchJava;
guardLicenseEncryptKey = config.guardLicenseEncryptKey;
guardLicenseKey = config.guardLicenseKey;
guardType = config.guardType;
guardLicenseName = config.guardLicenseName;
address = config.address;
LauncherEnvironment env;
@ -82,8 +80,7 @@ public LauncherConfig(String address, RSAPublicKey publicKey, Map<String, byte[]
this.guardLicenseName = "FREE";
this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD";
this.guardLicenseEncryptKey = "12345";
isUsingWrapper = true;
isDownloadJava = false;
guardType = "no";
isWarningMissArchJava = true;
isNettyEnabled = false;
}
@ -98,8 +95,7 @@ public LauncherConfig(String address, RSAPublicKey publicKey, Map<String, byte[]
this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD";
this.guardLicenseEncryptKey = "12345";
this.clientPort = 32148;
isUsingWrapper = true;
isDownloadJava = false;
guardType = "no";
isWarningMissArchJava = true;
isNettyEnabled = false;
}