diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index 6ee77c5b..7fb92075 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import com.google.gson.Gson; @@ -24,21 +25,21 @@ public final class JsonHWIDHandler extends HWIDHandler { private URL urlGet; public class banRequest { - public banRequest(String hwid) { + public banRequest(OshiHWID hwid) { this.hwid = hwid; } - String hwid; + OshiHWID hwid; } public class checkRequest { - public checkRequest(String username, String hwid) { + public checkRequest(String username, OshiHWID hwid) { this.username = username; this.hwid = hwid; } String username; - String hwid; + OshiHWID hwid; } @@ -51,10 +52,6 @@ public class BannedResult { String error; } - public class HWIDResult { - String string; - } - public class HWIDRequest { public HWIDRequest(String username) { this.username = username; @@ -66,7 +63,7 @@ public HWIDRequest(String username) { @Override public void ban(List l_hwid) throws HWIDException { for (HWID hwid : l_hwid) { - banRequest request = new banRequest(hwid.getSerializeString()); + banRequest request = new banRequest((OshiHWID) hwid); try { JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlBan); Result r = gson.fromJson(result, Result.class); @@ -80,9 +77,9 @@ public void ban(List l_hwid) throws HWIDException { @Override public void check0(HWID hwid, String username) throws HWIDException { - checkRequest request = new checkRequest(username, hwid.getSerializeString()); + checkRequest request = new checkRequest(username, (OshiHWID) hwid); try { - JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlBan); + JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), url); BannedResult r = gson.fromJson(result, BannedResult.class); if (r.error != null) throw new HWIDException(r.error); boolean isBanned = r.isBanned; @@ -103,11 +100,9 @@ public List getHwid(String username) throws HWIDException { ArrayList hwids = new ArrayList<>(); HWIDRequest request = new HWIDRequest(username); try { - JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlBan); - HWIDResult[] r = gson.fromJson(result, HWIDResult[].class); - for (HWIDResult hw : r) { - hwids.add(OshiHWID.gson.fromJson(hw.string, OshiHWID.class)); - } + JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlGet); + OshiHWID[] r = gson.fromJson(result, OshiHWID[].class); + hwids.addAll(Arrays.asList(r)); } catch (IOException e) { LogHelper.error(e); throw new HWIDException("HWID service error"); @@ -118,7 +113,7 @@ public List getHwid(String username) throws HWIDException { @Override public void unban(List l_hwid) throws HWIDException { for (HWID hwid : l_hwid) { - banRequest request = new banRequest(hwid.getSerializeString()); + banRequest request = new banRequest((OshiHWID) hwid); try { JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlUnBan); Result r = gson.fromJson(result, Result.class); diff --git a/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java b/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java index 149b2af8..868de75c 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java +++ b/libLauncher/src/main/java/ru/gravit/utils/HTTPRequest.java @@ -14,7 +14,7 @@ import java.nio.charset.StandardCharsets; public class HTTPRequest { - private static final int TIMEOUT = 10; + private static final int TIMEOUT = 10000; private static final JsonParser parser = new JsonParser(); public static int sendCrashreport(String strurl, byte[] data) throws IOException {