|
1 /* |
|
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package jdk.dns.client.internal; |
|
27 |
|
28 import jdk.dns.client.ex.DnsResolverException; |
|
29 |
|
30 import java.net.UnknownHostException; |
|
31 import java.util.List; |
|
32 |
|
33 // TODO: Remove this one |
|
34 // TODO: All with close() implements AutoCloseable |
|
35 // TODO: Analyse exceptions and remove all different types if not needed to maintain code-flow |
|
36 public class Resolver implements AutoCloseable { |
|
37 private DnsClient dnsClient; |
|
38 |
|
39 /* |
|
40 * Constructs a new Resolver given package oracle.dns.client.standalone;its servers and timeout parameters. |
|
41 * Each server is of the form "server[:port]". |
|
42 * IPv6 literal host names include delimiting brackets. |
|
43 * There must be at least one server. |
|
44 * "timeout" is the initial timeout interval (in ms) for UDP queries, |
|
45 * and "retries" gives the number of retries per server. |
|
46 */ |
|
47 public Resolver(List<String> servers, int timeout, int retries) |
|
48 throws UnknownHostException { |
|
49 dnsClient = new DnsClient(servers, timeout, retries); |
|
50 } |
|
51 |
|
52 public void close() { |
|
53 dnsClient.close(); |
|
54 dnsClient = null; |
|
55 } |
|
56 |
|
57 /* |
|
58 * Queries resource records of a particular class and type for a |
|
59 * given domain name. |
|
60 * Useful values of rrclass are ResourceRecord.[Q]CLASS_xxx. |
|
61 * Useful values of rrtype are ResourceRecord.[Q]TYPE_xxx. |
|
62 * If recursion is true, recursion is requested on the query. |
|
63 * If auth is true, only authoritative responses are accepted. |
|
64 */ |
|
65 public ResourceRecords query(DnsName fqdn, int rrclass, int rrtype, |
|
66 boolean recursion, boolean auth) |
|
67 throws DnsResolverException { |
|
68 return dnsClient.query(fqdn, rrclass, rrtype, recursion, auth); |
|
69 } |
|
70 } |