mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[ANY] IDEA Code Inspect
This commit is contained in:
parent
846ec90575
commit
3521f5882d
12 changed files with 66 additions and 74 deletions
|
@ -212,8 +212,7 @@ public void init()
|
||||||
protectHandler.checkLaunchServerLicense();
|
protectHandler.checkLaunchServerLicense();
|
||||||
}
|
}
|
||||||
LaunchServer.server.registerObject("permissionsHandler", permissionsHandler);
|
LaunchServer.server.registerObject("permissionsHandler", permissionsHandler);
|
||||||
for (int i = 0; i < auth.length; ++i) {
|
for (AuthProviderPair pair : auth) {
|
||||||
AuthProviderPair pair = auth[i];
|
|
||||||
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
|
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
|
||||||
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
|
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
|
||||||
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
|
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
|
||||||
|
@ -225,8 +224,7 @@ public void init()
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler);
|
LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler);
|
||||||
for (int i = 0; i < auth.length; ++i) {
|
for (AuthProviderPair pair : auth) {
|
||||||
AuthProviderPair pair = auth[i];
|
|
||||||
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
|
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
|
||||||
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
|
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
|
||||||
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
|
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
|
||||||
|
|
|
@ -33,7 +33,7 @@ private StarterVisitor() {
|
||||||
try {
|
try {
|
||||||
Files.deleteIfExists(filef);
|
Files.deleteIfExists(filef);
|
||||||
Files.createFile(filef);
|
Files.createFile(filef);
|
||||||
} catch (Throwable t) { }
|
} catch (Throwable ignored) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ public static void registerProviders() {
|
||||||
public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception;
|
public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception;
|
||||||
|
|
||||||
public void preAuth(String login, String password, String customText, String ip) {
|
public void preAuth(String login, String password, String customText, String ip) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final boolean sync() throws IOException {
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Path resolve(LaunchServer server, String ext) {
|
public static Path resolve(LaunchServer server, String ext) {
|
||||||
return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext);
|
return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public Path process(Path inputFile) throws IOException {
|
||||||
SessionInfo info = p.createSessionFromConfig();
|
SessionInfo info = p.createSessionFromConfig();
|
||||||
info.setInput(inputFile.toFile());
|
info.setInput(inputFile.toFile());
|
||||||
info.setOutput(outputFile.toFile());
|
info.setOutput(outputFile.toFile());
|
||||||
List<File> libs = srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList());
|
List<File> libs = srv.launcherBinary.coreLibs.stream().map(Path::toFile).collect(Collectors.toList());
|
||||||
libs.addAll(srv.launcherBinary.addonLibs.stream().map(e -> e.toFile()).collect(Collectors.toList()));
|
libs.addAll(srv.launcherBinary.addonLibs.stream().map(Path::toFile).collect(Collectors.toList()));
|
||||||
info.setLibraries(libs);
|
info.setLibraries(libs);
|
||||||
Radon r = new Radon(info);
|
Radon r = new Radon(info);
|
||||||
r.run();
|
r.run();
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
public final class TaskUtil {
|
public final class TaskUtil {
|
||||||
public static void addCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskAdd) {
|
public static void addCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskAdd) {
|
||||||
List<LauncherBuildTask> indexes = new ArrayList<>();
|
List<LauncherBuildTask> indexes = new ArrayList<>();
|
||||||
tasks.stream().filter(pred).forEach(e -> indexes.add(e));
|
tasks.stream().filter(pred).forEach(indexes::add);
|
||||||
indexes.forEach(e -> tasks.add(tasks.indexOf(e) + count, taskAdd));
|
indexes.forEach(e -> tasks.add(tasks.indexOf(e) + count, taskAdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskRep) {
|
public static void replaceCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskRep) {
|
||||||
List<LauncherBuildTask> indexes = new ArrayList<>();
|
List<LauncherBuildTask> indexes = new ArrayList<>();
|
||||||
tasks.stream().filter(pred).forEach(e -> indexes.add(e));
|
tasks.stream().filter(pred).forEach(indexes::add);
|
||||||
indexes.forEach(e -> tasks.set(tasks.indexOf(e) + count, taskRep));
|
indexes.forEach(e -> tasks.set(tasks.indexOf(e) + count, taskRep));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected final void debug(String message, Object... args) {
|
||||||
public abstract void reply() throws Exception;
|
public abstract void reply() throws Exception;
|
||||||
|
|
||||||
|
|
||||||
protected static final void writeNoError(HOutput output) throws IOException {
|
protected static void writeNoError(HOutput output) throws IOException {
|
||||||
output.writeString("", 0);
|
output.writeString("", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,56 +100,59 @@ private static void replaceClasses(boolean pb, boolean rt) {
|
||||||
* Use ASM to modify the byte array
|
* Use ASM to modify the byte array
|
||||||
*/
|
*/
|
||||||
private static byte[] transformClass(String className, byte[] classBytes) {
|
private static byte[] transformClass(String className, byte[] classBytes) {
|
||||||
if (className.equals("java.lang.Runtime")) {
|
switch (className) {
|
||||||
ClassReader cr=new ClassReader(classBytes);
|
case "java.lang.Runtime": {
|
||||||
ClassNode cn=new ClassNode();
|
ClassReader cr = new ClassReader(classBytes);
|
||||||
cr.accept(cn,ClassReader.EXPAND_FRAMES);
|
ClassNode cn = new ClassNode();
|
||||||
|
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
||||||
for (Object o : cn.methods.toArray()) {
|
|
||||||
MethodNode m = (MethodNode) o;
|
for (Object o : cn.methods.toArray()) {
|
||||||
if(m.name.equals("exec")) {
|
MethodNode m = (MethodNode) o;
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
if (m.name.equals("exec")) {
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
m.instructions.insert(new InsnNode(ARETURN));
|
||||||
}
|
m.instructions.insert(new InsnNode(ACONST_NULL));
|
||||||
}
|
}
|
||||||
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
}
|
||||||
cn.accept(cw);
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
return cw.toByteArray();
|
cn.accept(cw);
|
||||||
} else if (className.equals("java.lang.ProcessBuilder")) {
|
return cw.toByteArray();
|
||||||
ClassReader cr=new ClassReader(classBytes);
|
}
|
||||||
ClassNode cn=new ClassNode();
|
case "java.lang.ProcessBuilder": {
|
||||||
cr.accept(cn,ClassReader.EXPAND_FRAMES);
|
ClassReader cr = new ClassReader(classBytes);
|
||||||
|
ClassNode cn = new ClassNode();
|
||||||
for (Object o : cn.methods.toArray()) {
|
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
||||||
MethodNode m = (MethodNode) o;
|
|
||||||
if(m.name.equals("start")) {
|
for (Object o : cn.methods.toArray()) {
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
MethodNode m = (MethodNode) o;
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
if (m.name.equals("start")) {
|
||||||
}
|
m.instructions.insert(new InsnNode(ARETURN));
|
||||||
}
|
m.instructions.insert(new InsnNode(ACONST_NULL));
|
||||||
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
}
|
||||||
cn.accept(cw);
|
}
|
||||||
return cw.toByteArray();
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
} else if (className.equals("java.awt.Robot")) {
|
cn.accept(cw);
|
||||||
ClassReader cr=new ClassReader(classBytes);
|
return cw.toByteArray();
|
||||||
ClassNode cn=new ClassNode();
|
}
|
||||||
cr.accept(cn,ClassReader.EXPAND_FRAMES);
|
case "java.awt.Robot": {
|
||||||
|
ClassReader cr = new ClassReader(classBytes);
|
||||||
for (Object o : cn.methods.toArray()) {
|
ClassNode cn = new ClassNode();
|
||||||
MethodNode m = (MethodNode) o;
|
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
||||||
if( m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
|
|
||||||
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
|
for (Object o : cn.methods.toArray()) {
|
||||||
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
|
MethodNode m = (MethodNode) o;
|
||||||
m.name.equals("mouseWheel"))
|
if (m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
|
||||||
{
|
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
m.name.equals("mouseWheel")) {
|
||||||
}
|
m.instructions.insert(new InsnNode(ARETURN));
|
||||||
}
|
m.instructions.insert(new InsnNode(ACONST_NULL));
|
||||||
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
}
|
||||||
cn.accept(cw);
|
}
|
||||||
return cw.toByteArray();
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
}
|
cn.accept(cw);
|
||||||
|
return cw.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
return classBytes;
|
return classBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,7 @@ public void invoke(String... args) throws Exception {
|
||||||
Request.service.registerHandler((result) -> {
|
Request.service.registerHandler((result) -> {
|
||||||
if(result instanceof LogEvent)
|
if(result instanceof LogEvent)
|
||||||
{
|
{
|
||||||
LogHelper.rawLog(() -> {
|
LogHelper.rawLog(() -> ((LogEvent) result).string, () -> ((LogEvent) result).string, () -> ((LogEvent) result).string);
|
||||||
return ((LogEvent) result).string;
|
|
||||||
}, () -> {
|
|
||||||
return ((LogEvent) result).string;
|
|
||||||
}, () -> {
|
|
||||||
return ((LogEvent) result).string;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,9 +193,7 @@ else if(entry.getType().equals(HashedEntry.Type.DIR))
|
||||||
startTime = Instant.now();
|
startTime = Instant.now();
|
||||||
updateState("UnknownFile", 0L, 100);
|
updateState("UnknownFile", 0L, 100);
|
||||||
ListDownloader listDownloader = new ListDownloader();
|
ListDownloader listDownloader = new ListDownloader();
|
||||||
listDownloader.download(e.url, adds, dir, this::updateState, (add) -> {
|
listDownloader.download(e.url, adds, dir, this::updateState, (add) -> totalDownloaded += add);
|
||||||
totalDownloaded += add;
|
|
||||||
});
|
|
||||||
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
||||||
LogHelper.debug("Update success");
|
LogHelper.debug("Update success");
|
||||||
return e;
|
return e;
|
||||||
|
|
2
Radon
2
Radon
|
@ -1 +1 @@
|
||||||
Subproject commit 6410af8044e7346e06f546dc04636b631fa7584c
|
Subproject commit b288a56a2d6577c247b80ebd213599482aa17d20
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit 3f7cf22f4270dcdf6baa5c74dd00673b2b4ffc9e
|
Subproject commit ba8ebcc06dbc5847210e10928725e8254e47a1d9
|
Loading…
Reference in a new issue