From d845b73c85102c48a2b5df04515975c98d1023b6 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 4 Nov 2018 11:35:42 +0700 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BD=D0=B5=20=D1=83=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BF=D1=80=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=20=D0=BF=D1=80=D0=B8=20=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/auth/AuthResponse.java | 25 +++++++++++-------- .../texture/RequestTextureProvider.java | 2 +- .../launcher/request/auth/AuthRequest.java | 4 ++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java index bffafd67..3c30a6ae 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java @@ -40,7 +40,10 @@ public AuthResponse(LaunchServer server, long session, HInput input, HOutput out @Override public void reply() throws Exception { String login = input.readString(SerializeLimits.MAX_LOGIN); - String client = input.readString(SerializeLimits.MAX_CLIENT); + boolean isClient = input.readBoolean(); + String client = null; + if(isClient) + client = input.readString(SerializeLimits.MAX_CLIENT); int auth_id = input.readInt(); long hwid_hdd = input.readLong(); long hwid_cpu = input.readLong(); @@ -73,17 +76,19 @@ public void reply() throws Exception { AuthProvider.authError(String.format("Illegal result: '%s'", result.username)); return; } - Collection> profiles = server.getProfiles(); - for (SignedObjectHolder p : profiles) { - if (p.object.getTitle().equals(client)) { - if (!p.object.isWhitelistContains(login)) { - throw new AuthException(server.config.whitelistRejectString); + if(isClient) { + Collection> profiles = server.getProfiles(); + for (SignedObjectHolder p : profiles) { + if (p.object.getTitle().equals(client)) { + if (!p.object.isWhitelistContains(login)) { + throw new AuthException(server.config.whitelistRejectString); + } + clientData.profile = p.object; } - clientData.profile = p.object; } - } - if(clientData.profile == null) { - throw new AuthException("You profile not found"); + if (clientData.profile == null) { + throw new AuthException("You profile not found"); + } } server.config.hwidHandler.check(HWID.gen(hwid_hdd, hwid_bios, hwid_cpu), result.username); } catch (AuthException | HWIDException e) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java index 386a7149..face508f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java @@ -28,7 +28,7 @@ private static Texture getTexture(String url, boolean cloak) throws IOException private static String getTextureURL(String url, UUID uuid, String username, String client) { return CommonHelper.replace(url, "username", IOHelper.urlEncode(username), "uuid", IOHelper.urlEncode(uuid.toString()), "hash", IOHelper.urlEncode(Launcher.toHash(uuid)), - "client", IOHelper.urlEncode(client)); + "client", IOHelper.urlEncode(client == null ? "unknown" : client)); } // Instance diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java index 339ea99c..0af81609 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java @@ -67,7 +67,9 @@ public Integer getType() { @Override protected Result requestDo(HInput input, HOutput output) throws IOException { output.writeString(login, SerializeLimits.MAX_LOGIN); - output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); + output.writeBoolean(Launcher.profile != null); + if(Launcher.profile != null) + output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); output.writeInt(auth_id); output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetHddId() : 0); output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetCpuid() : 0);