• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
2 
3 package org.xbill.DNS;
4 
5 import java.io.*;
6 import java.util.*;
7 
8 /**
9  * Interface describing a resolver.
10  *
11  * @author Brian Wellington
12  */
13 
14 public interface Resolver {
15 
16 /**
17  * Sets the port to communicate with on the server
18  * @param port The port to send messages to
19  */
setPort(int port)20 void setPort(int port);
21 
22 /**
23  * Sets whether TCP connections will be sent by default
24  * @param flag Indicates whether TCP connections are made
25  */
setTCP(boolean flag)26 void setTCP(boolean flag);
27 
28 /**
29  * Sets whether truncated responses will be ignored.  If not, a truncated
30  * response over UDP will cause a retransmission over TCP.
31  * @param flag Indicates whether truncated responses should be ignored.
32  */
setIgnoreTruncation(boolean flag)33 void setIgnoreTruncation(boolean flag);
34 
35 /**
36  * Sets the EDNS version used on outgoing messages.
37  * @param level The EDNS level to use.  0 indicates EDNS0 and -1 indicates no
38  * EDNS.
39  * @throws IllegalArgumentException An invalid level was indicated.
40  */
setEDNS(int level)41 void setEDNS(int level);
42 
43 /**
44  * Sets the EDNS information on outgoing messages.
45  * @param level The EDNS level to use.  0 indicates EDNS0 and -1 indicates no
46  * EDNS.
47  * @param payloadSize The maximum DNS packet size that this host is capable
48  * of receiving over UDP.  If 0 is specified, the default (1280) is used.
49  * @param flags EDNS extended flags to be set in the OPT record.
50  * @param options EDNS options to be set in the OPT record, specified as a
51  * List of OPTRecord.Option elements.
52  * @throws IllegalArgumentException An invalid field was specified.
53  * @see OPTRecord
54  */
setEDNS(int level, int payloadSize, int flags, List options)55 void setEDNS(int level, int payloadSize, int flags, List options);
56 
57 /**
58  * Specifies the TSIG key that messages will be signed with
59  * @param key The key
60  */
setTSIGKey(TSIG key)61 void setTSIGKey(TSIG key);
62 
63 /**
64  * Sets the amount of time to wait for a response before giving up.
65  * @param secs The number of seconds to wait.
66  * @param msecs The number of milliseconds to wait.
67  */
setTimeout(int secs, int msecs)68 void setTimeout(int secs, int msecs);
69 
70 /**
71  * Sets the amount of time to wait for a response before giving up.
72  * @param secs The number of seconds to wait.
73  */
setTimeout(int secs)74 void setTimeout(int secs);
75 
76 /**
77  * Sends a message and waits for a response.
78  * @param query The query to send.
79  * @return The response
80  * @throws IOException An error occurred while sending or receiving.
81  */
send(Message query)82 Message send(Message query) throws IOException;
83 
84 /**
85  * Asynchronously sends a message registering a listener to receive a callback
86  * on success or exception.  Multiple asynchronous lookups can be performed
87  * in parallel.  Since the callback may be invoked before the function returns,
88  * external synchronization is necessary.
89  * @param query The query to send
90  * @param listener The object containing the callbacks.
91  * @return An identifier, which is also a parameter in the callback
92  */
sendAsync(final Message query, final ResolverListener listener)93 Object sendAsync(final Message query, final ResolverListener listener);
94 
95 }
96