diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-27 02:25:50 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-27 02:25:50 +0900 |
commit | bd6d9e260916648d28f21b034d910c81d2c226fa (patch) | |
tree | c662540085efacd2e77abaa80e484011cb825054 | |
parent | 85680da71fabcbd5179eab1b9e4698b3aa92722c (diff) | |
download | Skyblock-Dungeons-Guide-bd6d9e260916648d28f21b034d910c81d2c226fa.tar.gz Skyblock-Dungeons-Guide-bd6d9e260916648d28f21b034d910c81d2c226fa.tar.bz2 Skyblock-Dungeons-Guide-bd6d9e260916648d28f21b034d910c81d2c226fa.zip |
- Proper User Agent
Signed-off-by: syeyoung <cyoung06@naver.com>
8 files changed, 23 insertions, 12 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java index d1abadca..c1041192 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java @@ -22,6 +22,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.MinecraftSessionService; import kr.syeyoung.dungeonsguide.launcher.LetsEncrypt; +import kr.syeyoung.dungeonsguide.launcher.LoaderMeta; import kr.syeyoung.dungeonsguide.launcher.Main; import kr.syeyoung.dungeonsguide.launcher.auth.token.AuthToken; import kr.syeyoung.dungeonsguide.launcher.auth.token.DGAuthToken; @@ -101,7 +102,7 @@ public class DgAuthUtil { HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/auth/v2/requestAuth").openConnection(); connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); connection.setRequestProperty("Content-Type", "application/json"); connection.setConnectTimeout(1000); connection.setReadTimeout(3000); @@ -153,7 +154,7 @@ public class DgAuthUtil { HttpsURLConnection urlConnection = (HttpsURLConnection) new URL(Main.DOMAIN + "/auth/v2/authenticate").openConnection(); urlConnection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); urlConnection.setRequestMethod("POST"); - urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + urlConnection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setConnectTimeout(1000); urlConnection.setReadTimeout(3000); @@ -180,7 +181,7 @@ public class DgAuthUtil { HttpsURLConnection urlConnection = (HttpsURLConnection) new URL(Main.DOMAIN + "/auth/v2/acceptPrivacyPolicy").openConnection(); urlConnection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); urlConnection.setRequestMethod("POST"); - urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + urlConnection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setConnectTimeout(1000); urlConnection.setReadTimeout(3000); diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java index ef282f1e..f335dc38 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.launcher.branch; import kr.syeyoung.dungeonsguide.launcher.LetsEncrypt; +import kr.syeyoung.dungeonsguide.launcher.LoaderMeta; import kr.syeyoung.dungeonsguide.launcher.Main; import kr.syeyoung.dungeonsguide.launcher.auth.AuthManager; import kr.syeyoung.dungeonsguide.launcher.exceptions.AssetNotFoundException; @@ -51,7 +52,7 @@ public class UpdateRetrieverUtil { public static List<UpdateBranch> getUpdateBranches() throws IOException { HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/").openConnection(); connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setRequestMethod("GET"); connection.setConnectTimeout(1000); @@ -83,7 +84,7 @@ public class UpdateRetrieverUtil { public static List<Update> getLatestUpdates(long branchId, int page) throws IOException { HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/?page="+page).openConnection(); connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); connection.setRequestMethod("GET"); connection.setConnectTimeout(1000); connection.setReadTimeout(3000); @@ -126,7 +127,7 @@ public class UpdateRetrieverUtil { public static Update getUpdate(long branchId, long updateId) throws IOException { HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/"+updateId).openConnection(); connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setRequestMethod("GET"); connection.setConnectTimeout(1000); @@ -169,7 +170,7 @@ public class UpdateRetrieverUtil { try { HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/" + update.getBranchId() + "/" + update.getId() + "/" + asset.getAssetId()).openConnection(); connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); connection.setRequestMethod("GET"); connection.setRequestProperty("Authorization", "Bearer " + AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setDoInput(true); @@ -189,7 +190,7 @@ public class UpdateRetrieverUtil { try { connection = (HttpsURLConnection) new URL(url).openConnection(); connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); connection.setConnectTimeout(1000); connection.setReadTimeout(5000); connection.setRequestMethod(method); diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java index 1ac4556b..bbc82c62 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicy.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.launcher.gui.screen; import kr.syeyoung.dungeonsguide.launcher.LetsEncrypt; +import kr.syeyoung.dungeonsguide.launcher.LoaderMeta; import kr.syeyoung.dungeonsguide.launcher.Main; import kr.syeyoung.dungeonsguide.launcher.auth.AuthManager; import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute; @@ -78,7 +79,7 @@ public class WidgetPrivacyPolicy extends AnnotatedImportOnlyWidget { try { HttpsURLConnection urlConnection = (HttpsURLConnection) new URL(Main.POLICY).openConnection(); urlConnection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); - urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + urlConnection.setRequestProperty("User-Agent", "DungeonsGuideLoader/"+ LoaderMeta.LOADER_VERSION); urlConnection.setConnectTimeout(1000); urlConnection.setReadTimeout(3000); urlConnection.setRequestMethod("GET"); diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/guiv2/elements/image/ImageTexture.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/guiv2/elements/image/ImageTexture.java index 79ca20c9..999f5006 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/guiv2/elements/image/ImageTexture.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/guiv2/elements/image/ImageTexture.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.launcher.guiv2.elements.image; +import kr.syeyoung.dungeonsguide.launcher.LoaderMeta; import lombok.Data; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -75,7 +76,7 @@ public class ImageTexture { URL urlObj = new URL(url); HttpURLConnection huc = (HttpURLConnection) urlObj.openConnection(); - huc.addRequestProperty("User-Agent", "DungeonsGuideMod (dungeons.guide, 1.0)"); + huc.addRequestProperty("User-Agent", "DungeonsGuideLoader (dungeons.guide, "+ LoaderMeta.LOADER_VERSION +")"); ImageInputStream imageInputStream = ImageIO.createImageInputStream(huc.getInputStream()); Iterator<ImageReader> readers = ImageIO.getImageReaders(imageInputStream); if(!readers.hasNext()) throw new IOException("No image reader what" + url); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java index cbc8be12..010530f6 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/api/ApiFetcher.java @@ -25,6 +25,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile; import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfileParser; import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; @@ -80,6 +81,7 @@ public class ApiFetcher { public static JsonObject getJson(String url) throws IOException { URLConnection connection = new URL(url).openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); @@ -89,6 +91,7 @@ public class ApiFetcher { public static JsonArray getJsonArr(String url) throws IOException { URLConnection connection = new URL(url).openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); return gson.fromJson(new InputStreamReader(connection.getInputStream()), JsonArray.class); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java index 4db364d0..d16a8ab5 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/image/ImageTexture.java @@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.mod.guiv2.elements.image; import com.google.common.util.concurrent.ThreadFactoryBuilder; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import lombok.Data; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -77,7 +78,7 @@ public class ImageTexture { URL urlObj = new URL(url); HttpURLConnection huc = (HttpURLConnection) urlObj.openConnection(); - huc.addRequestProperty("User-Agent", "DungeonsGuideMod (dungeons.guide, 1.0)"); + huc.addRequestProperty("User-Agent", "DungeonsGuide (dungeons.guide, "+ VersionInfo.VERSION +")"); ImageInputStream imageInputStream = ImageIO.createImageInputStream(huc.getInputStream()); Iterator<ImageReader> readers = ImageIO.getImageReaders(imageInputStream); if(!readers.hasNext()) throw new IOException("No image reader what" + url); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java index 4de6b258..02160bb1 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/stomp/StompClient.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.mod.stomp; import com.google.common.util.concurrent.ThreadFactoryBuilder; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import lombok.Getter; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; @@ -43,6 +44,7 @@ public class StompClient extends WebSocketClient { addHeader("Authorization", token); + addHeader("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); logger.info("connecting websocket"); if (!connectBlocking()) { diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java index 2a10ba7e..61151c33 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/utils/SkyblockUtils.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.mod.utils; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import kr.syeyoung.dungeonsguide.mod.VersionInfo; import java.io.IOException; import java.io.InputStreamReader; @@ -31,7 +32,7 @@ public class SkyblockUtils { URL url = new URL("https://hypixel-api.inventivetalent.org/api/skyblock/calendar"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); - connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/"+ VersionInfo.VERSION); InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream()); JsonObject object = (JsonObject) new JsonParser().parse(inputStreamReader); if (!object.get("success").getAsBoolean()) { |