diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-23 17:56:38 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-09-23 17:56:38 +0800 |
commit | a38700b5ae8822f159c7457d4d67e53f75ca63fa (patch) | |
tree | 13097a8f1a5e1e3b71a0948f9b876e6ec3d1c600 /src | |
parent | 644a192508dba2719c24ecd3c0b3295120b0fbb5 (diff) | |
download | SoopyV2-a38700b5ae8822f159c7457d4d67e53f75ca63fa.tar.gz SoopyV2-a38700b5ae8822f159c7457d4d67e53f75ca63fa.tar.bz2 SoopyV2-a38700b5ae8822f159c7457d4d67e53f75ca63fa.zip |
Support lets encript prepairing for hypixel api change
Diffstat (limited to 'src')
-rw-r--r-- | src/featureClass/featureManager.js | 4 | ||||
-rw-r--r-- | src/features/changeLogGUI/index.js | 4 | ||||
-rw-r--r-- | src/features/cosmetics/cosmetic/dragon/dragonWings.js | 2 | ||||
-rw-r--r-- | src/features/cosmetics/index.js | 2 | ||||
-rw-r--r-- | src/features/dataLoader/index.js | 4 | ||||
-rw-r--r-- | src/features/dungeonSolvers/index.js | 2 | ||||
-rw-r--r-- | src/features/globalSettings/index.js | 14 | ||||
-rw-r--r-- | src/features/guild/index.js | 4 | ||||
-rw-r--r-- | src/features/networthGUI/index.js | 10 | ||||
-rw-r--r-- | src/features/settings/helpDataLoader.js | 23 | ||||
-rw-r--r-- | src/features/settings/settingThings/settingBase.js | 12 | ||||
-rw-r--r-- | src/features/spamHider/index.js | 2 | ||||
-rw-r--r-- | src/features/statHistoryGui/index.js | 6 | ||||
-rw-r--r-- | src/features/streamsGUI/index.js | 2 | ||||
-rw-r--r-- | src/features/suggestionsGui/index.js | 12 | ||||
-rw-r--r-- | src/utils/certs/ISRGRootX1.cer | bin | 0 -> 1391 bytes | |||
-rw-r--r-- | src/utils/letsEncryptCerts.js | 32 | ||||
-rw-r--r-- | src/utils/networkUtils.js | 6 |
18 files changed, 88 insertions, 53 deletions
diff --git a/src/featureClass/featureManager.js b/src/featureClass/featureManager.js index f80e6d6..30e7525 100644 --- a/src/featureClass/featureManager.js +++ b/src/featureClass/featureManager.js @@ -81,7 +81,7 @@ class FeatureManager { this.featureSettingsData = {} - let fetchD = fetch("http://soopy.dev/api/soopyv2/ping") + let fetchD = fetch("https://soopy.dev/api/soopyv2/ping") fetchD.load().then(() => { if (fetchD.responseCode() >= 400 || fetchD.responseCode() === -1) { ChatLib.chat(this.messagePrefix + "&cError: Could not connect to Soopy's server. This may cause issues with some features but will (hopefully) be back soon.") @@ -238,7 +238,7 @@ class FeatureManager { } reportLagData(data) { - return fetch("http://soopy.dev/soopy/submitlag", { postData: data }).textSync() + return fetch("https://soopy.dev/soopy/submitlag", { postData: data }).textSync() } loadSoopyLag() { diff --git a/src/features/changeLogGUI/index.js b/src/features/changeLogGUI/index.js index 47634f7..d346afc 100644 --- a/src/features/changeLogGUI/index.js +++ b/src/features/changeLogGUI/index.js @@ -136,7 +136,7 @@ class ChangelogPage extends GuiPage { } async loadChangeLog() { - let data = await fetch("http://soopy.dev/api/soopyv2/changelog.json").json() + let data = await fetch("https://soopy.dev/api/soopyv2/changelog.json").json() this.changelogData = data.changelog.reverse() @@ -175,7 +175,7 @@ class ChangelogPage extends GuiPage { this.progressBar.setProgress(0.1) - this.urlToFile("http://soopy.dev/api/soopyv2/downloadLatest.zip", "./config/ChatTriggers/modules/SoopyAddonsTempDownload/SoopyAddons.zip", 10000, 20000) + this.urlToFile("https://soopy.dev/api/soopyv2/downloadLatest.zip", "./config/ChatTriggers/modules/SoopyAddonsTempDownload/SoopyAddons.zip", 10000, 20000) this.progressBar.setProgress(0.5) diff --git a/src/features/cosmetics/cosmetic/dragon/dragonWings.js b/src/features/cosmetics/cosmetic/dragon/dragonWings.js index 944ba78..fbe67e4 100644 --- a/src/features/cosmetics/cosmetic/dragon/dragonWings.js +++ b/src/features/cosmetics/cosmetic/dragon/dragonWings.js @@ -20,7 +20,7 @@ let loadingTextures = new Set() function loadTexture(id) { new Thread(() => { loadingTextures.add(id) - textures.set(id, renderLibs.getImage("http://soopy.dev/api/soopyv2/textures/cosmetic/dragon/" + id + "/img.png", true)) + textures.set(id, renderLibs.getImage("https://soopy.dev/api/soopyv2/textures/cosmetic/dragon/" + id + "/img.png", true)) }).start() } loadTexture("classic") diff --git a/src/features/cosmetics/index.js b/src/features/cosmetics/index.js index 97dcf3e..7073869 100644 --- a/src/features/cosmetics/index.js +++ b/src/features/cosmetics/index.js @@ -83,7 +83,7 @@ class Cosmetics extends Feature { } async loadCosmeticsData() { - let data = await fetch("http://soopy.dev/api/soopyv2/cosmetics.json").json() + let data = await fetch("https://soopy.dev/api/soopyv2/cosmetics.json").json() this.cosmeticsData = data this.playerHasACosmeticA = !!data[Player.getUUID().toString().replace(/-/g, "")] diff --git a/src/features/dataLoader/index.js b/src/features/dataLoader/index.js index fd72648..4745d85 100644 --- a/src/features/dataLoader/index.js +++ b/src/features/dataLoader/index.js @@ -124,7 +124,7 @@ class DataLoader extends Feature { } async step_5min() { - let data = await fetch("http://soopy.dev/api/v2/mayor").json() + let data = await fetch("https://soopy.dev/api/v2/mayor").json() if (!data.success) return this.mayorData = data.data @@ -142,7 +142,7 @@ class DataLoader extends Feature { this.loadApiData("skyblock", false) } async loadApi() { - let data = await fetch("http://soopy.dev/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, "")).json() + let data = await fetch("https://soopy.dev/api/v2/player_skyblock/" + Player.getUUID().replace(/-/g, "")).json() if (!data.success) return diff --git a/src/features/dungeonSolvers/index.js b/src/features/dungeonSolvers/index.js index ae57736..4d4fb81 100644 --- a/src/features/dungeonSolvers/index.js +++ b/src/features/dungeonSolvers/index.js @@ -686,7 +686,7 @@ class DungeonSolvers extends Feature { if (this.scoreCalculation.getValue()) ChatLib.chat(this.FeatureManager.messagePrefix + username + " does not have spirit pet!") } } else { - let data = await fetch(`http://soopy.dev/api/v2/player_skyblock/${uuid}`).json() + let data = await fetch(`https://soopy.dev/api/v2/player_skyblock/${uuid}`).json() if (!data.success) return if (data.data.profiles[data2.data.stats.currentProfileId].members[uuid].pets.some(pet => pet.type === "SPIRIT" && pet.tier === "LEGENDARY")) { diff --git a/src/features/globalSettings/index.js b/src/features/globalSettings/index.js index 91d9583..3e9ded1 100644 --- a/src/features/globalSettings/index.js +++ b/src/features/globalSettings/index.js @@ -270,7 +270,7 @@ class GlobalSettings extends Feature { if (this.twitchCommands.getValue() && message.startsWith("-") && message[1].toLowerCase().match(/[a-z]/)) { cancel(event) ChatLib.addToSentMessageHistory(message) - fetch("http://soopy.dev/api/soopyv2/botcommand?m=" + encodeURIComponent(message.replace("-", "")) + "&u=" + Player.getName()).text().then(text => { + fetch("https://soopy.dev/api/soopyv2/botcommand?m=" + encodeURIComponent(message.replace("-", "")) + "&u=" + Player.getName()).text().then(text => { ChatLib.chat(this.FeatureManager.messagePrefix + "&7" + message) toMessageWithLinks(this.FeatureManager.messagePrefix + text, "7").chat() }) @@ -281,7 +281,7 @@ class GlobalSettings extends Feature { cancel(event) ChatLib.addToSentMessageHistory(message) - fetch("http://soopy.dev/api/soopyv2/itemup", { + fetch("https://soopy.dev/api/soopyv2/itemup", { postData: { name: Player.getHeldItem().getName(), lore: Player.getHeldItem().getLore().join("\n") @@ -305,7 +305,7 @@ class GlobalSettings extends Feature { let [_] = message.getUnformattedText().match(/\[ITEM:([0-9]+)\]/g) let id = _.replace("[ITEM:", "").replace(/\]$/g, "") - fetch("http://soopy.dev/api/soopyv2/itemdown/" + id).json().then(([name, lore]) => { + fetch("https://soopy.dev/api/soopyv2/itemdown/" + id).json().then(([name, lore]) => { for (let i = 0; i < message.getMessageParts().length; i++) { let component = message.getMessageParts()[i] @@ -371,7 +371,7 @@ class GlobalSettings extends Feature { }) this.registerCommand("price", async () => { - let json = await fetch("http://soopy.dev/api/soopyv2/itemPriceDetailed", { + let json = await fetch("https://soopy.dev/api/soopyv2/itemPriceDetailed", { postData: { item: Player.getHeldItem().getNBT().toObject() } @@ -784,7 +784,7 @@ class GlobalSettings extends Feature { this.currentPlayerOpen = uuid this.currentPlayerNetworth = {} - fetch("http://soopy.dev/api/v2/player_skyblock/" + uuid).json().then(data => { + fetch("https://soopy.dev/api/v2/player_skyblock/" + uuid).json().then(data => { if (!data.success) return if (this.currentPlayerOpen === data.data.uuid) { @@ -815,13 +815,13 @@ class GlobalSettings extends Feature { ChatLib.chat(this.FeatureManager.messagePrefix + "Finding senither weight for " + user) - let userData = await fetch("http://soopy.dev/api/v2/player/" + user).json() + let userData = await fetch("https://soopy.dev/api/v2/player/" + user).json() if (!userData.success) { ChatLib.chat(this.FeatureManager.messagePrefix + "&cError loading data: " + userData.error.description) return } - let sbData = await fetch("http://soopy.dev/api/v2/player_skyblock/" + userData.data.uuid).json() + let sbData = await fetch("https://soopy.dev/api/v2/player_skyblock/" + userData.data.uuid).json() if (!sbData.success) { ChatLib.chat(this.FeatureManager.messagePrefix + "&cError loading data: " + sbData.error.description) diff --git a/src/features/guild/index.js b/src/features/guild/index.js index 3fe0cdb..7a7307a 100644 --- a/src/features/guild/index.js +++ b/src/features/guild/index.js @@ -13,7 +13,7 @@ class Guild extends Feature { onEnable() { this.bridgeBots = new Set() - fetch("http://soopy.dev/api/soopyv2/gbots.json").json().then(bots => { + fetch("https://soopy.dev/api/soopyv2/gbots.json").json().then(bots => { bots.forEach(b => this.bridgeBots.add(b)) }) @@ -47,7 +47,7 @@ class Guild extends Feature { } else { if (msg.match(/^@(\w+?), ([\w\W]+?) \[GBot:([0-9]+)\] [,. ]+$/)) { let [_, name2, reply, gBotId] = msg.match(/^@(\w+?), ([\w\W]+?) \[GBot:([0-9]+)\] [,. ]+$/) - fetch("http://soopy.dev/api/botdown/" + gBotId).json().then(m => { + fetch("https://soopy.dev/api/botdown/" + gBotId).json().then(m => { let message = new Message(`&2B${this.shortenPrefix.getValue() ? "" : "ridge"} > &b${name2} &7⤷&f `) m.forEach(c => { diff --git a/src/features/networthGUI/index.js b/src/features/networthGUI/index.js index 3a887a3..16ab82b 100644 --- a/src/features/networthGUI/index.js +++ b/src/features/networthGUI/index.js @@ -119,7 +119,7 @@ class NetworthPage extends GuiPage { this.statArea.clearChildren() this.statArea.addChild(this.loadingElm) - let playerData = await fetch("http://soopy.dev/api/v2/player/" + player).json() + let playerData = await fetch("https://soopy.dev/api/v2/player/" + player).json() if (player !== this.playerLoad) return @@ -131,7 +131,7 @@ class NetworthPage extends GuiPage { return } - let skyblockData = await fetch("http://soopy.dev/api/v2/player_skyblock/" + playerData.data.uuid).json() + let skyblockData = await fetch("https://soopy.dev/api/v2/player_skyblock/" + playerData.data.uuid).json() if (player !== this.playerLoad) return @@ -181,7 +181,7 @@ class NetworthPage extends GuiPage { }) if (selectedProf === skyblockData.data.stats.bestProfileId) { - let leaderboardData = await fetch("http://soopy.dev/api/v2/leaderboard/networth/user/" + playerData.data.uuid).json() + let leaderboardData = await fetch("https://soopy.dev/api/v2/leaderboard/networth/user/" + playerData.data.uuid).json() if (player !== this.playerLoad) return if (leaderboardData.success) nameElm.setText("§0#" + numberWithCommas(leaderboardData.data.data.position + 1) + " " + playerData.data.stats.nameWithPrefix.replace(/§f/g, "§7")) @@ -199,7 +199,7 @@ class NetworthPage extends GuiPage { } async sidebarSearch(user) { - let data = await fetch("http://soopy.dev/api/v2/leaderboard/networth/user/" + user).json() + let data = await fetch("https://soopy.dev/api/v2/leaderboard/networth/user/" + user).json() if (!data.success) { return } @@ -218,7 +218,7 @@ class NetworthPage extends GuiPage { if (scroll) this.leaderboardArea._scrollAmount = 0 if (scroll) this.leaderboardArea.location.scroll.y.set(0, 100) - let data = await fetch("http://soopy.dev/api/v2/leaderboard/networth/" + page).json() + let data = await fetch("https://soopy.dev/api/v2/leaderboard/networth/" + page).json() this.leaderboardArea.clearChildren() data.data.data.forEach((user, i) => { this.leaderboardArea.addChild( diff --git a/src/features/settings/helpDataLoader.js b/src/features/settings/helpDataLoader.js index fc6afaf..acf4fd2 100644 --- a/src/features/settings/helpDataLoader.js +++ b/src/features/settings/helpDataLoader.js @@ -3,7 +3,7 @@ class HelpDataLoader { this.availableHelpData = {} this.dataCach = {} - fetch("http://soopy.dev/api/soopyv2/settingshelpoptions.json").json().then(data => { + fetch("https://soopy.dev/api/soopyv2/settingshelpoptions.json").json().then(data => { Object.keys(data).forEach(category => { this.availableHelpData[category] = new Set(data[category]) }); @@ -14,26 +14,23 @@ class HelpDataLoader { return this.availableHelpData[category] && this.availableHelpData[category].has(id) } - getData(category, id, callback) { + async getData(category, id) { if (!this.hasData(category, id)) { - callback("") - return + return "" } if (this.dataCach[category] && this.dataCach[category][id]) { - callback(this.dataCach[category][id]) - return + return this.dataCach[category][id] } - fetch("http://soopy.dev/api/soopyv2/settingshelp/" + category + "/" + id).text().then(data => { - if (!this.dataCach[category]) { - this.dataCach[category] = {} - } + let data = await fetch("https://soopy.dev/api/soopyv2/settingshelp/" + category + "/" + id).text() + if (!this.dataCach[category]) { + this.dataCach[category] = {} + } - this.dataCach[category][id] = data + this.dataCach[category][id] = data - callback(data) - }) + callback(data) } } diff --git a/src/features/settings/settingThings/settingBase.js b/src/features/settings/settingThings/settingBase.js index 5320f40..2346f32 100644 --- a/src/features/settings/settingThings/settingBase.js +++ b/src/features/settings/settingThings/settingBase.js @@ -30,12 +30,12 @@ class SettingBase { this.helpButton = new BoxWithText().setText("§0?").setLocation(3, 3, 0.05, 0.5) this.helpButton.location.location.setRelative(false, false) - this.helpButton.addEvent(new SoopyMouseClickEvent().setHandler(() => { + this.helpButton.addEvent(new SoopyMouseClickEvent().setHandler(async () => { module.FeatureManager.features.soopyGui.class.openSidebarPage(new SoopyGuiElement().setLocation(0.05, 0.05, 0.9, 0.9).setScrollable(true).addChild(new SoopyMarkdownElement().setLocation(0, 0, 1, 1).setText("Loading..."))) - this.getHelp(helpText => { - module.FeatureManager.features.soopyGui.class.openSidebarPage(new SoopyGuiElement().setLocation(0.05, 0.05, 0.9, 0.9).setScrollable(true).addChild(new SoopyMarkdownElement().setLocation(0, 0, 1, 1).setText(helpText))) - }) + let helpText = await this.getHelp() + + module.FeatureManager.features.soopyGui.class.openSidebarPage(new SoopyGuiElement().setLocation(0.05, 0.05, 0.9, 0.9).setScrollable(true).addChild(new SoopyMarkdownElement().setLocation(0, 0, 1, 1).setText(helpText))) })) this.helpButton.setLore(["Click for more information about this setting"]) @@ -79,8 +79,8 @@ class SettingBase { return helpDataLoader.hasData(this.moduleId, this.settingId) } - getHelp(callback) { - helpDataLoader.getData(this.moduleId, this.settingId, callback) + async getHelp() { + return await helpDataLoader.getData(this.moduleId, this.settingId) } getValue() { diff --git a/src/features/spamHider/index.js b/src/features/spamHider/index.js index c0f14d2..998c797 100644 --- a/src/features/spamHider/index.js +++ b/src/features/spamHider/index.js @@ -131,7 +131,7 @@ class SpamHider extends Feature { } async loadSpamMessages() { - let messages = await fetch("http://soopy.dev/api/soopyv2/spamHiderMessages.json").json() + let messages = await fetch("https://soopy.dev/api/soopyv2/spamHiderMessages.json").json() this.hideMessages = messages.hideMessages this.moveMessages = messages.moveMessages diff --git a/src/features/statHistoryGui/index.js b/src/features/statHistoryGui/index.js index dd620b9..ae6d843 100644 --- a/src/features/statHistoryGui/index.js +++ b/src/features/statHistoryGui/index.js @@ -91,7 +91,7 @@ class StatGraphPage extends GuiPage { this.statArea.clearChildren() this.statArea.addChild(this.loadingElm) - let playerData = await fetch("http://soopy.dev/api/v2/player/" + player).json() + let playerData = await fetch("https://soopy.dev/api/v2/player/" + player).json() if (player !== this.playerLoad) return @@ -107,7 +107,7 @@ class StatGraphPage extends GuiPage { this.statArea.addChild(nameElm) this.statArea.addChild(this.loadingElm) - let skyblockData = await fetch("http://soopy.dev/api/v2/player_skyblock/" + playerData.data.uuid).json() + let skyblockData = await fetch("https://soopy.dev/api/v2/player_skyblock/" + playerData.data.uuid).json() if (player !== this.playerLoad) return if (!skyblockData.success) { @@ -129,7 +129,7 @@ class StatGraphPage extends GuiPage { })) this.statArea.addChild(profileSelect) - fetch("http://soopy.dev/statgraphgenerations/" + playerData.data.uuid + "/" + selectedProf).json().then(graphData => { + fetch("https://soopy.dev/statgraphgenerations/" + playerData.data.uuid + "/" + selectedProf).json().then(graphData => { if (player !== this.playerLoad) return new Thread(() => { diff --git a/src/features/streamsGUI/index.js b/src/features/streamsGUI/index.js index 25cda23..5477e44 100644 --- a/src/features/streamsGUI/index.js +++ b/src/features/streamsGUI/index.js @@ -63,7 +63,7 @@ class StreamPage extends GuiPage { } async updateStreams() { - let streams = await fetch("http://soopy.dev/api/skyblockstreams").json() + let streams = await fetch("https://soopy.dev/api/skyblockstreams").json() this.streamsBox.clearChildren() let y = 0 diff --git a/src/features/suggestionsGui/index.js b/src/features/suggestionsGui/index.js index 04630ca..bb9f454 100644 --- a/src/features/suggestionsGui/index.js +++ b/src/features/suggestionsGui/index.js @@ -81,7 +81,7 @@ class SuggestionPage extends GuiPage { this.pages[0].addChild(this.suggestionsArea) - fetch("http://soopy.dev/api/soopyv2/suggestionTags.json").json().then(data => { + fetch("https://soopy.dev/api/soopyv2/suggestionTags.json").json().then(data => { this.tags = data }) @@ -89,7 +89,7 @@ class SuggestionPage extends GuiPage { } async loadSuggestionPage() { - let data = await fetch("http://soopy.dev/api/soopyv2/suggestion/new").json() + let data = await fetch("https://soopy.dev/api/soopyv2/suggestion/new").json() this.suggestionElements = {} this.suggestionsArea.clearChildren() @@ -125,7 +125,7 @@ class SuggestionPage extends GuiPage { } async loadSuggestion(id) { - let data = await fetch("http://soopy.dev/api/soopyv2/suggestion/" + id + "/user/" + Player.getUUID().toString().replace(/-/g, "")).json() + let data = await fetch("https://soopy.dev/api/soopyv2/suggestion/" + id + "/user/" + Player.getUUID().toString().replace(/-/g, "")).json() let sideBarElm = new SoopyGuiElement().setLocation(0, 0, 1, 1).setScrollable(true) if (!data.success) { sideBarElm.addChild(new SoopyTextElement().setText("§cError loading suggestion").setMaxTextScale(3).setLocation(0.5, 0.5, 0.5, 0.5)) @@ -152,13 +152,13 @@ class SuggestionPage extends GuiPage { drop.addEvent(new SoopyContentChangeEvent().setHandler((newVal) => { if (newVal === "delete") { - fetch("http://soopy.dev/api/soopyv2/suggestion/" + id + "/delete/" + this.password).load() + fetch("https://soopy.dev/api/soopyv2/suggestion/" + id + "/delete/" + this.password).load() this.loadSuggestionPage() this.closeSidebarPage() return } - fetch("http://soopy.dev/api/soopyv2/suggestion/" + id + "/status/" + newVal + "/" + this.password).load() + fetch("https://soopy.dev/api/soopyv2/suggestion/" + id + "/status/" + newVal + "/" + this.password).load() this.loadSuggestion(id) })) @@ -201,7 +201,7 @@ class SuggestionPage extends GuiPage { } voteSuggestion(id, type) { - fetch("http://soopy.dev/api/soopyv2/suggestion/" + id + "/vote/" + (type) + "/" + Player.getUUID().toString().replace(/-/g, "")).load() + fetch("https://soopy.dev/api/soopyv2/suggestion/" + id + "/vote/" + (type) + "/" + Player.getUUID().toString().replace(/-/g, "")).load() this.loadSuggestion(id) } diff --git a/src/utils/certs/ISRGRootX1.cer b/src/utils/certs/ISRGRootX1.cer Binary files differnew file mode 100644 index 0000000..9d2132e --- /dev/null +++ b/src/utils/certs/ISRGRootX1.cer diff --git a/src/utils/letsEncryptCerts.js b/src/utils/letsEncryptCerts.js new file mode 100644 index 0000000..4a639e7 --- /dev/null +++ b/src/utils/letsEncryptCerts.js @@ -0,0 +1,32 @@ +// Semisol was here +let certificates = [ + "ISRGRootX1.cer" +] // Certificate names +const + JKeyStore = Java.type("java.security.KeyStore"), + JPaths = Java.type("java.nio.file.Paths"), + JSystem = Java.type("java.lang.System"), + JFiles = Java.type("java.nio.file.Files"), + JCertificateFactory = Java.type("java.security.cert.CertificateFactory"), + JString = Java.type("java.lang.String"), + JByteArrayInputStream = Java.type("java.io.ByteArrayInputStream"), + JTrustManagerFactory = Java.type("javax.net.ssl.TrustManagerFactory"), + JSSLContext = Java.type("javax.net.ssl.SSLContext") +let keyStore = JKeyStore.getInstance(JKeyStore.getDefaultType()) +let ksPath = JPaths.get(JSystem.getProperty("java.home"), "lib", "security", "cacerts") +keyStore.load(JFiles.newInputStream(ksPath), new JString("changeit").toCharArray()) +let cf = JCertificateFactory.getInstance("X.509") +for (let i of certificates) { + let pathStr = `${Config.modulesFolder}/SoopyV2/utils/certs/${i}` + let path = JPaths.get(pathStr) + let data = JFiles.readAllBytes(path) + let cert = cf.generateCertificate(new JByteArrayInputStream(data)) + keyStore.setCertificateEntry("dev.semisol.letsencryptsupport:" + i, cert) +} +let tmf = JTrustManagerFactory.getInstance(JTrustManagerFactory.getDefaultAlgorithm()) +tmf.init(keyStore) +let sslContext = JSSLContext.getInstance("TLS") +sslContext.init(null, tmf.getTrustManagers(), null); +JSSLContext.setDefault(sslContext) +let socketFactory = sslContext.getSocketFactory() +export { socketFactory as default }; diff --git a/src/utils/networkUtils.js b/src/utils/networkUtils.js index 41d27e5..5ac95a4 100644 --- a/src/utils/networkUtils.js +++ b/src/utils/networkUtils.js @@ -1,3 +1,5 @@ +import socketFactory from "./letsEncryptCerts" + if (!global.networkUtilsThingSoopyPromise) { let jURL = Java.type("java.net.URL") @@ -6,6 +8,7 @@ if (!global.networkUtilsThingSoopyPromise) { let jBufferedReader = Java.type("java.io.BufferedReader") let jInputStreamReader = Java.type("java.io.InputStreamReader") let jString = Java.type("java.lang.String") + var JHttpsUrlConnection = Java.type('javax.net.ssl.HttpsURLConnection'); function getUrlContent(theUrl, { userAgent = "Mozilla/5.0", includeConnection = false, postData = undefined } = {}) { @@ -19,6 +22,9 @@ if (!global.networkUtilsThingSoopyPromise) { // Thread.sleep(1000) //simulating high ping let conn = new jURL(theUrl).openConnection() + if (conn instanceof JHttpsUrlConnection) { + conn.setSSLSocketFactory(socketFactory); + } conn.setRequestProperty("User-Agent", userAgent) if (postData) { |