From dfec491a7177e1e9763d20d97f3d2a17f173c794 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 29 Mar 2024 19:28:52 +0100 Subject: Use custom https ssl context for auto updater (#1317) --- gradle/libs.versions.toml | 2 +- .../skyhanni/config/features/dev/DebugConfig.java | 5 ++++ .../skyhanni/features/misc/update/UpdateManager.kt | 28 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 99aad1330..652e4fb07 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -libautoupdate = "1.0.3" +libautoupdate = "1.3.1" moulconfig = "2.5.0" headlessLwjgl = "1.7.2" jbAnnotations = "24.1.0" diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java index 480d2955e..97d378e2d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java @@ -97,6 +97,11 @@ public class DebugConfig { @ConfigEditorBoolean public boolean hotSwapDetection = false; + @Expose + @ConfigOption(name = "Always Outdated", desc = "For the sake of the auto updater, act like you are always oudated.") + @ConfigEditorBoolean + public boolean alwaysOutdated = false; + @Expose @ConfigOption(name = "SkyHanni Event Counter", desc = "Count once per second how many skyhanni events gets triggered, " + "show the total amount in console output.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt index 53a7db0f3..f064ac574 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt @@ -7,17 +7,21 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.LorenzLogger +import com.google.gson.JsonElement import io.github.moulberry.moulconfig.processor.MoulConfigProcessor +import io.github.moulberry.notenoughupdates.util.ApiUtil import io.github.moulberry.notenoughupdates.util.MinecraftExecutor import moe.nea.libautoupdate.CurrentVersion import moe.nea.libautoupdate.PotentialUpdate import moe.nea.libautoupdate.UpdateContext import moe.nea.libautoupdate.UpdateSource import moe.nea.libautoupdate.UpdateTarget +import moe.nea.libautoupdate.UpdateUtils import net.minecraft.client.Minecraft import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.concurrent.CompletableFuture +import javax.net.ssl.HttpsURLConnection object UpdateManager { @@ -129,12 +133,34 @@ object UpdateManager { private val context = UpdateContext( UpdateSource.githubUpdateSource("hannibal002", "SkyHanni"), UpdateTarget.deleteAndSaveInTheSameFolder(UpdateManager::class.java), - CurrentVersion.ofTag(SkyHanniMod.version), + object : CurrentVersion { + val normalDelegate = CurrentVersion.ofTag(SkyHanniMod.version) + override fun display(): String { + if (SkyHanniMod.feature.dev.debug.alwaysOutdated) + return "Force Outdated" + return normalDelegate.display() + } + + override fun isOlderThan(element: JsonElement): Boolean { + if (SkyHanniMod.feature.dev.debug.alwaysOutdated) + return true + return normalDelegate.isOlderThan(element) + } + + override fun toString(): String { + return "ForceOutdateDelegate($normalDelegate)" + } + }, SkyHanniMod.MODID, ) init { context.cleanup() + UpdateUtils.patchConnection { + if (it is HttpsURLConnection) { + ApiUtil.patchHttpsRequest(it) + } + } } enum class UpdateState { -- cgit