Some fixes.

This commit is contained in:
zaxar163 2018-12-26 16:17:47 +03:00
parent ddeefc03b0
commit ff7887a006
5 changed files with 20 additions and 10 deletions

View file

@ -53,6 +53,7 @@
import ru.gravit.launchserver.binary.EXELauncherBinary; import ru.gravit.launchserver.binary.EXELauncherBinary;
import ru.gravit.launchserver.binary.JARLauncherBinary; import ru.gravit.launchserver.binary.JARLauncherBinary;
import ru.gravit.launchserver.binary.LauncherBinary; import ru.gravit.launchserver.binary.LauncherBinary;
import ru.gravit.launchserver.binary.ProguardConf;
import ru.gravit.launchserver.command.handler.CommandHandler; import ru.gravit.launchserver.command.handler.CommandHandler;
import ru.gravit.launchserver.command.handler.JLineCommandHandler; import ru.gravit.launchserver.command.handler.JLineCommandHandler;
import ru.gravit.launchserver.command.handler.StdCommandHandler; import ru.gravit.launchserver.command.handler.StdCommandHandler;
@ -457,7 +458,12 @@ public static void initGson()
} }
private LauncherBinary binary() { private LauncherBinary binary() {
try {
Class.forName("net.sf.launch4j.Builder");
if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this); if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this);
} catch (ClassNotFoundException ignored) {
LogHelper.warning("Launch4J isn't in classpath.");
}
return new EXELauncherBinary(this); return new EXELauncherBinary(this);
} }

View file

@ -38,7 +38,7 @@ public void pushJarFile(ZipInputStream input) throws IOException {
e = input.getNextEntry(); e = input.getNextEntry();
continue; continue;
} }
output.putNextEntry(e); output.putNextEntry(IOHelper.newZipEntry(e));
IOHelper.transfer(input, output); IOHelper.transfer(input, output);
fileList.add(e.getName()); fileList.add(e.getName());
e = input.getNextEntry(); e = input.getNextEntry();
@ -52,7 +52,7 @@ public void pushJarFile(ZipInputStream input, Set<String> blacklist) throws IOEx
e = input.getNextEntry(); e = input.getNextEntry();
continue; continue;
} }
output.putNextEntry(e); output.putNextEntry(IOHelper.newZipEntry(e));
IOHelper.transfer(input, output); IOHelper.transfer(input, output);
fileList.add(e.getName()); fileList.add(e.getName());
e = input.getNextEntry(); e = input.getNextEntry();

View file

@ -126,7 +126,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
guardDir = server.dir.resolve(Launcher.GUARD_DIR); guardDir = server.dir.resolve(Launcher.GUARD_DIR);
initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE); initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE);
obfJar = server.dir.resolve(server.config.binaryName + "-obfed.jar"); obfJar = server.dir.resolve(server.config.binaryName + "-obfPre.jar");
obfOutJar = server.config.buildPostTransform.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar") obfOutJar = server.config.buildPostTransform.enabled ? server.dir.resolve(server.config.binaryName + "-obf.jar")
: syncBinaryFile; : syncBinaryFile;
cleanJar = server.dir.resolve(server.config.binaryName + "-clean.jar"); cleanJar = server.dir.resolve(server.config.binaryName + "-clean.jar");
@ -162,7 +162,7 @@ public void build() throws IOException {
ZipEntry e = input.getNextEntry(); ZipEntry e = input.getNextEntry();
while (e != null) { while (e != null) {
String filename = e.getName(); String filename = e.getName();
output.putNextEntry(IOHelper.newZipEntry(e.getName())); output.putNextEntry(IOHelper.newZipEntry(e));
if (filename.endsWith(".class")) { if (filename.endsWith(".class")) {
String classname = filename.replace('/', '.').substring(0, filename.length() - ".class".length()); String classname = filename.replace('/', '.').substring(0, filename.length() - ".class".length());
byte[] bytes; byte[] bytes;
@ -226,7 +226,7 @@ private void stdBuild() throws IOException {
continue; continue;
} }
try { try {
output.putNextEntry(IOHelper.newZipEntry(e.getName())); output.putNextEntry(IOHelper.newZipEntry(e));
} catch (ZipException ex) { } catch (ZipException ex) {
LogHelper.error(ex); LogHelper.error(ex);
e = input.getNextEntry(); e = input.getNextEntry();

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver; package ru.gravit.launchserver.binary;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -10,6 +10,7 @@
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.ArrayList; import java.util.ArrayList;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper;
@ -41,7 +42,7 @@ public ProguardConf(LaunchServer srv) {
if (srv.config.genMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'"); if (srv.config.genMappings) confStrs.add("-printmapping \'" + mappings.toFile().getName() + "\'");
confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-obfuscationdictionary \'" + words.toFile().getName() + "\'");
confStrs.add("-injar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-nonObf.jar\'"); confStrs.add("-injar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-nonObf.jar\'");
confStrs.add("-outjar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-obfed.jar\'"); confStrs.add("-outjar \'" + srv.dir.toAbsolutePath() + IOHelper.PLATFORM_SEPARATOR + srv.config.binaryName + "-obfPre.jar\'");
confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'");
confStrs.add(readConf()); confStrs.add(readConf());
@ -59,7 +60,6 @@ private void genConfig(boolean force) throws IOException {
public void genWords(boolean force) throws IOException { public void genWords(boolean force) throws IOException {
if (IOHelper.exists(words) && !force) return; if (IOHelper.exists(words) && !force) return;
Files.deleteIfExists(words); Files.deleteIfExists(words);
words.toFile().createNewFile();
SecureRandom rand = SecurityHelper.newRandom(); SecureRandom rand = SecurityHelper.newRandom();
rand.setSeed(SecureRandom.getSeed(32)); rand.setSeed(SecureRandom.getSeed(32));
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) { try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) {

View file

@ -1,5 +1,8 @@
package ru.gravit.launchserver.command.basic; package ru.gravit.launchserver.command.basic;
import java.io.IOException;
import java.nio.file.Files;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.Command;
@ -19,7 +22,8 @@ public String getUsageDescription() {
} }
@Override @Override
public void invoke(String... args) { public void invoke(String... args) throws IOException {
server.proguardConf.prepare(true); server.proguardConf.prepare(true);
Files.deleteIfExists(server.proguardConf.mappings);
} }
} }