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) --- .../skyhanni/features/misc/update/UpdateManager.kt | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') 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