mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] Опция отключения файл-сервера + автокопирование binaries (тоже опция). (#236)
* [FIX] Убраны лишние классы из libLauncher. * [FIX] Получение RAM. * [FIX] Ещё фиксы такового с RAM. * [REFACTOR] Удалён лишний код. * [FEATURE] Теперь прикрутить sentry можно просто добавив библиотеку в libraries и дописав 3 строчки в runtime. * [FIX] Ошибка в паттернах ServerWrapper, порождает java.util.IllegalFormatConversionException * [FEATURE] Чистка конфига. * [FIX] Убрал лишние варнинги. * [FIX] Мои ошибки.
This commit is contained in:
parent
10a441b2ae
commit
c6c86afce1
8 changed files with 33 additions and 30 deletions
|
@ -79,6 +79,8 @@ public static final class Config {
|
|||
public String[] mirrors;
|
||||
|
||||
public String binaryName;
|
||||
|
||||
public boolean copyBinaries = true;
|
||||
|
||||
public LauncherConfig.LauncherEnvironment env;
|
||||
|
||||
|
@ -269,7 +271,7 @@ public class LauncherConf
|
|||
}
|
||||
|
||||
public class NettyConfig {
|
||||
public boolean clientEnabled;
|
||||
public boolean fileServerEnabled;
|
||||
public boolean sendExceptionEnabled;
|
||||
public String launcherURL;
|
||||
public String downloadURL;
|
||||
|
@ -704,11 +706,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
|
|||
newConfig.whitelistRejectString = "Вас нет в белом списке";
|
||||
|
||||
newConfig.netty = new NettyConfig();
|
||||
newConfig.netty.address = "ws://localhost:9274/api";
|
||||
newConfig.netty.downloadURL = "http://localhost:9274/%dirname%/";
|
||||
newConfig.netty.launcherURL = "http://localhost:9274/Launcher.jar";
|
||||
newConfig.netty.launcherEXEURL = "http://localhost:9274/Launcher.exe";
|
||||
newConfig.netty.clientEnabled = false;
|
||||
newConfig.netty.fileServerEnabled = true;
|
||||
newConfig.netty.binds = new NettyBindAddress[]{ new NettyBindAddress("0.0.0.0", 9274) };
|
||||
newConfig.netty.performance = new NettyPerformanceConfig();
|
||||
newConfig.netty.performance.bossThread = 2;
|
||||
|
@ -734,25 +732,33 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
|
|||
newConfig.components.put("authLimiter", authLimiterComponent);
|
||||
|
||||
// Set server address
|
||||
String address;
|
||||
if (testEnv) {
|
||||
newConfig.setLegacyAddress("localhost");
|
||||
address = "localhost";
|
||||
newConfig.setProjectName("test");
|
||||
} else {
|
||||
System.out.println("LaunchServer legacy address(default: localhost): ");
|
||||
newConfig.setLegacyAddress(commandHandler.readLine());
|
||||
System.out.println("LaunchServer address(default: localhost): ");
|
||||
address = commandHandler.readLine();
|
||||
System.out.println("LaunchServer projectName: ");
|
||||
newConfig.setProjectName(commandHandler.readLine());
|
||||
}
|
||||
if(newConfig.legacyAddress == null)
|
||||
if(address == null)
|
||||
{
|
||||
LogHelper.error("Legacy address null. Using localhost");
|
||||
newConfig.legacyAddress = "localhost";
|
||||
LogHelper.error("Address null. Using localhost");
|
||||
address = "localhost";
|
||||
}
|
||||
if(newConfig.projectName == null)
|
||||
{
|
||||
LogHelper.error("ProjectName null. Using MineCraft");
|
||||
newConfig.projectName = "MineCraft";
|
||||
}
|
||||
|
||||
newConfig.legacyAddress = address;
|
||||
newConfig.netty.address = "ws://" + address + ":9274/api";
|
||||
newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/";
|
||||
newConfig.netty.launcherURL = "http://" + address + ":9274/internal/Launcher.jar";
|
||||
newConfig.netty.launcherEXEURL = "http://" + address + ":9274/internal/Launcher.exe";
|
||||
newConfig.netty.sendExceptionEnabled = true;
|
||||
|
||||
// Write LaunchServer config
|
||||
LogHelper.info("Writing LaunchServer config file");
|
||||
|
@ -836,14 +842,14 @@ public void syncUpdatesDir(Collection<String> dirs) throws IOException {
|
|||
LogHelper.info("Syncing updates dir");
|
||||
Map<String, SignedObjectHolder<HashedDir>> newUpdatesDirMap = new HashMap<>(16);
|
||||
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(updatesDir)) {
|
||||
for (Path updateDir : dirStream) {
|
||||
for (final Path updateDir : dirStream) {
|
||||
if (Files.isHidden(updateDir))
|
||||
continue; // Skip hidden
|
||||
|
||||
// Resolve name and verify is dir
|
||||
String name = IOHelper.getFileName(updateDir);
|
||||
if (!IOHelper.isDir(updateDir)) {
|
||||
LogHelper.warning("Not update dir: '%s'", name);
|
||||
if (!IOHelper.isFile(updateDir) && Arrays.asList(".jar", ".exe", ".hash").stream().noneMatch(e -> updateDir.toString().endsWith(e))) LogHelper.warning("Not update dir: '%s'", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public void clear() {
|
|||
|
||||
|
||||
public EXEL4JLauncherBinary(LaunchServer server) {
|
||||
super(server, server.dir.resolve(server.config.binaryName + ".exe"));
|
||||
super(server, LauncherBinary.resolve(server, ".exe"));
|
||||
faviconFile = server.dir.resolve("favicon.ico");
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
public class EXELauncherBinary extends LauncherBinary {
|
||||
|
||||
public EXELauncherBinary(LaunchServer server) {
|
||||
super(server, server.dir.resolve(server.config.binaryName + ".exe"));
|
||||
super(server, LauncherBinary.resolve(server, ".exe"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,9 +24,8 @@ public final class JARLauncherBinary extends LauncherBinary {
|
|||
public List<Path> addonLibs;
|
||||
|
||||
public JARLauncherBinary(LaunchServer server) throws IOException {
|
||||
super(server);
|
||||
super(server, LauncherBinary.resolve(server, ".jar"));
|
||||
count = new AtomicLong(0);
|
||||
syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar");
|
||||
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||
guardDir = server.dir.resolve(Launcher.GUARD_DIR);
|
||||
buildDir = server.dir.resolve("build");
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
public abstract class LauncherBinary {
|
||||
public final LaunchServer server;
|
||||
public Path syncBinaryFile;
|
||||
public final Path syncBinaryFile;
|
||||
private volatile DigestBytesHolder binary;
|
||||
private volatile byte[] sign;
|
||||
|
||||
|
@ -19,10 +19,6 @@ protected LauncherBinary(LaunchServer server, Path binaryFile) {
|
|||
syncBinaryFile = binaryFile;
|
||||
}
|
||||
|
||||
protected LauncherBinary(LaunchServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public abstract void build() throws IOException;
|
||||
|
||||
|
||||
|
@ -49,4 +45,8 @@ public final boolean sync() throws IOException {
|
|||
|
||||
return exists;
|
||||
}
|
||||
|
||||
public static final Path resolve(LaunchServer server, String ext) {
|
||||
return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public void initChannel(NioSocketChannel ch) {
|
|||
pipeline.addLast(new HttpObjectAggregator(65536));
|
||||
pipeline.addLast(new WebSocketServerCompressionHandler());
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
|
||||
pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true));
|
||||
if (LaunchServer.server.config.netty.fileServerEnabled) pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true));
|
||||
pipeline.addLast(new WebSocketFrameHandler());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -56,9 +56,9 @@ public static HWID getHWID() {
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static long getTotalMemory() {
|
||||
if (cachedMemorySize > 0) return cachedMemorySize;
|
||||
return cachedMemorySize = hwidProvider.getTotalMemory() >> 20;
|
||||
public static int getTotalMemory() {
|
||||
if (cachedMemorySize > 0) return (int)cachedMemorySize;
|
||||
return (int)(cachedMemorySize = hwidProvider.getTotalMemory() >> 20);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
|
@ -67,7 +67,7 @@ public static int getClientJVMBits() {
|
|||
}
|
||||
|
||||
@LauncherAPI
|
||||
public static long getJVMTotalMemory() {
|
||||
public static int getJVMTotalMemory() {
|
||||
if (getClientJVMBits() == 32) {
|
||||
return Math.min(getTotalMemory(), 1536);
|
||||
} else {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
public class LauncherSSLContext {
|
||||
public SSLServerSocketFactory ssf;
|
||||
public SSLSocketFactory sf;
|
||||
@SuppressWarnings("unused")
|
||||
private SSLContext sc;
|
||||
|
||||
public LauncherSSLContext(KeyStore ks, String keypassword) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException {
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
|
|
Loading…
Reference in a new issue