| 1 |
/* |
| 2 |
* Copyright 2015-2020 the original author or authors |
| 3 |
* |
| 4 |
* This software is licensed under the Apache License, Version 2.0, |
| 5 |
* the GNU Lesser General Public License version 2 or later ("LGPL") |
| 6 |
* and the WTFPL. |
| 7 |
* You may choose either license to govern your use of this software only |
| 8 |
* upon the condition that you accept all of the terms of either |
| 9 |
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL. |
| 10 |
*/ |
| 11 |
package org.minidns.source; |
| 12 |
|
| 13 |
import java.io.IOException; |
| 14 |
import java.net.InetAddress; |
| 15 |
|
| 16 |
import org.minidns.MiniDnsFuture; |
| 17 |
import org.minidns.dnsmessage.DnsMessage; |
| 18 |
import org.minidns.dnsqueryresult.DnsQueryResult; |
| 19 |
|
| 20 |
public interface DnsDataSource { |
| 21 |
|
| 22 |
DnsQueryResult query(DnsMessage message, InetAddress address, int port) throws IOException; |
| 23 |
|
| 24 |
MiniDnsFuture<DnsQueryResult, IOException> queryAsync(DnsMessage message, InetAddress address, int port, OnResponseCallback onResponseCallback); |
| 25 |
|
| 26 |
int getUdpPayloadSize(); |
| 27 |
|
| 28 |
/** |
| 29 |
* Retrieve the current dns query timeout, in milliseconds. |
| 30 |
* |
| 31 |
* @return the current dns query timeout in milliseconds. |
| 32 |
*/ |
| 33 |
int getTimeout(); |
| 34 |
|
| 35 |
/** |
| 36 |
* Change the dns query timeout for all future queries. The timeout |
| 37 |
* must be specified in milliseconds. |
| 38 |
* |
| 39 |
* @param timeout new dns query timeout in milliseconds. |
| 40 |
*/ |
| 41 |
void setTimeout(int timeout); |
| 42 |
|
| 43 |
public interface OnResponseCallback { |
| 44 |
void onResponse(DnsMessage request, DnsQueryResult result); |
| 45 |
} |
| 46 |
|
| 47 |
} |