mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-12 09:37:36 +00:00
feat: Shadowable deploader
This commit is contained in:
23 files changed
+2169
-1135
No files matched your search
@@ -23,6 +23,7 @@ package com.falsepattern.lib.dependencies;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -36,6 +37,16 @@ public class ComplexVersion extends Version {
|
||||
System.arraycopy(subVersions, 0, this.versions, 1, subVersions.length);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ComplexVersion(Version[] versions) {
|
||||
this.versions = versions;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Version[] versionsRaw() {
|
||||
return this.versions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull Version o) {
|
||||
if (o instanceof ComplexVersion) {
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.falsepattern.lib.internal;
|
||||
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Internet {
|
||||
private static final Map<String, String> NO_HEADERS = Collections.emptyMap();
|
||||
|
||||
public static void connect(URL URL, Consumer<Exception> onError, Consumer<InputStream> onSuccess, Consumer<Long> contentLengthCallback) {
|
||||
connect(URL, NO_HEADERS, onError, onSuccess, contentLengthCallback);
|
||||
}
|
||||
|
||||
public static void connect(URL URL, Map<String, String> headers, Consumer<Exception> onError, Consumer<InputStream> onSuccess, Consumer<Long> contentLengthCallback) {
|
||||
try {
|
||||
val urlConnection = URL.openConnection();
|
||||
if (urlConnection instanceof HttpURLConnection) {
|
||||
connectHTTP((HttpURLConnection) urlConnection, headers, onError, onSuccess, contentLengthCallback);
|
||||
} else {
|
||||
executeTransfer(urlConnection, onSuccess, contentLengthCallback);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//Check if NonUpdate is present
|
||||
try {
|
||||
if (Launch.classLoader.getClassBytes("moe.mickey.forge.nonupdate.NonUpdate") != null) {
|
||||
e.addSuppressed(new Exception(
|
||||
"NonUpdate is present, it's possible that it's blocking a library download."
|
||||
+ " Please disable it for a single run to allow mod dependencies to download."));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
e.addSuppressed(ex);
|
||||
}
|
||||
onError.accept(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void connectHTTP(HttpURLConnection connection, Map<String, String> headers, Consumer<Exception> onError, Consumer<InputStream> onSuccess, Consumer<Long> contentLengthCallback) throws IOException {
|
||||
connection.setConnectTimeout(3500);
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setRequestProperty("User-Agent",
|
||||
Tags.MODNAME
|
||||
+ " "
|
||||
+ Tags.VERSION
|
||||
+ " Internet Connector"
|
||||
+ " (https://github.com/FalsePattern/FalsePatternLib)");
|
||||
for (val header : headers.entrySet()) {
|
||||
val key = header.getKey();
|
||||
val value = header.getValue();
|
||||
if (key == null || value == null) {
|
||||
throw new IllegalArgumentException("Null key or value");
|
||||
}
|
||||
if (key.isEmpty()) {
|
||||
throw new IllegalArgumentException("Empty key");
|
||||
}
|
||||
connection.setRequestProperty(key, value);
|
||||
}
|
||||
if (connection.getResponseCode() != 200) {
|
||||
onError.accept(new Exception("HTTP response code " + connection.getResponseCode()));
|
||||
} else {
|
||||
executeTransfer(connection, onSuccess, contentLengthCallback);
|
||||
}
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
private static void executeTransfer(URLConnection connection, Consumer<InputStream> onSuccess, Consumer<Long> contentLengthCallback) throws IOException {
|
||||
contentLengthCallback.accept(connection.getContentLengthLong());
|
||||
onSuccess.accept(connection.getInputStream());
|
||||
}
|
||||
|
||||
public static void transferAndClose(InputStream is, OutputStream target, Consumer<Integer> downloadSizeCallback)
|
||||
throws IOException {
|
||||
var bytesRead = 0;
|
||||
|
||||
byte[] smallBuffer = new byte[256 * 1024];
|
||||
while ((bytesRead = is.read(smallBuffer)) >= 0) {
|
||||
target.write(smallBuffer, 0, bytesRead);
|
||||
downloadSizeCallback.accept(bytesRead);
|
||||
}
|
||||
target.close();
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,11 @@
|
||||
|
||||
package com.falsepattern.lib.internal;
|
||||
|
||||
import com.falsepattern.lib.internal.asm.PreShare;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class Share {
|
||||
public static final boolean DEV_ENV = PreShare.devEnv();
|
||||
public static final boolean CLIENT = PreShare.client();
|
||||
|
||||
public static boolean EARLY_INIT_DONE = false;
|
||||
}
|
||||
@@ -21,10 +21,9 @@
|
||||
*/
|
||||
package com.falsepattern.lib.internal.asm;
|
||||
|
||||
import com.falsepattern.deploader.Stub;
|
||||
import com.falsepattern.lib.internal.FPLog;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import com.falsepattern.lib.internal.impl.dependencies.DependencyLoaderImpl;
|
||||
import com.falsepattern.lib.internal.impl.dependencies.LetsEncryptHelper;
|
||||
import com.falsepattern.lib.internal.logging.CrashImprover;
|
||||
import com.falsepattern.lib.internal.logging.NotEnoughVerbosity;
|
||||
import com.falsepattern.lib.mapping.MappingManager;
|
||||
@@ -36,12 +35,10 @@ import lombok.val;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -58,9 +55,7 @@ public class CoreLoadingPlugin implements IFMLLoadingPlugin {
|
||||
private static boolean obfuscated;
|
||||
|
||||
static {
|
||||
PreShare.initDevState(Launch.classLoader.findResource("net/minecraft/world/World.class") != null);
|
||||
PreShare.initClientState(FMLLaunchHandler.side() == Side.CLIENT);
|
||||
LetsEncryptHelper.replaceSSLContext();
|
||||
Stub.bootstrap(false);
|
||||
FPLog.LOG.info("Removing skill issues...");
|
||||
try {
|
||||
Class.forName("thermos.Thermos");
|
||||
@@ -71,7 +66,7 @@ public class CoreLoadingPlugin implements IFMLLoadingPlugin {
|
||||
//Scan for dependencies now
|
||||
FPLog.LOG.info("Scanning for deps...");
|
||||
long start = System.nanoTime();
|
||||
DependencyLoaderImpl.executeDependencyLoading();
|
||||
Stub.runDepLoader();
|
||||
long end = System.nanoTime();
|
||||
FPLog.LOG.info("Scanned in " + (end - start) / 1000000 + "ms");
|
||||
//Initializing the rest
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.falsepattern.lib.internal.asm;
|
||||
|
||||
public class PreShare {
|
||||
private static volatile int devEnv = -1;
|
||||
private static volatile int client = -1;
|
||||
public static synchronized void initDevState(boolean state) {
|
||||
if (devEnv >= 0) {
|
||||
return;
|
||||
}
|
||||
devEnv = state ? 1 : 0;
|
||||
}
|
||||
public static synchronized void initClientState(boolean state) {
|
||||
if (client >= 0) {
|
||||
return;
|
||||
}
|
||||
client = state ? 1 : 0;
|
||||
}
|
||||
|
||||
public static synchronized boolean devEnv() {
|
||||
return devEnv == 1;
|
||||
}
|
||||
|
||||
public static synchronized boolean client() {
|
||||
return client == 1;
|
||||
}
|
||||
}
|
||||
@@ -22,15 +22,11 @@
|
||||
|
||||
package com.falsepattern.lib.internal.asm;
|
||||
|
||||
import com.falsepattern.lib.internal.core.LowLevelCallMultiplexer;
|
||||
import com.falsepattern.lib.internal.impl.dependencies.DependencyLoaderImpl;
|
||||
import com.falsepattern.lib.internal.impl.dependencies.LetsEncryptHelper;
|
||||
import com.falsepattern.deploader.Stub;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.RfbApiImpl;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbPlugin;
|
||||
import lombok.val;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
public class RFBLoadingPlugin implements RfbPlugin {
|
||||
static {
|
||||
val loader = RfbApiImpl.INSTANCE.launchClassLoader();
|
||||
@@ -47,11 +43,7 @@ public class RFBLoadingPlugin implements RfbPlugin {
|
||||
exc.invoke(loader, "com.falsepattern.lib.internal.config.EarlyConfig");
|
||||
exc.invoke(loader, "com.falsepattern.lib.internal.core.LowLevelCallMultiplexer");
|
||||
} catch (Exception ignored) {}
|
||||
PreShare.initDevState(((URLClassLoader)loader).findResource("net/minecraft/world/World.class") != null);
|
||||
PreShare.initClientState(((URLClassLoader)loader).findResource("net/minecraft/client/Minecraft.class") != null ||
|
||||
((URLClassLoader)loader).findResource("bao.class") != null);
|
||||
LetsEncryptHelper.replaceSSLContext();
|
||||
LowLevelCallMultiplexer.rfbDetected();
|
||||
DependencyLoaderImpl.executeDependencyLoading();
|
||||
Stub.bootstrap(true);
|
||||
Stub.runDepLoader();
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import com.falsepattern.lib.internal.core.LowLevelCallMultiplexer;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.val;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
//For stuff that runs before FML does
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
public class EarlyConfig {
|
||||
@Expose
|
||||
private boolean enableLibraryDownloads;
|
||||
|
||||
@Expose
|
||||
private boolean enableLetsEncryptRoot;
|
||||
|
||||
private static volatile EarlyConfig instance = null;
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(Tags.MODNAME + " Early Config");
|
||||
|
||||
public static @NotNull EarlyConfig getInstance() {
|
||||
val config = instance;
|
||||
if (config != null)
|
||||
return config;
|
||||
return loadFromDisk();
|
||||
}
|
||||
|
||||
private static synchronized @NotNull EarlyConfig loadFromDisk() {
|
||||
var config = instance;
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
val configDir = LowLevelCallMultiplexer.gameDir().resolve("config");
|
||||
val configFile = configDir.resolve("falsepatternlib-early.json");
|
||||
val gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
try {
|
||||
if (!Files.exists(configDir)) {
|
||||
Files.createDirectories(configDir);
|
||||
}
|
||||
if (Files.exists(configFile)) {
|
||||
config = gson.fromJson(new String(Files.readAllBytes(configFile), StandardCharsets.UTF_8),
|
||||
EarlyConfig.class);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to load from disk", e);
|
||||
}
|
||||
if (config == null) {
|
||||
config = new EarlyConfig();
|
||||
config.enableLibraryDownloads(true);
|
||||
config.enableLetsEncryptRoot(true);
|
||||
try {
|
||||
Files.write(configFile, gson.toJson(config).getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to write to disk", e);
|
||||
}
|
||||
}
|
||||
instance = config;
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.falsepattern.lib.internal.core;
|
||||
|
||||
import com.gtnewhorizons.retrofuturabootstrap.RfbApiImpl;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@UtilityClass
|
||||
public class LowLevelCallMultiplexer {
|
||||
private static boolean rfbDetected = false;
|
||||
public static void rfbDetected() {
|
||||
rfbDetected = true;
|
||||
}
|
||||
|
||||
public static void addURLToClassPath(URL url) {
|
||||
if (rfbDetected) {
|
||||
RFBLowLevel.addURLToClassPath(url);
|
||||
} else {
|
||||
LaunchWrapperLowLevel.addURLToClassPath(url);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<URL> getClassPathSources() {
|
||||
if (rfbDetected) {
|
||||
return RFBLowLevel.getClassPathSources();
|
||||
} else {
|
||||
return LaunchWrapperLowLevel.getClassPathSources();
|
||||
}
|
||||
}
|
||||
|
||||
public static @NotNull Path gameDir() {
|
||||
if (rfbDetected) {
|
||||
return RFBLowLevel.gameDir();
|
||||
} else {
|
||||
return LaunchWrapperLowLevel.gameDir();
|
||||
}
|
||||
}
|
||||
|
||||
public static int javaMajorVersion() {
|
||||
if (rfbDetected) {
|
||||
return RFBLowLevel.javaMajorVersion();
|
||||
} else {
|
||||
return LaunchWrapperLowLevel.javaMajorVersion();
|
||||
}
|
||||
}
|
||||
|
||||
//Separate classes to avoid accidental classloading
|
||||
|
||||
private static class RFBLowLevel {
|
||||
static void addURLToClassPath(URL url) {
|
||||
RfbApiImpl.INSTANCE.launchClassLoader().addURL(url);
|
||||
}
|
||||
|
||||
static List<URL> getClassPathSources() {
|
||||
return Arrays.asList(((URLClassLoader)RfbApiImpl.INSTANCE.launchClassLoader()).getURLs());
|
||||
}
|
||||
|
||||
static @NotNull Path gameDir() {
|
||||
return RfbApiImpl.INSTANCE.gameDirectory();
|
||||
}
|
||||
|
||||
static int javaMajorVersion() {
|
||||
return RfbApiImpl.INSTANCE.javaMajorVersion();
|
||||
}
|
||||
}
|
||||
|
||||
private static class LaunchWrapperLowLevel {
|
||||
static void addURLToClassPath(URL url) {
|
||||
Launch.classLoader.addURL(url);
|
||||
}
|
||||
|
||||
static List<URL> getClassPathSources() {
|
||||
return Launch.classLoader.getSources();
|
||||
}
|
||||
|
||||
static @NotNull Path gameDir() {
|
||||
return Launch.minecraftHome == null ? Paths.get(".") : Launch.minecraftHome.toPath();
|
||||
}
|
||||
|
||||
static int javaMajorVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) {
|
||||
version = version.substring(2, 3);
|
||||
} else {
|
||||
int dot = version.indexOf(".");
|
||||
if(dot != -1) { version = version.substring(0, dot); }
|
||||
}
|
||||
return Integer.parseInt(version);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.falsepattern.lib.internal.impl.dependencies;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
public class DepRoot {
|
||||
private String source;
|
||||
@Expose
|
||||
private Integer minJava;
|
||||
@Expose
|
||||
private Integer maxJava;
|
||||
@Expose
|
||||
private List<String> bundledArtifacts;
|
||||
@Expose
|
||||
private List<String> repositories;
|
||||
@Expose
|
||||
private Dependencies dependencies;
|
||||
@Expose
|
||||
private Dependencies modDependencies;
|
||||
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
public static class Dependencies {
|
||||
@Expose
|
||||
private SidedDependencies always;
|
||||
@Expose
|
||||
private SidedDependencies obf;
|
||||
@Expose
|
||||
private SidedDependencies dev;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
public static class SidedDependencies {
|
||||
@Expose
|
||||
private List<String> common;
|
||||
@Expose
|
||||
private List<String> client;
|
||||
@Expose
|
||||
private List<String> server;
|
||||
}
|
||||
}
|
||||
+64
-1077
File diff suppressed because it is too large.
Load diff
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.falsepattern.lib.internal.impl.dependencies;
|
||||
|
||||
import com.falsepattern.lib.internal.FPLog;
|
||||
import com.falsepattern.lib.internal.config.EarlyConfig;
|
||||
import lombok.val;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.CertificateFactory;
|
||||
|
||||
/**
|
||||
* Add Let's Encrypt root certificates to the default SSLContext.
|
||||
* CurseForge launcher uses the vanilla JDK for 1.7.10, which is version 8u51.
|
||||
* This version does not include these certificates, support for ISRG Root X1 was added in 8u141.
|
||||
* Based on <a href="https://github.com/Cloudhunter/LetsEncryptCraft/blob/2471391f7d081a8b7faed9e22051cab6352966fe/src/main/java/uk/co/cloudhunter/letsencryptcraft/LetsEncryptAdder.java">LetsEncryptCraft</a> by Cloudhunter (MIT)
|
||||
*/
|
||||
public class LetsEncryptHelper {
|
||||
private static volatile boolean patched = false;
|
||||
private LetsEncryptHelper() {}
|
||||
@SuppressWarnings("java:S6437")
|
||||
public static void replaceSSLContext() {
|
||||
if (!EarlyConfig.getInstance().enableLetsEncryptRoot()) {
|
||||
FPLog.LOG.info("[LetsEncryptHelper] Disabled by config");
|
||||
return;
|
||||
}
|
||||
if (patched) {
|
||||
FPLog.LOG.info("[LetsEncryptHelper] Already patched");
|
||||
return;
|
||||
}
|
||||
FPLog.LOG.info("[LetsEncryptHelper] Starting patcher");
|
||||
patched = true;
|
||||
|
||||
try (val x1 = LetsEncryptHelper.class.getResourceAsStream("/letsencrypt/isrgrootx1.pem");
|
||||
val x2 = LetsEncryptHelper.class.getResourceAsStream("/letsencrypt/isrg-root-x2.pem")) {
|
||||
val merged = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
val cacerts = Paths.get(System.getProperty("java.home"),"lib", "security", "cacerts");
|
||||
merged.load(Files.newInputStream(cacerts), "changeit".toCharArray());
|
||||
|
||||
val cf = CertificateFactory.getInstance("X.509");
|
||||
|
||||
val cx1 = cf.generateCertificate(x1);
|
||||
merged.setCertificateEntry("archaicfix-isrgx1", cx1);
|
||||
|
||||
val cx2 = cf.generateCertificate(x2);
|
||||
merged.setCertificateEntry("archaicfix-isrgx2", cx2);
|
||||
|
||||
val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(merged);
|
||||
val sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
SSLContext.setDefault(sslContext);
|
||||
FPLog.LOG.info("[LetsEncryptHelper] Added certificates to trust store.");
|
||||
} catch (IOException e) {
|
||||
FPLog.LOG.error("[LetsEncryptHelper] Failed to load certificates from classpath.", e);
|
||||
} catch (GeneralSecurityException e) {
|
||||
FPLog.LOG.error("[LetsEncryptHelper] Failed to load default keystore.", e);
|
||||
} catch (Throwable t) {
|
||||
FPLog.LOG.error("[LetsEncryptHelper] Unknown error", t);
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.falsepattern.lib.internal.impl.dependencies;
|
||||
|
||||
public class Pair<A, B> {
|
||||
public final A a;
|
||||
public final B b;
|
||||
|
||||
public Pair(A a, B b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user