DnsRecord() — netty Function Reference
Architecture documentation for the DnsRecord() function in DefaultDnsRecordDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 6c10a76a_10a1_2baa_c2d7_930c4b884c79["DnsRecord()"] c16e962c_4ec3_f108_e01f_b69ee7a6f791["DefaultDnsRecordDecoder"] 6c10a76a_10a1_2baa_c2d7_930c4b884c79 -->|defined in| c16e962c_4ec3_f108_e01f_b69ee7a6f791 style 6c10a76a_10a1_2baa_c2d7_930c4b884c79 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsRecordDecoder.java lines 87–130
protected DnsRecord decodeRecord(
String name, DnsRecordType type, int dnsClass, long timeToLive,
ByteBuf in, int offset, int length) throws Exception {
// DNS message compression means that domain names may contain "pointers" to other positions in the packet
// to build a full message. This means the indexes are meaningful and we need the ability to reference the
// indexes un-obstructed, and thus we cannot use a slice here.
// See https://www.ietf.org/rfc/rfc1035 [4.1.4. Message compression]
if (type == DnsRecordType.PTR) {
return new DefaultDnsPtrRecord(
name, dnsClass, timeToLive, decodeName0(in.duplicate().setIndex(offset, offset + length)));
}
if (type == DnsRecordType.CNAME || type == DnsRecordType.NS) {
return new DefaultDnsRawRecord(name, type, dnsClass, timeToLive,
DnsCodecUtil.decompressDomainName(
in.duplicate().setIndex(offset, offset + length)));
}
if (type == DnsRecordType.MX) {
// MX RDATA: 16-bit preference + exchange (domain name, possibly compressed)
if (length < 3) {
throw new CorruptedFrameException("MX record RDATA is too short: " + length);
}
final int pref = in.getUnsignedShort(offset);
ByteBuf exchange = null;
try {
exchange = DnsCodecUtil.decompressDomainName(
in.duplicate().setIndex(offset + 2, offset + length));
// Build decompressed RDATA = [preference][expanded exchange name]
final ByteBuf out = in.alloc().buffer(2 + exchange.readableBytes());
out.writeShort(pref);
out.writeBytes(exchange);
return new DefaultDnsRawRecord(name, type, dnsClass, timeToLive, out);
} finally {
if (exchange != null) {
exchange.release();
}
}
}
return new DefaultDnsRawRecord(
name, type, dnsClass, timeToLive, in.retainedDuplicate().setIndex(offset, offset + length));
}
Domain
Subdomains
Source
Frequently Asked Questions
What does DnsRecord() do?
DnsRecord() is a function in the netty codebase, defined in codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsRecordDecoder.java.
Where is DnsRecord() defined?
DnsRecord() is defined in codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsRecordDecoder.java at line 87.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free