List of usage examples for io.netty.handler.codec.dns DnsRecordType CNAME
DnsRecordType CNAME
To view the source code for io.netty.handler.codec.dns DnsRecordType CNAME.
Click Source Link
From source file:io.vertx.core.dns.impl.DnsClientImpl.java
License:Open Source License
@Override public DnsClient resolveCNAME(String name, Handler<AsyncResult<List<String>>> handler) { lookupList(name, handler, DnsRecordType.CNAME); return this; }
From source file:io.vertx.core.dns.impl.fix.DnsNameResolverContext.java
License:Apache License
void onResponse(final DnsQuestion question, AddressedEnvelope<DnsResponse, InetSocketAddress> envelope) { try {/*from w w w . j av a 2 s. c o m*/ final DnsResponse res = envelope.content(); final DnsResponseCode code = res.code(); if (code == DnsResponseCode.NOERROR) { final DnsRecordType type = question.type(); if (type == DnsRecordType.A || type == DnsRecordType.AAAA) { onResponseAorAAAA(type, question, envelope); } else if (type == DnsRecordType.CNAME) { onResponseCNAME(question, envelope); } return; } if (traceEnabled) { addTrace(envelope.sender(), "response code: " + code + " with " + res.count(DnsSection.ANSWER) + " answer(s) and " + res.count(DnsSection.AUTHORITY) + " authority resource(s)"); } // Retry with the next server if the server did not tell us that the domain does not exist. if (code != DnsResponseCode.NXDOMAIN) { query(nameServerAddrs.next(), question); } } finally { ReferenceCountUtil.safeRelease(envelope); } }
From source file:io.vertx.core.dns.impl.fix.DnsNameResolverContext.java
License:Apache License
private static Map<String, String> buildAliasMap(DnsResponse response) { final int answerCount = response.count(DnsSection.ANSWER); Map<String, String> cnames = null; for (int i = 0; i < answerCount; i++) { final DnsRecord r = response.recordAt(DnsSection.ANSWER, i); final DnsRecordType type = r.type(); if (type != DnsRecordType.CNAME) { continue; }/*from ww w . j a v a2 s .c om*/ if (!(r instanceof DnsRawRecord)) { continue; } final ByteBuf recordContent = ((ByteBufHolder) r).content(); final String domainName = decodeDomainName(recordContent); if (domainName == null) { continue; } if (cnames == null) { cnames = new HashMap<String, String>(); } cnames.put(r.name().toLowerCase(Locale.US), domainName.toLowerCase(Locale.US)); } return cnames != null ? cnames : Collections.<String, String>emptyMap(); }
From source file:io.vertx.core.dns.impl.fix.DnsNameResolverContext.java
License:Apache License
void tryToFinishResolve() { if (!queriesInProgress.isEmpty()) { // There are still some queries we did not receive responses for. if (gotPreferredAddress()) { // But it's OK to finish the resolution process if we got a resolved address of the preferred type. finishResolve();//from w w w. ja v a 2 s . c o m } // We did not get any resolved address of the preferred type, so we can't finish the resolution process. return; } // There are no queries left to try. if (resolvedEntries == null) { // .. and we could not find any A/AAAA records. if (!triedCNAME) { // As the last resort, try to query CNAME, just in case the name server has it. triedCNAME = true; query(nameServerAddrs.next(), new DefaultDnsQuestion(hostname, DnsRecordType.CNAME)); return; } } // We have at least one resolved address or tried CNAME as the last resort.. finishResolve(); }