Search in sources :

Example 1 with AsyncNetworkDataSource

use of org.minidns.source.async.AsyncNetworkDataSource in project minidns by MiniDNS.

the class AsyncApiTest method simpleAsyncApiTest.

public static void simpleAsyncApiTest() throws IOException {
    DNSClient client = new DNSClient();
    client.setDataSource(new AsyncNetworkDataSource());
    client.getDataSource().setTimeout(60 * 60 * 1000);
    MiniDnsFuture<DNSMessage, IOException> future = client.queryAsync("example.com", Record.TYPE.NS);
    DNSMessage response = future.getOrThrow();
    assertEquals(RESPONSE_CODE.NO_ERROR, response.responseCode);
}
Also used : DNSClient(org.minidns.DNSClient) IOException(java.io.IOException) AsyncNetworkDataSource(org.minidns.source.async.AsyncNetworkDataSource) DNSMessage(org.minidns.dnsmessage.DNSMessage)

Example 2 with AsyncNetworkDataSource

use of org.minidns.source.async.AsyncNetworkDataSource in project minidns by MiniDNS.

the class AsyncApiTest method tcpAsyncApiTest.

public static void tcpAsyncApiTest() throws IOException {
    DNSDataSource dataSource = new AsyncNetworkDataSource();
    dataSource.setTimeout(60 * 60 * 1000);
    dataSource.setUdpPayloadSize(256);
    dataSource.setQueryMode(QueryMode.tcp);
    DNSClient client = new DNSClient();
    client.setDataSource(dataSource);
    client.setAskForDnssec(true);
    MiniDnsFuture<DNSMessage, IOException> future = client.queryAsync("google.com", Record.TYPE.AAAA);
    DNSMessage response = future.getOrThrow();
    assertEquals(RESPONSE_CODE.NO_ERROR, response.responseCode);
}
Also used : DNSDataSource(org.minidns.source.DNSDataSource) DNSClient(org.minidns.DNSClient) IOException(java.io.IOException) AsyncNetworkDataSource(org.minidns.source.async.AsyncNetworkDataSource) DNSMessage(org.minidns.dnsmessage.DNSMessage)

Aggregations

IOException (java.io.IOException)2 DNSClient (org.minidns.DNSClient)2 DNSMessage (org.minidns.dnsmessage.DNSMessage)2 AsyncNetworkDataSource (org.minidns.source.async.AsyncNetworkDataSource)2 DNSDataSource (org.minidns.source.DNSDataSource)1