This commit is contained in:
Anuken
2023-02-26 15:41:49 -05:00
parent b496e8457c
commit 8e9b409b63

View File

@@ -2,6 +2,7 @@ package mindustry.net;
import arc.func.*;
import arc.math.*;
import arc.net.dns.*;
import arc.struct.*;
import arc.util.*;
@@ -15,7 +16,7 @@ public class Dns{
private static final Pattern ipPattern = Pattern.compile("^((0|1\\d?\\d?|2[0-4]?\\d?|25[0-5]?|[3-9]\\d?)\\.){3}(0|1\\d?\\d?|2[0-4]?\\d?|25[0-5]?|[3-9]\\d?)$");
private static final int aRecord = 1, srvRecord = 33;
private static IntMap<ObjectMap<String, Seq<?>>> cache = new IntMap<>();
private static Seq<InetSocketAddress> nameservers = Seq.with(new InetSocketAddress("1.1.1.1", 53), new InetSocketAddress("8.8.8.8", 53));
private static Seq<InetSocketAddress> defNameservers = Seq.with(new InetSocketAddress("1.1.1.1", 53), new InetSocketAddress("8.8.8.8", 53));
static <T> void resolve(int type, String domain, Func<ByteBuffer, T> reader, Cons<Seq<T>> result, Cons<Exception> error){
ObjectMap<String, Seq<?>> map;
@@ -30,7 +31,7 @@ public class Dns{
}
}
send(Seq.with(new InetSocketAddress("1.1.1.1", 53)), 0, type, domain, reader, records -> {
send(ArcDns.getNameservers(), 0, type, domain, reader, records -> {
synchronized(cache){
//cache the records
map.put(domain, records);