mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] GuardLicense 2
This commit is contained in:
parent
d7a2d0733f
commit
2c8f3d4f5b
3 changed files with 32 additions and 4 deletions
|
@ -28,6 +28,7 @@
|
|||
dependencies {
|
||||
pack project(':LauncherAPI') // Not error on obf.
|
||||
bundle 'com.github.oshi:oshi-core:3.11.0'
|
||||
bundle 'commons-codec:commons-codec:1.11'
|
||||
}
|
||||
|
||||
task genRuntimeJS(type: Zip) {
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package ru.gravit.launcher.guard;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launcher.LauncherConfig;
|
||||
import ru.gravit.launcher.client.ClientLauncherContext;
|
||||
import ru.gravit.launcher.client.DirBridge;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.JVMHelper;
|
||||
import ru.gravit.utils.helper.UnpackHelper;
|
||||
import ru.gravit.utils.helper.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class LauncherWrapperGuard implements LauncherGuardInterface {
|
||||
@Override
|
||||
|
@ -52,6 +53,19 @@ public void addCustomParams(ClientLauncherContext context) {
|
|||
|
||||
@Override
|
||||
public void addCustomEnv(ClientLauncherContext context) {
|
||||
context.builder.environment().put("JAVA_HOME", System.getProperty("java.home"));
|
||||
Map<String,String> env = context.builder.environment();
|
||||
env.put("JAVA_HOME", System.getProperty("java.home"));
|
||||
LauncherConfig config = Launcher.getConfig();
|
||||
if(config.guardLicenseName != null)
|
||||
env.put("GUARD_LICENSE_NAME", config.guardLicenseName);
|
||||
if(config.guardLicenseKey != null && config.guardLicenseEncryptKey != null)
|
||||
{
|
||||
try {
|
||||
byte[] encrypt = SecurityHelper.encrypt(config.guardLicenseEncryptKey,config.guardLicenseKey);
|
||||
env.put("GUARD_LICENSE_NAME", Base64.getEncoder().encodeToString(encrypt));
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ public static AutogenConfig getAutogenConfig() {
|
|||
public final boolean isDownloadJava;
|
||||
public final boolean isWarningMissArchJava;
|
||||
|
||||
public final String guardLicenseName;
|
||||
public final String guardLicenseKey;
|
||||
public final String guardLicenseEncryptKey;
|
||||
|
||||
@LauncherAPI
|
||||
public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException {
|
||||
String localAddress = config.address;
|
||||
|
@ -55,6 +59,9 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
|
|||
isDownloadJava = config.isDownloadJava;
|
||||
isUsingWrapper = config.isUsingWrapper;
|
||||
isWarningMissArchJava = config.isWarningMissArchJava;
|
||||
guardLicenseEncryptKey = config.guardLicenseEncryptKey;
|
||||
guardLicenseKey = config.guardLicenseKey;
|
||||
guardLicenseName = config.guardLicenseName;
|
||||
nettyPort = config.nettyPort;
|
||||
LauncherEnvironment env;
|
||||
if (config.env == 0) env = LauncherEnvironment.DEV;
|
||||
|
@ -86,6 +93,9 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
|
|||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||
this.projectname = projectname;
|
||||
this.clientPort = 32148;
|
||||
this.guardLicenseName = "FREE";
|
||||
this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD";
|
||||
this.guardLicenseEncryptKey = "12345";
|
||||
isUsingWrapper = true;
|
||||
isDownloadJava = false;
|
||||
isWarningMissArchJava = true;
|
||||
|
@ -97,6 +107,9 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
|
|||
this.publicKey = Objects.requireNonNull(publicKey, "publicKey");
|
||||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||
this.projectname = "Minecraft";
|
||||
this.guardLicenseName = "FREE";
|
||||
this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD";
|
||||
this.guardLicenseEncryptKey = "12345";
|
||||
this.clientPort = 32148;
|
||||
isUsingWrapper = true;
|
||||
isDownloadJava = false;
|
||||
|
|
Loading…
Reference in a new issue