Revert "Updated dnsjava"

This reverts commit 0abad7e694.

dnsjava 3+ depends on java.time.Duration, which was added in SDK 26
pull/214/head
M66B 1 year ago
parent d82019d090
commit 27d96e7fe8

@ -10,7 +10,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
* Added [Certificate transparency](https://github.com/appmattus/certificatetransparency/blob/main/docs/what-is-certificate-transparency.md) * Added [Certificate transparency](https://github.com/appmattus/certificatetransparency/blob/main/docs/what-is-certificate-transparency.md)
* Small improvements and minor bug fixes * Small improvements and minor bug fixes
* Updated libraries (Apache Compress, Bugsnag, Bouncy Castle, dnsjava, Jsoup) * Updated libraries (Apache Compress, Bugsnag, Bouncy Castle, Jsoup)
* Updated [translations](https://crowdin.com/project/open-source-email) * Updated [translations](https://crowdin.com/project/open-source-email)
### 1.2145 - 2023-12-30 ### 1.2145 - 2023-12-30

@ -548,7 +548,7 @@ dependencies {
def jsonpath_version = "2.8.0" def jsonpath_version = "2.8.0"
def css_version = "0.9.30" def css_version = "0.9.30"
def jax_version = "2.3.0-jaxb-1.0.6" def jax_version = "2.3.0-jaxb-1.0.6"
def dnsjava_version = "3.5.3" def dnsjava_version = "2.1.9"
def openpgp_version = "12.0" def openpgp_version = "12.0"
def badge_version = "1.1.22" def badge_version = "1.1.22"
def bugsnag_version = "6.1.0" def bugsnag_version = "6.1.0"

@ -10,7 +10,7 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
* Added [Certificate transparency](https://github.com/appmattus/certificatetransparency/blob/main/docs/what-is-certificate-transparency.md) * Added [Certificate transparency](https://github.com/appmattus/certificatetransparency/blob/main/docs/what-is-certificate-transparency.md)
* Small improvements and minor bug fixes * Small improvements and minor bug fixes
* Updated libraries (Apache Compress, Bugsnag, Bouncy Castle, dnsjava, Jsoup) * Updated libraries (Apache Compress, Bugsnag, Bouncy Castle, Jsoup)
* Updated [translations](https://crowdin.com/project/open-source-email) * Updated [translations](https://crowdin.com/project/open-source-email)
### 1.2145 - 2023-12-30 ### 1.2145 - 2023-12-30

@ -37,6 +37,7 @@ import org.xbill.DNS.MXRecord;
import org.xbill.DNS.Message; import org.xbill.DNS.Message;
import org.xbill.DNS.NSRecord; import org.xbill.DNS.NSRecord;
import org.xbill.DNS.Record; import org.xbill.DNS.Record;
import org.xbill.DNS.SOARecord;
import org.xbill.DNS.SRVRecord; import org.xbill.DNS.SRVRecord;
import org.xbill.DNS.SimpleResolver; import org.xbill.DNS.SimpleResolver;
import org.xbill.DNS.TXTRecord; import org.xbill.DNS.TXTRecord;
@ -45,7 +46,6 @@ import org.xbill.DNS.Type;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -97,6 +97,9 @@ public class DnsHelper {
case "mx": case "mx":
rtype = Type.MX; rtype = Type.MX;
break; break;
case "soa":
rtype = Type.SOA;
break;
case "srv": case "srv":
rtype = Type.SRV; rtype = Type.SRV;
break; break;
@ -186,7 +189,7 @@ public class DnsHelper {
} }
} }
}; };
resolver.setTimeout(Duration.ofSeconds(timeout)); resolver.setTimeout(timeout);
Lookup lookup = new Lookup(name, rtype); Lookup lookup = new Lookup(name, rtype);
lookup.setResolver(resolver); lookup.setResolver(resolver);
Log.i("Lookup name=" + name + " @" + resolver.getAddress() + " type=" + rtype); Log.i("Lookup name=" + name + " @" + resolver.getAddress() + " type=" + rtype);
@ -205,13 +208,16 @@ public class DnsHelper {
Log.i("Found record=" + record); Log.i("Found record=" + record);
if (record instanceof NSRecord) { if (record instanceof NSRecord) {
NSRecord ns = (NSRecord) record; NSRecord ns = (NSRecord) record;
result.add(new DnsRecord(type, ns.getTarget().toString(true))); result.add(new DnsRecord(ns.getTarget().toString(true)));
} else if (record instanceof MXRecord) { } else if (record instanceof MXRecord) {
MXRecord mx = (MXRecord) record; MXRecord mx = (MXRecord) record;
result.add(new DnsRecord(type, mx.getTarget().toString(true))); result.add(new DnsRecord(mx.getTarget().toString(true)));
} else if (record instanceof SOARecord) {
SOARecord soa = (SOARecord) record;
result.add(new DnsRecord(soa.getHost().toString(true)));
} else if (record instanceof SRVRecord) { } else if (record instanceof SRVRecord) {
SRVRecord srv = (SRVRecord) record; SRVRecord srv = (SRVRecord) record;
result.add(new DnsRecord(type, srv.getTarget().toString(true), srv.getPort(), srv.getPriority(), srv.getWeight())); result.add(new DnsRecord(srv.getTarget().toString(true), srv.getPort(), srv.getPriority(), srv.getWeight()));
} else if (record instanceof TXTRecord) { } else if (record instanceof TXTRecord) {
TXTRecord txt = (TXTRecord) record; TXTRecord txt = (TXTRecord) record;
for (Object content : txt.getStrings()) { for (Object content : txt.getStrings()) {
@ -233,14 +239,14 @@ public class DnsHelper {
if (result.size() > 0) if (result.size() > 0)
result.get(0).response += text; result.get(0).response += text;
else else
result.add(new DnsRecord(type, text, 0)); result.add(new DnsRecord(text, 0));
} }
} else if (record instanceof ARecord) { } else if (record instanceof ARecord) {
ARecord a = (ARecord) record; ARecord a = (ARecord) record;
result.add(new DnsRecord(type, a.getAddress().getHostAddress())); result.add(new DnsRecord(a.getAddress().getHostAddress()));
} else if (record instanceof AAAARecord) { } else if (record instanceof AAAARecord) {
AAAARecord aaaa = (AAAARecord) record; AAAARecord aaaa = (AAAARecord) record;
result.add(new DnsRecord(type, aaaa.getAddress().getHostAddress())); result.add(new DnsRecord(aaaa.getAddress().getHostAddress()));
} else } else
throw new IllegalArgumentException(record.getClass().getName()); throw new IllegalArgumentException(record.getClass().getName());
} }
@ -291,41 +297,23 @@ public class DnsHelper {
return dns.get(0).getHostAddress(); return dns.get(0).getHostAddress();
} }
static void test(Context context) throws UnknownHostException {
log(lookup(context, "gmail.com", "ns"));
log(lookup(context, "gmail.com", "mx"));
log(lookup(context, "_imaps._tcp.gmail.com", "srv"));
log(lookup(context, "gmail.com", "txt"));
log(lookup(context, "gmail.com", "a"));
log(lookup(context, "gmail.com", "aaaa"));
}
static void log(DnsRecord[] records) {
for (DnsRecord record : records)
Log.w("DNS " + record);
}
static class DnsRecord { static class DnsRecord {
String type;
String query; String query;
String response; String response;
Integer port; Integer port;
Integer priority; Integer priority;
Integer weight; Integer weight;
DnsRecord(String type, String response) { DnsRecord(String response) {
this.type = type;
this.response = response; this.response = response;
} }
DnsRecord(String type, String response, int port) { DnsRecord(String response, int port) {
this.type = type;
this.response = response; this.response = response;
this.port = port; this.port = port;
} }
DnsRecord(String type, String response, int port, int priority, int weight) { DnsRecord(String response, int port, int priority, int weight) {
this.type = type;
this.response = response; this.response = response;
this.port = port; this.port = port;
this.priority = priority; this.priority = priority;
@ -335,7 +323,7 @@ public class DnsHelper {
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {
return type + " " + query + "=" + response + ":" + port + " " + priority + "/" + weight; return query + "=" + response + ":" + port + " " + priority + "/" + weight;
} }
} }
} }

@ -10,7 +10,7 @@ Next version
* Added Certificate transparency * Added Certificate transparency
* Small improvements and minor bug fixes * Small improvements and minor bug fixes
* Updated libraries (Apache Compress, Bugsnag, Bouncy Castle, dnsjava, Jsoup) * Updated libraries (Apache Compress, Bugsnag, Bouncy Castle, Jsoup)
* Updated translations * Updated translations
1.2145 - 2023-12-30 1.2145 - 2023-12-30

Loading…
Cancel
Save