This commit is contained in:
zaxar163 2018-12-12 15:51:50 +03:00
parent d559025241
commit eca11301b3
No known key found for this signature in database
GPG key ID: E3B309DD3852DE06
5 changed files with 17 additions and 12 deletions

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver; package ru.gravit.launchserver;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.nio.file.Files; import java.nio.file.Files;
@ -10,9 +10,13 @@
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.ArrayList; 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.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;
import ru.gravit.utils.helper.UnpackHelper;
public class ProguardConf { public class ProguardConf {
private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
@ -50,16 +54,12 @@ public ProguardConf(LaunchServer srv) {
private void genConfig(boolean force) throws IOException { private void genConfig(boolean force) throws IOException {
if (IOHelper.exists(config) && !force) return; if (IOHelper.exists(config) && !force) return;
Files.deleteIfExists(config); Files.deleteIfExists(config);
config.toFile().createNewFile(); UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config);
try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) {
IOHelper.transfer(in, out);
}
} }
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

@ -29,7 +29,7 @@ public void pushFile(String filename, InputStream inputStream) throws IOExceptio
public void pushJarFile(ZipInputStream input) throws IOException { public void pushJarFile(ZipInputStream input) throws IOException {
ZipEntry e = input.getNextEntry(); ZipEntry e = input.getNextEntry();
while (e != null) { while (e != null) {
output.putNextEntry(e); output.putNextEntry(IOHelper.newZipEntry(e));
IOHelper.transfer(input, output); IOHelper.transfer(input, output);
e = input.getNextEntry(); e = input.getNextEntry();
} }
@ -42,7 +42,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);
e = input.getNextEntry(); e = input.getNextEntry();
} }

View file

@ -41,6 +41,7 @@
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
import ru.gravit.utils.helper.UnpackHelper; import ru.gravit.utils.helper.UnpackHelper;
// TODO: exclusions impl
public final class JARLauncherBinary extends LauncherBinary { public final class JARLauncherBinary extends LauncherBinary {
private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> { private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> {

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);
} }
} }

View file

@ -19,9 +19,9 @@
-keepattributes Signature -keepattributes Signature
-adaptresourcefilecontents META-INF/MANIFEST.MF -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.** {
*; *;
} }