mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] LaunchServerLauncherExeInit
This commit is contained in:
parent
24d625fd16
commit
bddf31c94e
7 changed files with 33 additions and 23 deletions
|
@ -95,8 +95,6 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab
|
||||||
* Pipeline for building EXE
|
* Pipeline for building EXE
|
||||||
*/
|
*/
|
||||||
public final LauncherBinary launcherEXEBinary;
|
public final LauncherBinary launcherEXEBinary;
|
||||||
//public static LaunchServer server = null;
|
|
||||||
public final Class<? extends LauncherBinary> launcherEXEBinaryClass;
|
|
||||||
// Server config
|
// Server config
|
||||||
public final AuthHookManager authHookManager;
|
public final AuthHookManager authHookManager;
|
||||||
public final LaunchServerModulesManager modulesManager;
|
public final LaunchServerModulesManager modulesManager;
|
||||||
|
@ -148,9 +146,6 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
||||||
|
|
||||||
// Print keypair fingerprints
|
// Print keypair fingerprints
|
||||||
|
|
||||||
// Load class bindings.
|
|
||||||
launcherEXEBinaryClass = defaultLauncherEXEBinaryClass;
|
|
||||||
|
|
||||||
runtime.verify();
|
runtime.verify();
|
||||||
config.verify();
|
config.verify();
|
||||||
|
|
||||||
|
@ -276,12 +271,10 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
private LauncherBinary binary() {
|
private LauncherBinary binary() {
|
||||||
if (launcherEXEBinaryClass != null) {
|
LaunchServerLauncherExeInit event = new LaunchServerLauncherExeInit(this, null);
|
||||||
try {
|
modulesManager.invokeEvent(event);
|
||||||
return (LauncherBinary) MethodHandles.publicLookup().findConstructor(launcherEXEBinaryClass, MethodType.methodType(void.class, LaunchServer.class)).invoke(this);
|
if(event.binary != null) {
|
||||||
} catch (Throwable e) {
|
return event.binary;
|
||||||
logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class.forName("net.sf.launch4j.Builder");
|
Class.forName("net.sf.launch4j.Builder");
|
||||||
|
|
|
@ -25,7 +25,7 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
|
||||||
builder.setAssetDir("asset" + version.toCleanString());
|
builder.setAssetDir("asset" + version.toCleanString());
|
||||||
}
|
}
|
||||||
builder.setAssetIndex(version.toString());
|
builder.setAssetIndex(version.toString());
|
||||||
builder.setInfo("Информация о сервере");
|
builder.setInfo("Server description");
|
||||||
builder.setTitle(title);
|
builder.setTitle(title);
|
||||||
builder.setUuid(UUID.randomUUID());
|
builder.setUuid(UUID.randomUUID());
|
||||||
builder.setMainClass(getMainClassByVersion(version, options));
|
builder.setMainClass(getMainClassByVersion(version, options));
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package pro.gravit.launchserver.modules.events;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.modules.LauncherModule;
|
||||||
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
import pro.gravit.launchserver.binary.LauncherBinary;
|
||||||
|
|
||||||
|
public class LaunchServerLauncherExeInit extends LauncherModule.Event {
|
||||||
|
public final LaunchServer server;
|
||||||
|
public LauncherBinary binary;
|
||||||
|
|
||||||
|
public LaunchServerLauncherExeInit(LaunchServer server, LauncherBinary binary) {
|
||||||
|
this.server = server;
|
||||||
|
this.binary = binary;
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,13 +65,13 @@ private void injectCertificates() {
|
||||||
// добавление стандартных сертификатов в новый KeyStore
|
// добавление стандартных сертификатов в новый KeyStore
|
||||||
jdkTrustStore.keySet().forEach(key -> setCertificateEntry(mergedTrustStore, key, jdkTrustStore.get(key)));
|
jdkTrustStore.keySet().forEach(key -> setCertificateEntry(mergedTrustStore, key, jdkTrustStore.get(key)));
|
||||||
|
|
||||||
// Инициализация контекста. В случае неудачи допустимо прерывание процесса, но сертификаты добавлены не будут
|
// Context initialization. In case of failure, the process is allowed to be interrupted, but certificates will not be added
|
||||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
trustManagerFactory.init(mergedTrustStore);
|
trustManagerFactory.init(mergedTrustStore);
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
|
sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
|
||||||
|
|
||||||
// Установка контекста по умолчанию
|
// Setting the default context
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
||||||
LogHelper.info("Successfully injected certificates to truststore");
|
LogHelper.info("Successfully injected certificates to truststore");
|
||||||
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException | IOException | CertificateException e) {
|
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException | IOException | CertificateException e) {
|
||||||
|
@ -99,7 +99,7 @@ private static Map<String, Certificate> getDefaultKeyStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Извлечение существующих сертификатов из стандартного KeyStore текущий сессии JVM. Процесс не должен прерываться в случае неудачи
|
* Retrieve existing certificates from the standard KeyStore of the current JVM session. The process should not be interrupted in case of failure
|
||||||
*/
|
*/
|
||||||
private static void extractAllCertsAndPutInMap(KeyStore keyStore, Map<String, Certificate> placeToExport) {
|
private static void extractAllCertsAndPutInMap(KeyStore keyStore, Map<String, Certificate> placeToExport) {
|
||||||
try {
|
try {
|
||||||
|
@ -121,7 +121,7 @@ private static void setCertificateEntry(KeyStore keyStore, String name, Certific
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Извлечение существующего сертификата из стандартного KeyStore текущий сессии JVM. Процесс не должен прерываться в случае неудачи
|
* Retrieve an existing certificate from the standard KeyStore of the current JVM session. The process should not be interrupted in case of failure
|
||||||
*/
|
*/
|
||||||
private static void extractCertAndPutInMap(KeyStore keyStoreFromExtract, String key, Map<String, Certificate> placeToExtract) {
|
private static void extractCertAndPutInMap(KeyStore keyStoreFromExtract, String key, Map<String, Certificate> placeToExtract) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
import pro.gravit.utils.Version;
|
import pro.gravit.utils.Version;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Nashorn при инициализации LogHelper пытается инициализировтаь все доступные в нем методы.
|
* Nashorn when initializing LogHelper tries to initialize all methods available in it.
|
||||||
* При попытке инициализировать rawAnsiFormat он пытается найти класс org.fusesource.jansi.Ansi
|
* When trying to initialize rawAnsiFormat , it tries to find the org.fusesource.jansi.Ansi class
|
||||||
* И есстественно крашится с ClassNotFound
|
* And naturally crashes with ClassNotFound
|
||||||
* В итоге любой вызов LogHelper.* приводит к ClassNotFound org.fusesource.jansi.Ansi
|
* As a result, any call to LogHelper.* results in ClassNotFound org.fusesource.jansi.Ansi
|
||||||
* Поэтому rawAnsiFormat вынесен в отдельный Helper
|
* Therefore, rawAnsiFormat is moved to a separate Helper
|
||||||
*/
|
*/
|
||||||
public class FormatHelper {
|
public class FormatHelper {
|
||||||
public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) {
|
public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
|
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
|
||||||
}
|
}
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.4.2'
|
version = '5.4.3-SNAPSHOT'
|
||||||
|
|
||||||
apply from: 'props.gradle'
|
apply from: 'props.gradle'
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||||
options.incremental = true // one flag, and things will get MUCH faster
|
options.incremental = true // one flag, and things will get MUCH faster
|
||||||
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
compileTestJava.options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
Loading…
Reference in a new issue