-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthlib-injector.patch
More file actions
95 lines (84 loc) · 4.13 KB
/
authlib-injector.patch
File metadata and controls
95 lines (84 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
diff --git a/src/main/java/org/to2mbn/authlibinjector/AuthlibInjector.java b/src/main/java/org/to2mbn/authlibinjector/AuthlibInjector.java
index 78ac323..06555d2 100644
--- a/src/main/java/org/to2mbn/authlibinjector/AuthlibInjector.java
+++ b/src/main/java/org/to2mbn/authlibinjector/AuthlibInjector.java
@@ -45,36 +44,23 @@ public final class AuthlibInjector {
transformerRegistry.accept(createTransformer(optionalConfig.get()));
} else {
info("no config available");
+ System.exit(1);
}
}
private static Optional<YggdrasilConfiguration> configure() {
- String apiRoot = System.getProperty("org.to2mbn.authlibinjector.config");
+ String apiRoot = System.getProperty("nide8auth.uuid");
if (apiRoot == null) return empty();
- info("api root: {0}", apiRoot);
+ apiRoot = "https://auth2.nide8.com:233/" + apiRoot + "/";
+ info("\u6b63\u5728\u4ece\u670d\u52a1\u5668\u83b7\u53d6\u901a\u884c\u8bc1\u914d\u7f6e\u4fe1\u606f: {0}", apiRoot);
String metadataResponse;
- String prefetched = System.getProperty("org.to2mbn.authlibinjector.config.prefetched");
- if (prefetched == null) {
- info("fetching metadata");
- try {
- metadataResponse = asString(getURL(apiRoot));
- } catch (IOException e) {
- info("unable to fetch metadata: {0}", e);
- throw new UncheckedIOException(e);
- }
-
- } else {
- info("prefetched metadata detected");
- try {
- metadataResponse = new String(Base64.getDecoder().decode(removeNewLines(prefetched)), UTF_8);
- } catch (IllegalArgumentException e) {
- info("unable to decode metadata: {0}\n"
- + "metadata to decode:\n"
- + "{1}", e, prefetched);
- throw e;
- }
+ try {
+ metadataResponse = asString(getURL(apiRoot));
+ } catch (IOException e) {
+ info("\u65e0\u6cd5\u4ece\u670d\u52a1\u5668\u83b7\u53d6\u901a\u884c\u8bc1\u914d\u7f6e\u4fe1\u606f: {0}", e);
+ throw new UncheckedIOException(e);
}
debug("metadata: {0}", metadataResponse);
diff --git a/src/main/java/org/to2mbn/authlibinjector/YggdrasilConfiguration.java b/src/main/java/org/to2mbn/authlibinjector/YggdrasilConfiguration.java
index 0e9c663..59d5728 100644
--- a/src/main/java/org/to2mbn/authlibinjector/YggdrasilConfiguration.java
+++ b/src/main/java/org/to2mbn/authlibinjector/YggdrasilConfiguration.java
@@ -40,6 +40,10 @@ public class YggdrasilConfiguration {
.map(JsonUtils::asString)
.map(KeyUtils::parseSignaturePublicKey);
+ apiRoot = ofNullable(response.get("apiRoot"))
+ .map(JsonUtils::asString)
+ .orElse(apiRoot);
+
Map<String, Object> meta =
ofNullable(response.get("meta"))
.map(it -> (Map<String, Object>) new TreeMap<>(asObject(it)))
diff --git a/src/main/java/org/to2mbn/authlibinjector/javaagent/AuthlibInjectorPremain.java b/src/main/java/org/to2mbn/authlibinjector/javaagent/AuthlibInjectorPremain.java
index fea56f6..47e6a2f 100644
--- a/src/main/java/org/to2mbn/authlibinjector/javaagent/AuthlibInjectorPremain.java
+++ b/src/main/java/org/to2mbn/authlibinjector/javaagent/AuthlibInjectorPremain.java
@@ -50,7 +50,7 @@ public class AuthlibInjectorPremain {
private static void setupConfig(String arg) {
if (arg != null && !arg.isEmpty()) {
- System.setProperty("org.to2mbn.authlibinjector.config", arg);
+ System.setProperty("nide8auth.uuid", arg);
}
}
diff --git a/src/main/java/org/to2mbn/authlibinjector/util/LoggingUtils.java b/src/main/java/org/to2mbn/authlibinjector/util/LoggingUtils.java
index d92e4e0..11c5be8 100644
--- a/src/main/java/org/to2mbn/authlibinjector/util/LoggingUtils.java
+++ b/src/main/java/org/to2mbn/authlibinjector/util/LoggingUtils.java
@@ -4,10 +4,10 @@ import java.text.MessageFormat;
public final class LoggingUtils {
- private static boolean debug = "true".equals(System.getProperty("org.to2mbn.authlibinjector.debug"));
+ private static boolean debug = "true".equals(System.getProperty("nide8auth.debug"));
public static void info(String message, Object... args) {
- System.err.println("[authlib-injector] " + MessageFormat.format(message, args));
+ System.err.println("[\u7edf\u4e00\u901a\u884c\u8bc1] " + MessageFormat.format(message, args));
}
public static void debug(String message, Object... args) {