onExpectedResponse() — netty Function Reference
Architecture documentation for the onExpectedResponse() function in DnsResolveContext.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1ff8f220_55f4_0cc5_b454_65682e36be5e["onExpectedResponse()"] 3bc002ec_f54e_a55f_0b37_77eac88c60db["DnsResolveContext"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|defined in| 3bc002ec_f54e_a55f_0b37_77eac88c60db 6b22df1c_91b5_21bf_29f9_518f692074d4["onResponse()"] 6b22df1c_91b5_21bf_29f9_518f692074d4 -->|calls| 1ff8f220_55f4_0cc5_b454_65682e36be5e e8e0f39e_4c0b_4101_2c4b_e74b1af9a114["buildAliasMap()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| e8e0f39e_4c0b_4101_2c4b_e74b1af9a114 836e4609_6a00_0ab5_76ae_511f287c23c9["isEmpty()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| 836e4609_6a00_0ab5_76ae_511f287c23c9 62ab1144_69c1_0204_37b8_4eea34d6eac3["isCompleteEarly()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| 62ab1144_69c1_0204_37b8_4eea34d6eac3 161fe130_19c1_016b_ea22_8d91937c6452["add()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452 ef806d7b_af94_59ce_ffc1_c767faa5b6f5["isDuplicateAllowed()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| ef806d7b_af94_59ce_ffc1_c767faa5b6f5 83b5f3ee_8078_cb8b_b707_9c1f58a2c6cb["onResponseCNAME()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| 83b5f3ee_8078_cb8b_b707_9c1f58a2c6cb e1a10468_2ab8_17c7_5dfe_66d356b0d510["cache()"] 1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| e1a10468_2ab8_17c7_5dfe_66d356b0d510 style 1ff8f220_55f4_0cc5_b454_65682e36be5e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java lines 810–946
private void onExpectedResponse(
DnsQuestion question, AddressedEnvelope<DnsResponse, InetSocketAddress> envelope,
final DnsQueryLifecycleObserver queryLifecycleObserver, Promise<List<T>> promise) {
// We often get a bunch of CNAMES as well when we asked for A/AAAA.
final DnsResponse response = envelope.content();
final Map<String, String> cnames = buildAliasMap(response, cnameCache(), parent.executor());
final int answerCount = response.count(DnsSection.ANSWER);
boolean found = false;
boolean completeEarly = this.completeEarly;
boolean cnameNeedsFollow = !cnames.isEmpty();
for (int i = 0; i < answerCount; i ++) {
final DnsRecord r = response.recordAt(DnsSection.ANSWER, i);
final DnsRecordType type = r.type();
boolean matches = false;
for (DnsRecordType expectedType : expectedTypes) {
if (type == expectedType) {
matches = true;
break;
}
}
if (!matches) {
continue;
}
final String questionName = question.name().toLowerCase(Locale.US);
final String recordName = r.name().toLowerCase(Locale.US);
// Make sure the record is for the questioned domain.
if (!recordName.equals(questionName)) {
Map<String, String> cnamesCopy = new HashMap<String, String>(cnames);
// Even if the record's name is not exactly same, it might be an alias defined in the CNAME records.
String resolved = questionName;
do {
resolved = cnamesCopy.remove(resolved);
if (recordName.equals(resolved)) {
// We followed a CNAME chain that was part of the response without any extra queries.
cnameNeedsFollow = false;
break;
}
} while (resolved != null);
if (resolved == null) {
assert questionName.isEmpty() || questionName.charAt(questionName.length() - 1) == '.';
for (String searchDomain : parent.searchDomains()) {
if (searchDomain.isEmpty()) {
continue;
}
final String fqdn;
if (searchDomain.charAt(searchDomain.length() - 1) == '.') {
fqdn = questionName + searchDomain;
} else {
fqdn = questionName + searchDomain + '.';
}
if (recordName.equals(fqdn)) {
resolved = recordName;
break;
}
}
if (resolved == null) {
if (logger.isDebugEnabled()) {
logger.debug("{} Ignoring record {} for [{}: {}] as it contains a different name than " +
"the question name [{}]. Cnames: {}, Search domains: {}",
channel, r.toString(), response.id(), envelope.sender(),
questionName, cnames, parent.searchDomains());
}
continue;
}
}
}
final T converted = convertRecord(r, hostname, additionals, parent.executor());
if (converted == null) {
if (logger.isDebugEnabled()) {
logger.debug("{} Ignoring record {} for [{}: {}] as the converted record is null. "
+ "Hostname [{}], Additionals: {}",
channel, r.toString(), response.id(),
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does onExpectedResponse() do?
onExpectedResponse() is a function in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java.
Where is onExpectedResponse() defined?
onExpectedResponse() is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java at line 810.
What does onExpectedResponse() call?
onExpectedResponse() calls 7 function(s): add, buildAliasMap, cache, isCompleteEarly, isDuplicateAllowed, isEmpty, onResponseCNAME.
What calls onExpectedResponse()?
onExpectedResponse() is called by 1 function(s): onResponse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free