use dns to lookup the servers
This commit is contained in:
parent
e0ddf6c4bf
commit
4dbea283ab
@ -2,8 +2,8 @@ name: Fetch new Pia Servers
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "@hourly"
|
# - cron: "@hourly"
|
||||||
#- cron: "*/5 * * * *"
|
- cron: "*/30 * * * *"
|
||||||
push:
|
push:
|
||||||
branches: ["master"]
|
branches: ["master"]
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
|
17
pom.xml
17
pom.xml
@ -68,6 +68,15 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<!-- Repos -->
|
||||||
|
<repositories>
|
||||||
|
<!-- Jitpack - Used for dnsjava -->
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Libraries -->
|
<!-- Libraries -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -83,6 +92,14 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- DNS -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.dnsjava</groupId>
|
||||||
|
<artifactId>dnsjava</artifactId>
|
||||||
|
<version>v3.5.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Archive Utilities -->
|
<!-- Archive Utilities -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
@ -6,6 +6,8 @@ import cc.fascinated.piaservers.model.PiaServerToken;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
|
import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
|
||||||
|
import org.xbill.DNS.*;
|
||||||
|
import org.xbill.DNS.Record;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -95,6 +97,9 @@ public class PiaManager {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the DNS resolver to Cloudflare
|
||||||
|
Lookup.setDefaultResolver(new SimpleResolver("1.1.1.1"));
|
||||||
|
|
||||||
// Search for the server domains
|
// Search for the server domains
|
||||||
List<PiaServerToken> domains = new ArrayList<>();
|
List<PiaServerToken> domains = new ArrayList<>();
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
@ -109,10 +114,17 @@ public class PiaManager {
|
|||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if (line.startsWith("remote ")) {
|
if (line.startsWith("remote ")) {
|
||||||
String[] parts = line.split(" ");
|
String[] parts = line.split(" ");
|
||||||
String domain = parts[1];
|
String hostname = parts[1];
|
||||||
String region = file.getName().split("\\.")[0];
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user