diff --git a/.gitea/workflows/fetch-new.yml b/.gitea/workflows/fetch-new.yml
index eeaf5d7..63e0097 100644
--- a/.gitea/workflows/fetch-new.yml
+++ b/.gitea/workflows/fetch-new.yml
@@ -2,8 +2,8 @@ name: Fetch new Pia Servers
on:
schedule:
- - cron: "@hourly"
- #- cron: "*/5 * * * *"
+# - cron: "@hourly"
+ - cron: "*/30 * * * *"
push:
branches: ["master"]
paths-ignore:
diff --git a/pom.xml b/pom.xml
index 3a1b094..7175d2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,15 @@
+
+
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
@@ -83,6 +92,14 @@
compile
+
+
+ com.github.dnsjava
+ dnsjava
+ v3.5.2
+ compile
+
+
org.codehaus.plexus
diff --git a/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java b/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java
index b16674c..65b6ff8 100644
--- a/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java
+++ b/src/main/java/cc/fascinated/piaservers/pia/PiaManager.java
@@ -6,6 +6,8 @@ import cc.fascinated.piaservers.model.PiaServerToken;
import com.google.gson.reflect.TypeToken;
import lombok.SneakyThrows;
import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
+import org.xbill.DNS.*;
+import org.xbill.DNS.Record;
import java.io.File;
import java.net.InetAddress;
@@ -95,6 +97,9 @@ public class PiaManager {
System.exit(1);
}
+ // Set the DNS resolver to Cloudflare
+ Lookup.setDefaultResolver(new SimpleResolver("1.1.1.1"));
+
// Search for the server domains
List domains = new ArrayList<>();
for (File file : files) {
@@ -109,10 +114,17 @@ public class PiaManager {
for (String line : lines) {
if (line.startsWith("remote ")) {
String[] parts = line.split(" ");
- String domain = parts[1];
+ String hostname = parts[1];
String region = file.getName().split("\\.")[0];
- domains.add(new PiaServerToken(domain, region));
+ Record[] records = new Lookup(hostname, Type.A).run();
+ if (records == null) {
+ continue;
+ }
+ for (Record record : records) {
+ ARecord aRecord = (ARecord) record;
+ domains.add(new PiaServerToken(aRecord.getAddress().getHostAddress(), region));
+ }
break;
}
}