Merge pull request #191 from GravitLauncher/radon

Radon
This commit is contained in:
Gravit 2019-03-22 13:04:24 +07:00 committed by GitHub
commit 8def68fa90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 126 additions and 26 deletions

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "modules"] [submodule "modules"]
path = modules path = modules
url = git@github.com:GravitLauncher/LauncherModules.git url = git@github.com:GravitLauncher/LauncherModules.git
[submodule "Radon"]
path = Radon
url = git@github.com:GravitLauncher/Radon.git

View file

@ -3,10 +3,10 @@
repositories { repositories {
maven { maven {
url "http://maven.geomajas.org/" url "https://oss.sonatype.org/content/repositories/snapshots"
} }
maven { maven {
url "https://oss.sonatype.org/content/repositories/snapshots" url "http://maven.geomajas.org/"
} }
} }
@ -14,6 +14,7 @@
targetCompatibility = '1.8' targetCompatibility = '1.8'
configurations { configurations {
compileOnlyA
bundleOnly bundleOnly
bundle bundle
hikari hikari
@ -38,8 +39,7 @@
dependencies { dependencies {
pack project(':libLauncher') pack project(':libLauncher')
bundle 'org.ow2.asm:asm-commons:7.0' bundle project(':Radon')
bundle 'org.ow2.asm:asm-util:7.0'
bundle 'mysql:mysql-connector-java:8.0.13' bundle 'mysql:mysql-connector-java:8.0.13'
bundle 'jline:jline:2.14.6' bundle 'jline:jline:2.14.6'
bundle 'net.sf.proguard:proguard-base:6.0.3' bundle 'net.sf.proguard:proguard-base:6.0.3'
@ -70,6 +70,9 @@ pack project(':libLauncher')
launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-linux') { launch4jCJ('net.sf.launch4j:launch4j:3.12:workdir-linux') {
exclude group: '*' exclude group: '*'
} }
compileOnlyA 'com.google.guava:guava:26.0-jre'
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2'
} }
task hikari(type: Copy) { task hikari(type: Copy) {
@ -113,13 +116,25 @@ task dumpLibs(type: Copy) {
from configurations.bundleOnly from configurations.bundleOnly
} }
task dumpCompileOnlyLibs(type: Copy) {
into "$buildDir/libs/launcher-libraries-compile"
from configurations.compileOnlyA
}
task bundle(type: Zip) { task bundle(type: Zip) {
dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.jar dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.jar
archiveName 'LaunchServer.zip' archiveName 'LaunchServer.zip'
destinationDir file("$buildDir") destinationDir file("$buildDir")
from(tasks.dumpLibs.destinationDir) { into 'libraries' } from(tasks.dumpLibs.destinationDir) { into 'libraries' }
from(tasks.dumpCompileOnlyLibs.destinationDir) { into 'launcher-libraries-compile' }
from tasks.jar.archivePath from tasks.jar.archivePath
from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' } from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' }
} }
build.dependsOn tasks.dumpLibs, tasks.bundle task dumpClientLibs(type: Copy) {
dependsOn parent.childProjects.Launcher.tasks.build
into "$buildDir/libs/launcher-libraries"
from parent.childProjects.Launcher.tasks.dumpLibs.destinationDir
}
build.dependsOn tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.dumpClientLibs, tasks.bundle

View file

@ -120,6 +120,7 @@ public static final class Config {
public boolean isWarningMissArchJava; public boolean isWarningMissArchJava;
public boolean enabledProGuard; public boolean enabledProGuard;
public boolean enabledRadon;
public boolean stripLineNumbers; public boolean stripLineNumbers;
public boolean deleteTempFiles; public boolean deleteTempFiles;
public boolean enableRcon; public boolean enableRcon;
@ -277,6 +278,7 @@ public static void main(String... args) throws Throwable {
// Start LaunchServer // Start LaunchServer
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
try { try {
@SuppressWarnings("resource")
LaunchServer launchserver = new LaunchServer(IOHelper.WORKING_DIR, args); LaunchServer launchserver = new LaunchServer(IOHelper.WORKING_DIR, args);
if(args.length == 0) launchserver.run(); if(args.length == 0) launchserver.run();
else { //Обработка команды else { //Обработка команды
@ -296,6 +298,8 @@ public static void main(String... args) throws Throwable {
public final Path launcherLibraries; public final Path launcherLibraries;
public final Path launcherLibrariesCompile;
public final List<String> args; public final List<String> args;
public final Path configFile; public final Path configFile;
@ -366,10 +370,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
this.dir = dir; this.dir = dir;
taskPool = new Timer("Timered task worker thread", true); taskPool = new Timer("Timered task worker thread", true);
launcherLibraries = dir.resolve("launcher-libraries"); launcherLibraries = dir.resolve("launcher-libraries");
if (!Files.isDirectory(launcherLibraries)) { launcherLibrariesCompile = dir.resolve("launcher-libraries-compile");
Files.deleteIfExists(launcherLibraries);
Files.createDirectory(launcherLibraries);
}
this.args = Arrays.asList(args); this.args = Arrays.asList(args);
configFile = dir.resolve("LaunchServer.conf"); configFile = dir.resolve("LaunchServer.conf");
publicKeyFile = dir.resolve("public.key"); publicKeyFile = dir.resolve("public.key");
@ -641,6 +642,7 @@ private void generateConfigIfNotExists() throws IOException {
newConfig.threadCoreCount = 0; // on your own newConfig.threadCoreCount = 0; // on your own
newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors(); newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors();
newConfig.enabledRadon = true;
newConfig.enabledProGuard = true; newConfig.enabledProGuard = true;
newConfig.stripLineNumbers = true; newConfig.stripLineNumbers = true;
newConfig.deleteTempFiles = true; newConfig.deleteTempFiles = true;

View file

@ -21,6 +21,7 @@ public final class JARLauncherBinary extends LauncherBinary {
public final Path buildDir; public final Path buildDir;
public List<LauncherBuildTask> tasks; public List<LauncherBuildTask> tasks;
public List<Path> coreLibs; public List<Path> coreLibs;
public List<Path> addonLibs;
public JARLauncherBinary(LaunchServer server) throws IOException { public JARLauncherBinary(LaunchServer server) throws IOException {
super(server); super(server);
@ -31,6 +32,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
buildDir = server.dir.resolve("build"); buildDir = server.dir.resolve("build");
tasks = new ArrayList<>(); tasks = new ArrayList<>();
coreLibs = new ArrayList<>(); coreLibs = new ArrayList<>();
addonLibs = new ArrayList<>();
if (!Files.isDirectory(buildDir)) { if (!Files.isDirectory(buildDir)) {
Files.deleteIfExists(buildDir); Files.deleteIfExists(buildDir);
Files.createDirectory(buildDir); Files.createDirectory(buildDir);
@ -42,8 +44,9 @@ public void init() {
tasks.add(new PrepareBuildTask(server)); tasks.add(new PrepareBuildTask(server));
tasks.add(new MainBuildTask(server)); tasks.add(new MainBuildTask(server));
tasks.add(new ProGuardBuildTask(server)); tasks.add(new ProGuardBuildTask(server));
tasks.add(new AttachJarsTask(server));
tasks.add(new AdditionalFixesApplyTask(server)); tasks.add(new AdditionalFixesApplyTask(server));
tasks.add(new RadonBuildTask(server));
tasks.add(new AttachJarsTask(server));
} }
@Override @Override

View file

@ -4,6 +4,7 @@
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;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
@ -13,7 +14,6 @@
import java.util.List; import java.util.List;
public class ProguardConf { public class ProguardConf {
private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ"; private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ";
private static String generateString(SecureRandom rand, String lowString, String upString, int il) { private static String generateString(SecureRandom rand, String lowString, String upString, int il) {
@ -50,6 +50,9 @@ public String[] buildConfig(Path inputJar, Path outputJar) {
srv.launcherBinary.coreLibs.stream() srv.launcherBinary.coreLibs.stream()
.map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'") .map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'")
.forEach(confStrs::add); .forEach(confStrs::add);
srv.launcherBinary.addonLibs.stream()
.map(e -> "-libraryjars \'" + e.toAbsolutePath().toString() + "\'")
.forEach(confStrs::add);
confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'"); confStrs.add("-classobfuscationdictionary \'" + words.toFile().getName() + "\'");
confStrs.add(readConf()); confStrs.add(readConf());
return confStrs.toArray(new String[0]); return confStrs.toArray(new String[0]);
@ -58,9 +61,7 @@ public String[] buildConfig(Path inputJar, Path outputJar) {
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);
try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) { UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config);
IOHelper.transfer(in, out);
}
} }
public void genWords(boolean force) throws IOException { public void genWords(boolean force) throws IOException {

View file

@ -30,7 +30,9 @@ public String getName() {
@Override @Override
public Path process(Path inputFile) throws IOException { public Path process(Path inputFile) throws IOException {
server.launcherBinary.coreLibs.clear(); server.launcherBinary.coreLibs.clear();
server.launcherBinary.addonLibs.clear();
IOHelper.walk(server.launcherLibraries, new ListFileVisitor(server.launcherBinary.coreLibs), true); IOHelper.walk(server.launcherLibraries, new ListFileVisitor(server.launcherBinary.coreLibs), true);
IOHelper.walk(server.launcherLibrariesCompile, new ListFileVisitor(server.launcherBinary.addonLibs), true);
UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), result); UnpackHelper.unpack(IOHelper.getResourceURL("Launcher.jar"), result);
tryUnpack(); tryUnpack();
return result; return result;

View file

@ -25,8 +25,8 @@ public String getName() {
@Override @Override
public Path process(Path inputFile) throws IOException { public Path process(Path inputFile) throws IOException {
if (server.config.enabledProGuard) {
Path outputJar = server.launcherBinary.nextLowerPath(this); Path outputJar = server.launcherBinary.nextLowerPath(this);
if (server.config.enabledProGuard) {
Configuration proguard_cfg = new Configuration(); Configuration proguard_cfg = new Configuration();
ConfigurationParser parser = new ConfigurationParser(server.proguardConf.buildConfig(inputFile, outputJar), ConfigurationParser parser = new ConfigurationParser(server.proguardConf.buildConfig(inputFile, outputJar),
server.proguardConf.proguard.toFile(), System.getProperties()); server.proguardConf.proguard.toFile(), System.getProperties());
@ -37,13 +37,10 @@ public Path process(Path inputFile) throws IOException {
} catch (ParseException e) { } catch (ParseException e) {
LogHelper.error(e); LogHelper.error(e);
} }
return outputJar; } else
} else {
Path outputJar = server.launcherBinary.nextPath("non-obf");
IOHelper.copy(inputFile, outputJar); IOHelper.copy(inputFile, outputJar);
return outputJar; return outputJar;
} }
}
@Override @Override
public boolean allowDelete() { public boolean allowDelete() {

View file

@ -0,0 +1,55 @@
package ru.gravit.launchserver.binary.tasks;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.UnpackHelper;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
public class RadonBuildTask implements LauncherBuildTask {
private final LaunchServer srv;
public final Path config;
public RadonBuildTask(LaunchServer srv) {
this.srv = srv;
config = this.srv.dir.resolve("radon.yml");
System.setProperty("radon.useJVMCP", "true");
}
@Override
public String getName() {
return "Radon";
}
@Override
public Path process(Path inputFile) throws IOException {
Path outputFile = srv.launcherBinary.nextLowerPath(this);
if (srv.config.enabledRadon) {
if (!IOHelper.isFile(config)) UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config);
ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config));
SessionInfo info = p.createSessionFromConfig();
info.setInput(inputFile.toFile());
info.setOutput(outputFile.toFile());
List<File> libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList());
libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()));
info.setLibraries(libs);
Radon r = new Radon(info);
r.run();
} else
IOHelper.copy(inputFile, outputFile);
return outputFile;
}
@Override
public boolean allowDelete() {
return true;
}
}

View file

@ -0,0 +1,21 @@
StringEncryption:
Enabled: true
Mode: Normal
StringPool: false
InvokeDynamic: None
NumberObfuscation: Normal
FlowObfuscation: Normal
HideCode: false
Shuffler: true
Crasher: false
Optimizer:
Enabled: true
InlineGotoGoto: true
InlineGotoReturn: true
RemoveNopInstructions: true
Watermarker:
Enabled: false
Message: "This copy belongs to GravitLauncher"
Key: "SuperSecureKey"
Dictionary: Spaces
TrashClasses: 500

View file

@ -356,8 +356,6 @@ public static Process launch(
context.args.add(JVMHelper.jvmProperty("os.name", "Windows 10")); context.args.add(JVMHelper.jvmProperty("os.name", "Windows 10"));
context.args.add(JVMHelper.jvmProperty("os.version", "10.0")); context.args.add(JVMHelper.jvmProperty("os.version", "10.0"));
} }
context.args.add(JVMHelper.systemToJvmProperty("avn32"));
context.args.add(JVMHelper.systemToJvmProperty("avn64"));
} }
// Add classpath and main class // Add classpath and main class
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();

1
Radon Submodule

@ -0,0 +1 @@
Subproject commit e1f7548f97132fa29b01f68bd57ffab32de7b6e7

View file

@ -1,10 +1,11 @@
configure(subprojects.findAll {it.name != 'modules'}) { configure(subprojects.findAll { it.name != 'modules' && it.name != 'Radon' }) {
apply plugin: 'idea' apply plugin: 'idea'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'java' apply plugin: 'java'
repositories { repositories {
mavenCentral() mavenCentral()
maven { url 'http://oss.sonatype.org/content/groups/public' }
maven { maven {
url "http://clojars.org/repo/" url "http://clojars.org/repo/"
} }

View file

@ -1,6 +1,7 @@
rootProject.name = 'GravitLauncher' rootProject.name = 'GravitLauncher'
include 'Launcher' include 'Launcher'
include 'Radon'
include 'libLauncher' include 'libLauncher'
include 'LauncherAPI' include 'LauncherAPI'
include 'ServerWrapper' include 'ServerWrapper'