mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 11:15:51 +00:00
Added simple DNS test
This commit is contained in:
parent
912bd7ec22
commit
9dbbc209a9
1 changed files with 14 additions and 0 deletions
|
@ -31,6 +31,7 @@ import androidx.annotation.NonNull;
|
|||
import org.xbill.DNS.Lookup;
|
||||
import org.xbill.DNS.MXRecord;
|
||||
import org.xbill.DNS.Record;
|
||||
import org.xbill.DNS.SRVRecord;
|
||||
import org.xbill.DNS.SimpleResolver;
|
||||
import org.xbill.DNS.TextParseException;
|
||||
import org.xbill.DNS.Type;
|
||||
|
@ -172,4 +173,17 @@ public class DNSHelper {
|
|||
else
|
||||
return dns.get(0).getHostAddress();
|
||||
}
|
||||
|
||||
static void test(Context context) {
|
||||
try {
|
||||
String domain = "gmail.com";
|
||||
boolean ok = lookupMx(context, new Address[]{Log.myAddress()});
|
||||
InetAddress iaddr = lookupMx(context, domain);
|
||||
Record[] records = DNSHelper.lookup(context, "_imaps._tcp." + domain, Type.SRV);
|
||||
SRVRecord srv = (SRVRecord) records[0];
|
||||
Log.i("DNS ok=" + ok + " iaddr=" + iaddr + " srv=" + srv.getTarget().toString());
|
||||
} catch (Throwable ex) {
|
||||
Log.e("DNS", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue