From e0ddf6c4bf7923e91d18412e17465529c72f36b3 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 29 Apr 2024 01:01:44 +0100 Subject: [PATCH] fix --- src/main/java/cc/fascinated/piaservers/Main.java | 6 +++++- .../java/cc/fascinated/piaservers/pia/PiaManager.java | 8 +------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/fascinated/piaservers/Main.java b/src/main/java/cc/fascinated/piaservers/Main.java index bdb8e3a..1fb7e43 100644 --- a/src/main/java/cc/fascinated/piaservers/Main.java +++ b/src/main/java/cc/fascinated/piaservers/Main.java @@ -6,6 +6,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.SneakyThrows; +import java.util.concurrent.TimeUnit; + public class Main { public static final Gson GSON = new GsonBuilder() .setPrettyPrinting() @@ -13,7 +15,9 @@ public class Main { @SneakyThrows public static void main(String[] args) { - new PiaManager(); + PiaManager.updateServers(); + Thread.sleep(TimeUnit.MINUTES.toMillis(3)); + PiaManager.updateServers(); new ReadMeManager(); } } \ No newline at end of file diff --git a/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java b/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java index 0b27c46..b16674c 100644 --- a/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java +++ b/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java @@ -21,14 +21,13 @@ import java.util.List; import java.util.concurrent.TimeUnit; public class PiaManager { - private static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient(); private static final String PIA_OPENVPN_CONFIGS_URL = "https://www.privateinternetaccess.com/openvpn/openvpn.zip"; private static final long REMOVAL_THRESHOLD = TimeUnit.DAYS.toMicros(14); // 2 weeks public static List SERVERS = new ArrayList<>(); @SneakyThrows - public PiaManager() { + public static void updateServers() { File serversFile = new File("servers.json"); if (!serversFile.exists()) { System.out.println("serversFile.json does not exist, creating..."); @@ -55,11 +54,6 @@ public class PiaManager { SERVERS.removeAll(toRemove); // Remove the servers System.out.printf("Removed %s old servers\n", toRemove.size()); - // Update the last seen time for all the servers - for (PiaServer server : SERVERS) { - server.setLastSeen(new Date()); - } - // Add the new servers to the list for (PiaServerToken serverToken : piaDomain) { InetAddress address = InetAddress.getByName(serverToken.getHostname());