diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java index 6cffd62b..7342582c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java @@ -1,8 +1,8 @@ package ru.gravit.launchserver; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.file.Files; @@ -10,9 +10,13 @@ import java.security.SecureRandom; import java.util.ArrayList; +import ru.gravit.launcher.serialize.config.TextConfigReader; +import ru.gravit.launcher.serialize.config.TextConfigWriter; +import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.UnpackHelper; public class ProguardConf { private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; @@ -50,16 +54,12 @@ public ProguardConf(LaunchServer srv) { private void genConfig(boolean force) throws IOException { if (IOHelper.exists(config) && !force) return; Files.deleteIfExists(config); - config.toFile().createNewFile(); - try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) { - IOHelper.transfer(in, out); - } + UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config); } public void genWords(boolean force) throws IOException { if (IOHelper.exists(words) && !force) return; Files.deleteIfExists(words); - words.toFile().createNewFile(); SecureRandom rand = SecurityHelper.newRandom(); rand.setSeed(SecureRandom.getSeed(32)); try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java index 49a9e669..0e3028cf 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java @@ -29,7 +29,7 @@ public void pushFile(String filename, InputStream inputStream) throws IOExceptio public void pushJarFile(ZipInputStream input) throws IOException { ZipEntry e = input.getNextEntry(); while (e != null) { - output.putNextEntry(e); + output.putNextEntry(IOHelper.newZipEntry(e)); IOHelper.transfer(input, output); e = input.getNextEntry(); } @@ -42,7 +42,7 @@ public void pushJarFile(ZipInputStream input, Set blacklist) throws IOEx e = input.getNextEntry(); continue; } - output.putNextEntry(e); + output.putNextEntry(IOHelper.newZipEntry(e)); IOHelper.transfer(input, output); e = input.getNextEntry(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 79d2f843..63c9d800 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -41,6 +41,7 @@ import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; import ru.gravit.utils.helper.UnpackHelper; +// TODO: exclusions impl public final class JARLauncherBinary extends LauncherBinary { private final class RuntimeDirVisitor extends SimpleFileVisitor { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ProguardCleanCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ProguardCleanCommand.java index 704f1c6d..b2dd5014 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ProguardCleanCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/ProguardCleanCommand.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.command.basic; +import java.io.IOException; +import java.nio.file.Files; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; @@ -19,7 +22,8 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) { + public void invoke(String... args) throws IOException { server.proguardConf.prepare(true); + Files.deleteIfExists(server.proguardConf.mappings); } } diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg index c08bbda3..1776cd74 100644 --- a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg +++ b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/proguard.cfg @@ -19,9 +19,9 @@ -keepattributes Signature -adaptresourcefilecontents META-INF/MANIFEST.MF --keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,oshi.**,com.sun.jna.**,com.google.gson.** +-keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,oshi.**,com.sun.jna.**,com.google.gson.**,org.slf4j.** --keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,oshi.**,com.sun.jna.**,com.google.gson.**,org.slf4j.**,oshi.jna.**,com.sun.jna.** { +-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,oshi.**,com.sun.jna.**,com.google.gson.**,org.slf4j.** { *; }