Skip to content

Commit 4db8fd3

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents f0f42dc + d9e10fc commit 4db8fd3

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Agent/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
base {
2+
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
3+
}
4+
15
dependencies {
26
include "org.ow2.asm:asm:9.7.1"
37
include "org.ow2.asm:asm-tree:9.7.1"

Agent/src/main/java/net/lenni0451/authhook/Agent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public static void premain(final String args, final Instrumentation instrumentat
1616
private static void hook(final Instrumentation instrumentation) {
1717
try {
1818
Map<String, String> config = Config.load();
19+
if (config.get(Config.SECRET_KEY).contains(" ")) {
20+
System.err.println("Please set a valid secret key in the auth_hook.properties file");
21+
System.err.println("It is automatically generated by ViaProxy if you have the AuthHook plugin installed");
22+
System.exit(-1);
23+
}
24+
1925
instrumentation.addTransformer(new URLRedirector(config), true);
2026
} catch (Throwable t) {
2127
System.err.println("An error occurred while starting AuthHook");

Agent/src/main/java/net/lenni0451/authhook/URLRedirector.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
3838
boolean modified = false;
3939
for (MethodNode method : node.methods) {
4040
for (AbstractInsnNode insn : method.instructions) {
41-
if (insn instanceof LdcInsnNode ldc && ldc.cst instanceof String str) {
41+
if (insn instanceof LdcInsnNode && ((LdcInsnNode) insn).cst instanceof String) {
42+
LdcInsnNode ldc = (LdcInsnNode) insn;
43+
String str = (String) ldc.cst;
4244
if (str.startsWith(URL)) {
4345
str = str.substring(URL.length());
4446
str = this.targetAddress + "/" + this.secretKey + str;

0 commit comments

Comments
 (0)