fix
All checks were successful
Fetch new Pia Servers / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 3m17s
All checks were successful
Fetch new Pia Servers / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 3m17s
This commit is contained in:
parent
74c2c89385
commit
e0ddf6c4bf
@ -6,6 +6,8 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static final Gson GSON = new GsonBuilder()
|
public static final Gson GSON = new GsonBuilder()
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
@ -13,7 +15,9 @@ public class Main {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new PiaManager();
|
PiaManager.updateServers();
|
||||||
|
Thread.sleep(TimeUnit.MINUTES.toMillis(3));
|
||||||
|
PiaManager.updateServers();
|
||||||
new ReadMeManager();
|
new ReadMeManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,14 +21,13 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class PiaManager {
|
public class PiaManager {
|
||||||
|
|
||||||
private static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient();
|
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 String PIA_OPENVPN_CONFIGS_URL = "https://www.privateinternetaccess.com/openvpn/openvpn.zip";
|
||||||
private static final long REMOVAL_THRESHOLD = TimeUnit.DAYS.toMicros(14); // 2 weeks
|
private static final long REMOVAL_THRESHOLD = TimeUnit.DAYS.toMicros(14); // 2 weeks
|
||||||
public static List<PiaServer> SERVERS = new ArrayList<>();
|
public static List<PiaServer> SERVERS = new ArrayList<>();
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public PiaManager() {
|
public static void updateServers() {
|
||||||
File serversFile = new File("servers.json");
|
File serversFile = new File("servers.json");
|
||||||
if (!serversFile.exists()) {
|
if (!serversFile.exists()) {
|
||||||
System.out.println("serversFile.json does not exist, creating...");
|
System.out.println("serversFile.json does not exist, creating...");
|
||||||
@ -55,11 +54,6 @@ public class PiaManager {
|
|||||||
SERVERS.removeAll(toRemove); // Remove the servers
|
SERVERS.removeAll(toRemove); // Remove the servers
|
||||||
System.out.printf("Removed %s old servers\n", toRemove.size());
|
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
|
// Add the new servers to the list
|
||||||
for (PiaServerToken serverToken : piaDomain) {
|
for (PiaServerToken serverToken : piaDomain) {
|
||||||
InetAddress address = InetAddress.getByName(serverToken.getHostname());
|
InetAddress address = InetAddress.getByName(serverToken.getHostname());
|
||||||
|
Loading…
Reference in New Issue
Block a user