mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 19:18:37 +00:00
Resolve multiple times when generating static IPs.
An attempt to make the list somewhat more stable.
This commit is contained in:
committed by
Cody Henthorne
parent
570b39f82e
commit
a0ebb891de
@@ -1,7 +1,7 @@
|
|||||||
ext.service_ips='new String[]{"13.248.212.111","76.223.92.165"}'
|
ext.service_ips='new String[]{"13.248.212.111","76.223.92.165"}'
|
||||||
ext.storage_ips='new String[]{"142.250.188.51"}'
|
ext.storage_ips='new String[]{"142.250.176.211"}'
|
||||||
ext.cdn_ips='new String[]{"99.84.42.84","99.84.42.34","99.84.42.27","99.84.42.88"}'
|
ext.cdn_ips='new String[]{"65.8.198.118","65.8.198.39","65.8.198.46","65.8.198.54"}'
|
||||||
ext.cdn2_ips='new String[]{"104.18.29.74","104.18.28.74"}'
|
ext.cdn2_ips='new String[]{"104.18.28.74","104.18.29.74"}'
|
||||||
ext.cds_ips='new String[]{"20.62.208.25"}'
|
ext.cds_ips='new String[]{"20.62.208.25"}'
|
||||||
ext.kbs_ips='new String[]{"20.85.156.233"}'
|
ext.kbs_ips='new String[]{"20.85.156.233"}'
|
||||||
ext.sfu_ips='new String[]{"52.6.24.145","54.152.177.76"}'
|
ext.sfu_ips='new String[]{"52.6.24.145","54.152.177.76"}'
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ import org.xbill.DNS.Type;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class StaticIpResolver {
|
public final class StaticIpResolver {
|
||||||
|
|
||||||
@@ -29,7 +33,18 @@ public final class StaticIpResolver {
|
|||||||
return builder.append("}").toString();
|
return builder.append("}").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] resolve(String hostName) {
|
private static String[] resolve(String hostname) {
|
||||||
|
Set<String> ips = new HashSet<>();
|
||||||
|
|
||||||
|
// Run several resolves to mitigate DNS round robin
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
ips.addAll(resolveOnce(hostname));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ips.stream().sorted().toArray(String[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> resolveOnce(String hostName) {
|
||||||
try {
|
try {
|
||||||
Resolver resolver = new SimpleResolver("1.1.1.1");
|
Resolver resolver = new SimpleResolver("1.1.1.1");
|
||||||
Lookup lookup = doLookup(hostName);
|
Lookup lookup = doLookup(hostName);
|
||||||
@@ -44,7 +59,7 @@ public final class StaticIpResolver {
|
|||||||
.map(r -> (ARecord) r)
|
.map(r -> (ARecord) r)
|
||||||
.map(ARecord::getAddress)
|
.map(ARecord::getAddress)
|
||||||
.map(InetAddress::getHostAddress)
|
.map(InetAddress::getHostAddress)
|
||||||
.toArray(String[]::new);
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Failed to resolve host! " + hostName);
|
throw new IllegalStateException("Failed to resolve host! " + hostName);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user