1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.resolver.dns;
17
18 import java.net.UnknownHostException;
19 import java.util.List;
20
21 import io.netty.channel.Channel;
22 import io.netty.channel.EventLoop;
23 import io.netty.handler.codec.dns.DnsQuestion;
24 import io.netty.handler.codec.dns.DnsRecord;
25 import io.netty.handler.codec.dns.DnsRecordType;
26 import io.netty.util.ReferenceCountUtil;
27 import io.netty.util.concurrent.Future;
28 import io.netty.util.concurrent.Promise;
29
30 final class DnsRecordResolveContext extends DnsResolveContext<DnsRecord> {
31
32 DnsRecordResolveContext(DnsNameResolver parent, Channel channel, Future<? extends Channel> channelReadyFuture,
33 Promise<?> originalPromise, DnsQuestion question, DnsRecord[] additionals,
34 DnsServerAddressStream nameServerAddrs, int allowedQueries) {
35 this(parent, channel, channelReadyFuture, originalPromise, question.name(), question.dnsClass(),
36 new DnsRecordType[] { question.type() },
37 additionals, nameServerAddrs, allowedQueries);
38 }
39
40 private DnsRecordResolveContext(DnsNameResolver parent, Channel channel,
41 Future<? extends Channel> channelReadyFuture, Promise<?> originalPromise,
42 String hostname, int dnsClass, DnsRecordType[] expectedTypes,
43 DnsRecord[] additionals,
44 DnsServerAddressStream nameServerAddrs,
45 int allowedQueries) {
46 super(parent, channel, channelReadyFuture, originalPromise, hostname, dnsClass, expectedTypes,
47 additionals, nameServerAddrs, allowedQueries);
48 }
49
50 @Override
51 DnsResolveContext<DnsRecord> newResolverContext(DnsNameResolver parent, Channel channel,
52 Future<? extends Channel> channelReadyFuture,
53 Promise<?> originalPromise,
54 String hostname,
55 int dnsClass, DnsRecordType[] expectedTypes,
56 DnsRecord[] additionals,
57 DnsServerAddressStream nameServerAddrs,
58 int allowedQueries) {
59 return new DnsRecordResolveContext(parent, channel, channelReadyFuture, originalPromise, hostname, dnsClass,
60 expectedTypes, additionals, nameServerAddrs, allowedQueries);
61 }
62
63 @Override
64 DnsRecord convertRecord(DnsRecord record, String hostname, DnsRecord[] additionals, EventLoop eventLoop) {
65 return ReferenceCountUtil.retain(record);
66 }
67
68 @Override
69 List<DnsRecord> filterResults(List<DnsRecord> unfiltered) {
70 return unfiltered;
71 }
72
73 @Override
74 boolean isCompleteEarly(DnsRecord resolved) {
75 return false;
76 }
77
78 @Override
79 boolean isDuplicateAllowed() {
80 return true;
81 }
82
83 @Override
84 void cache(String hostname, DnsRecord[] additionals, DnsRecord result, DnsRecord convertedResult) {
85
86
87 }
88
89 @Override
90 void cache(String hostname, DnsRecord[] additionals, UnknownHostException cause) {
91
92
93 }
94
95 @Override
96 DnsCnameCache cnameCache() {
97
98 return NoopDnsCnameCache.INSTANCE;
99 }
100 }