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,55 +100,58 @@ 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()) {
|
for (Object o : cn.methods.toArray()) {
|
||||||
MethodNode m = (MethodNode) o;
|
MethodNode m = (MethodNode) o;
|
||||||
if(m.name.equals("exec")) {
|
if (m.name.equals("exec")) {
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
m.instructions.insert(new InsnNode(ARETURN));
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
m.instructions.insert(new InsnNode(ACONST_NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
cn.accept(cw);
|
cn.accept(cw);
|
||||||
return cw.toByteArray();
|
return cw.toByteArray();
|
||||||
} else if (className.equals("java.lang.ProcessBuilder")) {
|
}
|
||||||
ClassReader cr=new ClassReader(classBytes);
|
case "java.lang.ProcessBuilder": {
|
||||||
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()) {
|
for (Object o : cn.methods.toArray()) {
|
||||||
MethodNode m = (MethodNode) o;
|
MethodNode m = (MethodNode) o;
|
||||||
if(m.name.equals("start")) {
|
if (m.name.equals("start")) {
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
m.instructions.insert(new InsnNode(ARETURN));
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
m.instructions.insert(new InsnNode(ACONST_NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
cn.accept(cw);
|
cn.accept(cw);
|
||||||
return cw.toByteArray();
|
return cw.toByteArray();
|
||||||
} else if (className.equals("java.awt.Robot")) {
|
}
|
||||||
ClassReader cr=new ClassReader(classBytes);
|
case "java.awt.Robot": {
|
||||||
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()) {
|
for (Object o : cn.methods.toArray()) {
|
||||||
MethodNode m = (MethodNode) o;
|
MethodNode m = (MethodNode) o;
|
||||||
if( m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
|
if (m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
|
||||||
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
|
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
|
||||||
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
|
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
|
||||||
m.name.equals("mouseWheel"))
|
m.name.equals("mouseWheel")) {
|
||||||
{
|
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
m.instructions.insert(new InsnNode(ARETURN));
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
m.instructions.insert(new InsnNode(ACONST_NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClassWriter cw=new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
cn.accept(cw);
|
cn.accept(cw);
|
||||||
return cw.toByteArray();
|
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