diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java b/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java index 6228e0d6..a1b204e5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java @@ -3,6 +3,7 @@ import com.google.gson.JsonElement; import pro.gravit.launcher.Launcher; import pro.gravit.launchserver.helper.HttpHelper; +import pro.gravit.utils.helper.IOHelper; import java.io.IOException; import java.lang.reflect.Type; @@ -28,6 +29,7 @@ public HttpRequest get(String url, String token) { .uri(new URI(url)) .header("Content-Type", "application/json; charset=UTF-8") .header("Accept", "application/json") + .header("User-Agent", IOHelper.USER_AGENT) .timeout(Duration.ofMillis(10000)); if (token != null) { requestBuilder.header("Authorization", "Bearer ".concat(token)); @@ -45,6 +47,7 @@ public HttpRequest post(String url, T request, String token) { .uri(new URI(url)) .header("Content-Type", "application/json; charset=UTF-8") .header("Accept", "application/json") + .header("User-Agent", IOHelper.USER_AGENT) .timeout(Duration.ofMillis(10000)); if (token != null) { requestBuilder.header("Authorization", "Bearer ".concat(token)); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/JsonPasswordVerifier.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/JsonPasswordVerifier.java index 339b8447..7932c62c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/JsonPasswordVerifier.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/JsonPasswordVerifier.java @@ -3,6 +3,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import pro.gravit.launcher.Launcher; +import pro.gravit.utils.helper.IOHelper; import java.io.InputStream; import java.io.InputStreamReader; @@ -32,6 +33,7 @@ public static R jsonRequest(T request, String url, String bearerToken, Cl .uri(new URI(url)) .header("Content-Type", "application/json; charset=UTF-8") .header("Accept", "application/json") + .header("User-Agent", IOHelper.USER_AGENT) .timeout(Duration.ofMillis(10000)); if (bearerToken != null) { request1.header("Authorization", "Bearer ".concat(bearerToken)); diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java b/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java index f7ff77fa..bb8e46b8 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/AsyncDownloader.java @@ -59,6 +59,7 @@ public static SSLContext makeSSLContext() throws NoSuchAlgorithmException, Certi public void downloadFile(URL url, Path target, long size) throws IOException { if (isClosed) throw new IOException("Download interrupted"); URLConnection connection = url.openConnection(); + connection.addRequestProperty("User-Agent", IOHelper.USER_AGENT); if (isCertificatePinning) { HttpsURLConnection connection1 = (HttpsURLConnection) connection; try { @@ -74,6 +75,7 @@ public void downloadFile(URL url, Path target, long size) throws IOException { public void downloadFile(URL url, Path target) throws IOException { URLConnection connection = url.openConnection(); + connection.addRequestProperty("User-Agent", IOHelper.USER_AGENT); if (isCertificatePinning) { HttpsURLConnection connection1 = (HttpsURLConnection) connection; try { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java index aed442fb..308e1d37 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java @@ -234,6 +234,7 @@ public static HttpURLConnection newConnectionPost(URL url) throws IOException { HttpURLConnection connection = (HttpURLConnection) newConnection(url); connection.setDoOutput(true); connection.setRequestMethod("POST"); + connection.addRequestProperty("User-Agent", IOHelper.USER_AGENT); return connection; } diff --git a/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java b/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java index b57e765f..47eda0ac 100644 --- a/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java +++ b/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java @@ -150,7 +150,7 @@ protected HttpRequest makeHttpRequest(URI baseUri, String filePath) throws URISy return HttpRequest.newBuilder() .GET() .uri(new URI(scheme, host, path + filePath, "", "")) - .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36") + .header("User-Agent", IOHelper.USER_AGENT) .build(); }