-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from Polyfrost/develop-v0
- Loading branch information
Showing
9 changed files
with
129 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
versions/src/main/java/cc/polyfrost/oneconfig/internal/hacks/SkyClientUpdaterHack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is part of OneConfig. | ||
* OneConfig - Next Generation Config Library for Minecraft: Java Edition | ||
* Copyright (C) 2021~2023 Polyfrost. | ||
* <https://polyfrost.cc> <https://github.com/Polyfrost/> | ||
* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* OneConfig is licensed under the terms of version 3 of the GNU Lesser | ||
* General Public License as published by the Free Software Foundation, AND | ||
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost, | ||
* either version 1.0 of the Additional Terms, or (at your option) any later | ||
* version. | ||
* | ||
* This program 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. If not, see <https://www.gnu.org/licenses/>. You should | ||
* have also received a copy of the Additional Terms Applicable | ||
* to OneConfig, as published by Polyfrost. If not, see | ||
* <https://polyfrost.cc/legal/oneconfig/additional-terms> | ||
*/ | ||
|
||
package cc.polyfrost.oneconfig.internal.hacks; | ||
|
||
import cc.polyfrost.oneconfig.internal.OneConfig; | ||
|
||
import javax.net.ssl.KeyManagerFactory; | ||
import javax.net.ssl.SSLContext; | ||
import javax.net.ssl.TrustManagerFactory; | ||
import java.security.KeyStore; | ||
|
||
public class SkyClientUpdaterHack { | ||
public static final SkyClientUpdaterHack INSTANCE = new SkyClientUpdaterHack(); | ||
|
||
public SSLContext getSSLContext() { | ||
try { | ||
KeyStore keystore = KeyStore.getInstance("JKS"); | ||
keystore.load(SkyClientUpdaterHack.class.getResourceAsStream("/polyfrost_backup.jks"), "changeit".toCharArray()); | ||
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); | ||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); | ||
kmf.init(keystore, null); | ||
tmf.init(keystore); | ||
SSLContext ctx = SSLContext.getInstance("TLS"); | ||
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); | ||
return ctx; | ||
} catch (Exception e) { | ||
OneConfig.LOGGER.warn("Failed to load keystore. Web requests may fail on older Java versions", e); | ||
return null; | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/SkyClientUpdaterMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* This file is part of OneConfig. | ||
* OneConfig - Next Generation Config Library for Minecraft: Java Edition | ||
* Copyright (C) 2021~2023 Polyfrost. | ||
* <https://polyfrost.cc> <https://github.com/Polyfrost/> | ||
* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* OneConfig is licensed under the terms of version 3 of the GNU Lesser | ||
* General Public License as published by the Free Software Foundation, AND | ||
* under the Additional Terms Applicable to OneConfig, as published by Polyfrost, | ||
* either version 1.0 of the Additional Terms, or (at your option) any later | ||
* version. | ||
* | ||
* This program 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. If not, see <https://www.gnu.org/licenses/>. You should | ||
* have also received a copy of the Additional Terms Applicable | ||
* to OneConfig, as published by Polyfrost. If not, see | ||
* <https://polyfrost.cc/legal/oneconfig/additional-terms> | ||
*/ | ||
|
||
package cc.polyfrost.oneconfig.internal.mixin; | ||
|
||
import cc.polyfrost.oneconfig.internal.hacks.SkyClientUpdaterHack; | ||
import org.spongepowered.asm.mixin.Dynamic; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import javax.net.ssl.HttpsURLConnection; | ||
import java.io.InputStream; | ||
|
||
@Pseudo | ||
@Mixin(targets = "mynameisjeff.skyblockclientupdater.UpdateChecker", remap = false) | ||
public class SkyClientUpdaterMixin { | ||
|
||
@Unique private HttpsURLConnection oneconfig$connection; | ||
|
||
@Dynamic("SCC 1.3.6 or below. If this doesn't apply, Minecraft should still work fine.") | ||
@Redirect(method = "setupConnection", at = @At(value = "INVOKE", target = "Lkotlin/jvm/internal/Intrinsics;checkNotNull(Ljava/lang/Object;Ljava/lang/String;)V")) | ||
private void fixSSLOnOlderSCC(Object connection, String error) { | ||
this.oneconfig$connection = (HttpsURLConnection) connection; | ||
} | ||
|
||
@Dynamic("SCC 1.3.6 or below. If this doesn't apply, Minecraft should still work fine.") | ||
@Inject(method = "setupConnection", at = @At(value = "INVOKE", target = "Ljavax/net/ssl/HttpsURLConnection;getInputStream()Ljava/io/InputStream;")) | ||
private void fixSSLOnOlderSCC(String url, CallbackInfoReturnable<InputStream> cir) { | ||
if (this.oneconfig$connection != null) { | ||
this.oneconfig$connection.setSSLSocketFactory(SkyClientUpdaterHack.INSTANCE.getSSLContext().getSocketFactory()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.