From 5603bfb94e59c2f9163907c8c214c92ce3bb7ded Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 6 Dec 2018 15:28:25 +0100 Subject: [PATCH] Use a proper user agent for downloading --- src/de/mas/wiiu/jnus/Settings.java | 1 + src/de/mas/wiiu/jnus/utils/download/Downloader.java | 2 ++ src/de/mas/wiiu/jnus/utils/download/NUSDownloadService.java | 1 + 3 files changed, 4 insertions(+) diff --git a/src/de/mas/wiiu/jnus/Settings.java b/src/de/mas/wiiu/jnus/Settings.java index 82f4132..2573a9d 100644 --- a/src/de/mas/wiiu/jnus/Settings.java +++ b/src/de/mas/wiiu/jnus/Settings.java @@ -28,6 +28,7 @@ public class Settings { public static final String WUD_KEY_FILENAME = "game.key"; public static final String WOOMY_METADATA_FILENAME = "metadata.xml"; public static final String H3_EXTENTION = ".h3"; + public static final String USER_AGENT = "Mozilla/5.0 (Nintendo WiiU) AppleWebKit/536.28 (KHTML, like Gecko) NX/3.0.3.12.12 NintendoBrowser/3.0.0.9561.US"; public static byte[] commonKey = new byte[0x10]; public static int WIIU_DECRYPTED_AREA_OFFSET = 0x18000; diff --git a/src/de/mas/wiiu/jnus/utils/download/Downloader.java b/src/de/mas/wiiu/jnus/utils/download/Downloader.java index e9898db..8b6a93f 100644 --- a/src/de/mas/wiiu/jnus/utils/download/Downloader.java +++ b/src/de/mas/wiiu/jnus/utils/download/Downloader.java @@ -21,6 +21,7 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; +import de.mas.wiiu.jnus.Settings; import lombok.extern.java.Log; @Log @@ -33,6 +34,7 @@ public abstract class Downloader { int BUFFER_SIZE = 0x800; URL url = new URL(fileURL); HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); + httpConn.setRequestProperty("User-Agent", Settings.USER_AGENT); int responseCode = httpConn.getResponseCode(); byte[] file = null; diff --git a/src/de/mas/wiiu/jnus/utils/download/NUSDownloadService.java b/src/de/mas/wiiu/jnus/utils/download/NUSDownloadService.java index 0567158..aa0f769 100644 --- a/src/de/mas/wiiu/jnus/utils/download/NUSDownloadService.java +++ b/src/de/mas/wiiu/jnus/utils/download/NUSDownloadService.java @@ -85,6 +85,7 @@ public final class NUSDownloadService extends Downloader { public InputStream getInputStream(String URL, long offset) throws IOException { URL url_obj = new URL(URL); HttpURLConnection connection = (HttpURLConnection) url_obj.openConnection(); + connection.setRequestProperty("User-Agent", Settings.USER_AGENT); connection.setRequestProperty("Range", "bytes=" + offset + "-"); try { connection.connect();