String() — netty Function Reference
Architecture documentation for the String() function in DnsCodecUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD bf1393c0_29d3_74ac_3a63_fc1091b78bb6["String()"] b5deaff8_7855_06da_81ac_dd1ff0412cf2["DnsCodecUtil"] bf1393c0_29d3_74ac_3a63_fc1091b78bb6 -->|defined in| b5deaff8_7855_06da_81ac_dd1ff0412cf2 style bf1393c0_29d3_74ac_3a63_fc1091b78bb6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-dns/src/main/java/io/netty/handler/codec/dns/DnsCodecUtil.java lines 53–118
static String decodeDomainName(ByteBuf in) {
int position = -1;
int checked = 0;
final int end = in.writerIndex();
final int readable = in.readableBytes();
// Looking at the spec we should always have at least enough readable bytes to read a byte here but it seems
// some servers do not respect this for empty names. So just workaround this and return an empty name in this
// case.
//
// See:
// - https://github.com/netty/netty/issues/5014
// - https://www.ietf.org/rfc/rfc1035.txt , Section 3.1
if (readable == 0) {
return ROOT;
}
final StringBuilder name = new StringBuilder(readable << 1);
while (in.isReadable()) {
final int len = in.readUnsignedByte();
final boolean pointer = (len & 0xc0) == 0xc0;
if (pointer) {
if (position == -1) {
position = in.readerIndex() + 1;
}
if (!in.isReadable()) {
throw new CorruptedFrameException("truncated pointer in a name");
}
final int next = (len & 0x3f) << 8 | in.readUnsignedByte();
if (next >= end) {
throw new CorruptedFrameException("name has an out-of-range pointer");
}
in.readerIndex(next);
// check for loops
checked += 2;
if (checked >= end) {
throw new CorruptedFrameException("name contains a loop.");
}
} else if (len != 0) {
if (!in.isReadable(len)) {
throw new CorruptedFrameException("truncated label in a name");
}
name.append(in.toString(in.readerIndex(), len, CharsetUtil.UTF_8)).append('.');
in.skipBytes(len);
} else { // len == 0
break;
}
}
if (position != -1) {
in.readerIndex(position);
}
if (name.length() == 0) {
return ROOT;
}
if (name.charAt(name.length() - 1) != '.') {
name.append('.');
}
return name.toString();
}
Domain
Subdomains
Source
Frequently Asked Questions
What does String() do?
String() is a function in the netty codebase, defined in codec-dns/src/main/java/io/netty/handler/codec/dns/DnsCodecUtil.java.
Where is String() defined?
String() is defined in codec-dns/src/main/java/io/netty/handler/codec/dns/DnsCodecUtil.java at line 53.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free