diff options
author | syeyoung <cyoung06@naver.com> | 2022-12-15 13:40:03 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2022-12-15 13:40:03 +0900 |
commit | bf56c97637e14df058ac52f270af530b85574be0 (patch) | |
tree | 94a58f6d5c78bde2c6252452ce9f953e47289c42 /loader/src/main/java/kr/syeyoung | |
parent | 1e5e7b1071b7e6c75f9dd26b716d14c5065fe282 (diff) | |
download | Skyblock-Dungeons-Guide-bf56c97637e14df058ac52f270af530b85574be0.tar.gz Skyblock-Dungeons-Guide-bf56c97637e14df058ac52f270af530b85574be0.tar.bz2 Skyblock-Dungeons-Guide-bf56c97637e14df058ac52f270af530b85574be0.zip |
- timeouts
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src/main/java/kr/syeyoung')
4 files changed, 52 insertions, 25 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java index b5d76566..4cb4d1a2 100755 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java @@ -53,7 +53,7 @@ public class Main { public static final String MOD_ID = "dungeons_guide_wrapper"; public static final String VERSION = "1.0"; - public static final String DOMAIN = "http://testmachine2/api"; + public static final String DOMAIN = "https://v2.dungeons.guide/api"; private static Main main; diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java index 4db06318..4f378f18 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java @@ -130,6 +130,7 @@ public class AuthManager { .title("Auth Error") .description("Authentication Error Occured\n"+e.getMessage()) .titleColor(0xFFFF0000) + .unremovable(true) .onClick(() -> { GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); }) @@ -152,6 +153,7 @@ public class AuthManager { if (currentToken instanceof PrivacyPolicyRequiredToken) { reauthLock = true; + NotificationManager.INSTANCE.removeNotification(authenticationFailure); NotificationManager.INSTANCE.removeNotification(privacyPolicyRequired); try { currentToken = DgAuthUtil.acceptNewPrivacyPolicy(currentToken.getToken(), version); @@ -173,6 +175,7 @@ public class AuthManager { .title("Auth Error") .description("Authentication Error Occured\n"+e.getMessage()) .titleColor(0xFFFF0000) + .unremovable(true) .onClick(() -> { GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); }) 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 033427bd..fd9a6c01 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 @@ -77,8 +77,10 @@ public class DgAuthUtil { GameProfile profile = Minecraft.getMinecraft().getSession().getProfile(); HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/auth/v2/requestAuth").openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestProperty("Content-Type", "application/json"); + connection.setConnectTimeout(1000); + connection.setReadTimeout(3000); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setDoOutput(true); @@ -126,8 +128,10 @@ public class DgAuthUtil { public static AuthToken verifyAuth(String tempToken, byte[] encSecret) throws IOException { HttpURLConnection urlConnection = (HttpURLConnection) new URL(Main.DOMAIN + "/auth/v2/authenticate").openConnection(); urlConnection.setRequestMethod("POST"); - urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); urlConnection.setRequestProperty("Content-Type", "application/json"); + urlConnection.setConnectTimeout(1000); + urlConnection.setReadTimeout(3000); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); @@ -150,8 +154,10 @@ public class DgAuthUtil { public static AuthToken acceptNewPrivacyPolicy(String tempToken, long version) throws IOException { HttpURLConnection urlConnection = (HttpURLConnection) new URL(Main.DOMAIN + "/auth/v2/acceptPrivacyPolicy").openConnection(); urlConnection.setRequestMethod("POST"); - urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); urlConnection.setRequestProperty("Content-Type", "application/json"); + urlConnection.setConnectTimeout(1000); + urlConnection.setReadTimeout(3000); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); 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 9db6c8bc..6539ee5c 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 @@ -30,9 +30,11 @@ public class UpdateRetrieverUtil { public static List<UpdateBranch> getUpdateBranches() throws IOException { HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/").openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setRequestMethod("GET"); + connection.setConnectTimeout(1000); + connection.setReadTimeout(3000); connection.setDoInput(true); connection.setDoOutput(true); @@ -56,8 +58,10 @@ public class UpdateRetrieverUtil { public static List<Update> getLatestUpdates(long branchId, int page) throws IOException { HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/?page="+page).openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestMethod("GET"); + connection.setConnectTimeout(1000); + connection.setReadTimeout(3000); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setDoInput(true); connection.setDoOutput(true); @@ -96,9 +100,11 @@ public class UpdateRetrieverUtil { public static Update getUpdate(long branchId, long updateId) throws IOException { HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/"+updateId).openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); + connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setRequestMethod("GET"); + connection.setConnectTimeout(1000); + connection.setReadTimeout(3000); connection.setDoInput(true); connection.setDoOutput(true); @@ -134,26 +140,38 @@ public class UpdateRetrieverUtil { .findFirst().orElseThrow(() -> new AssetNotFoundException(update.getBranchId()+"", update.getId()+"("+update.getName()+")", assetName)); - HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/"+update.getBranchId()+"/"+update.getId()+"/"+asset.getAssetId()).openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - connection.setRequestMethod("GET"); - connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); - connection.setDoInput(true); - connection.setDoOutput(true); - - String payload = getResponse(connection); - String url, method; try { - JSONObject result = new JSONObject(payload); - url = result.getString("url"); - method = result.getString("method"); - } catch (Exception e) { - throw new ResponseParsingException(payload, e); + HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/" + update.getBranchId() + "/" + update.getId() + "/" + asset.getAssetId()).openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setRequestMethod("GET"); + connection.setRequestProperty("Authorization", "Bearer " + AuthManager.getInstance().getWorkingTokenOrThrow()); + connection.setDoInput(true); + connection.setConnectTimeout(1000); + connection.setReadTimeout(3000); + connection.setDoOutput(true); + + String payload = getResponse(connection); + String url, method; + try { + JSONObject result = new JSONObject(payload); + url = result.getString("url"); + method = result.getString("method"); + } catch (Exception e) { + throw new ResponseParsingException(payload, e); + } + try { + connection = (HttpURLConnection) new URL(url).openConnection(); + connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); + connection.setConnectTimeout(1000); + connection.setReadTimeout(5000); + connection.setRequestMethod(method); + return connection.getInputStream(); + } catch (IOException e) { + throw new RuntimeException("Error occured while downloading update asset from "+method+" "+url, e); + } + } catch (IOException e) { + throw new RuntimeException("Error occured while downloading update asset "+update+"/"+assetName, e); } - connection = (HttpURLConnection) new URL(url).openConnection(); - connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); - connection.setRequestMethod(method); - return connection.getInputStream(); } @Data @Builder |