From 9b3b6633d374010c82473c55228e93b03c07ac4c Mon Sep 17 00:00:00 2001 From: Fugi Date: Tue, 9 Jun 2020 18:29:28 -0700 Subject: [PATCH] Handle token in URL, report build version --- src/main/java/mdnet/base/ServerHandler.java | 2 ++ src/main/kotlin/mdnet/base/Application.kt | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/mdnet/base/ServerHandler.java b/src/main/java/mdnet/base/ServerHandler.java index afa2fcb..a6a3e00 100644 --- a/src/main/java/mdnet/base/ServerHandler.java +++ b/src/main/java/mdnet/base/ServerHandler.java @@ -41,6 +41,7 @@ public class ServerHandler { params.put("secret", settings.getClientSecret()); params.put("port", settings.getClientPort()); params.put("disk_space", settings.getMaxCacheSizeMib() * 1024 * 1024 /* MiB to bytes */); + params.put("build_version", Constants.CLIENT_BUILD); HttpResponse response = Unirest.post(SERVER_ADDRESS + "ping") .header("Content-Type", "application/json").body(new JSONObject(params)).asObject(ServerSettings.class); @@ -63,6 +64,7 @@ public class ServerHandler { params.put("secret", settings.getClientSecret()); params.put("port", settings.getClientPort()); params.put("disk_space", settings.getMaxCacheSizeMib() * 1024 * 1024 /* MiB to bytes */); + params.put("build_version", Constants.CLIENT_BUILD); params.put("tls_created_at", old.getTls().getCreatedAt()); HttpResponse response = Unirest.post(SERVER_ADDRESS + "ping") diff --git a/src/main/kotlin/mdnet/base/Application.kt b/src/main/kotlin/mdnet/base/Application.kt index f314710..4fb3094 100644 --- a/src/main/kotlin/mdnet/base/Application.kt +++ b/src/main/kotlin/mdnet/base/Application.kt @@ -209,7 +209,9 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting .then( routes( "/data/{chapterHash}/{fileName}" bind Method.GET to app(false), - "/data-saver/{chapterHash}/{fileName}" bind Method.GET to app(true) + "/data-saver/{chapterHash}/{fileName}" bind Method.GET to app(true), + "/{token}/data/{chapterHash}/{fileName}" bind Method.GET to app(false), + "/{token}/data-saver/{chapterHash}/{fileName}" bind Method.GET to app(true) ) ) .asServer(Netty(serverSettings.tls, clientSettings, statistics)) @@ -228,7 +230,7 @@ private fun addCommonHeaders(): Filter { { request: Request -> val response = next(request) response.header("Date", HTTP_TIME_FORMATTER.format(ZonedDateTime.now(ZoneOffset.UTC))) - .header("Server", "Mangadex@Home Node") + .header("Server", "Mangadex@Home Node ${Constants.CLIENT_VERSION} (${Constants.CLIENT_BUILD})") } } }