diff --git a/LaunchServer/source/LaunchServer.java b/LaunchServer/source/LaunchServer.java index 44fe876..1143803 100644 --- a/LaunchServer/source/LaunchServer.java +++ b/LaunchServer/source/LaunchServer.java @@ -61,7 +61,7 @@ @LauncherAPI public final Path configFile; @LauncherAPI - public final Path ipConfigFile; + public final Path ipConfigPath; @LauncherAPI public final Path publicKeyFile; @LauncherAPI @@ -111,7 +111,7 @@ // Setup config locations this.dir = dir; configFile = dir.resolve("LaunchServer.cfg"); - ipConfigFile = dir.resolve("ListIpConnection.json"); + ipConfigPath = dir.resolve("ListIpConnection.json"); publicKeyFile = dir.resolve("public.key"); privateKeyFile = dir.resolve("private.key"); updatesDir = dir.resolve("updates"); @@ -183,7 +183,7 @@ LogHelper.info("Reading IP Connection List file"); try { - AuthLimiterIPConfig.load(ipConfigFile); + AuthLimiterIPConfig.load(ipConfigPath); } catch (Exception error) { diff --git a/LaunchServer/source/auth/limiter/AuthLimiterIPConfig.java b/LaunchServer/source/auth/limiter/AuthLimiterIPConfig.java index 091de45..83692d0 100644 --- a/LaunchServer/source/auth/limiter/AuthLimiterIPConfig.java +++ b/LaunchServer/source/auth/limiter/AuthLimiterIPConfig.java @@ -15,9 +15,9 @@ public class AuthLimiterIPConfig { - public static Path ipConfigFile; + public static Path ipConfigPath; public static Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); - public static AuthLimiterIPConfig Instance; // С этим сами разбирайтесь) + public static AuthLimiterIPConfig Instance; @Expose List allowIp = new ArrayList<>(); @@ -25,12 +25,12 @@ List blockIp = new ArrayList<>(); public static void load(Path file) throws Exception { - ipConfigFile = file; - if (IOHelper.exists(ipConfigFile)) { + ipConfigPath = file; + if (IOHelper.exists(ipConfigPath)) { LogHelper.subDebug("IP List file found! Loading..."); try { - Instance = gson.fromJson(IOHelper.newReader(ipConfigFile), AuthLimiterIPConfig.class); + Instance = gson.fromJson(IOHelper.newReader(ipConfigPath), AuthLimiterIPConfig.class); return; } catch (JsonIOException | IOException error) { @@ -50,7 +50,13 @@ public void saveIPConfig() throws Exception { - gson.toJson(this, IOHelper.newWriter(ipConfigFile)); + File ipConfigFile = ipConfigPath.toFile(); + if (!ipConfigFile.exists()) ipConfigFile.createNewFile(); + + FileWriter fw = new FileWriter(ipConfigFile, false); + fw.write(gson.toJson(this)); + fw.close(); + //gson.toJson(this, IOHelper.newWriter(ipConfigPath)); } public List getAllowIp() { diff --git a/buildnumber b/buildnumber index 81de09f..67f665c 100644 --- a/buildnumber +++ b/buildnumber @@ -1 +1 @@ -570, 29.10.2021 \ No newline at end of file +571, 29.10.2021 \ No newline at end of file