@Override public String toString() { final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('('); final DnsRecordType type = type(); buf.append(name().isEmpty()? "<root>" : name()) .append(' ') .append(timeToLive()) .append(' '); DnsMessageUtil.appendRecordClass(buf, dnsClass()) .append(' ') .append(type.name()); buf.append(' ') .append(hostname); return buf.toString(); } }
/** * Decodes a record from the information decoded so far by {@link #decodeRecord(ByteBuf)}. * * @param name the domain name of the record * @param type the type of the record * @param dnsClass the class of the record * @param timeToLive the TTL of the record * @param in the {@link ByteBuf} that contains the RDATA * @param offset the start offset of the RDATA in {@code in} * @param length the length of the RDATA * * @return a {@link DnsRawRecord}. Override this method to decode RDATA and return other record implementation. */ 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))); } return new DefaultDnsRawRecord( name, type, dnsClass, timeToLive, in.retainedDuplicate().setIndex(offset, offset + length)); }
final PtrDnsAnswer.Builder dnsAnswerBuilder = PtrDnsAnswer.builder(); final String hostname = ptrRecord.hostname(); LOG.trace("PTR record retrieved with hostname [{}]", hostname); return dnsAnswerBuilder.dnsTTL(ptrRecord.timeToLive()) .build();
final PtrDnsAnswer.Builder dnsAnswerBuilder = PtrDnsAnswer.builder(); final String hostname = ptrRecord.hostname(); LOG.trace("PTR record retrieved with hostname [{}]", hostname); return dnsAnswerBuilder.dnsTTL(ptrRecord.timeToLive()) .build();
@Override public String toString() { final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('('); final DnsRecordType type = type(); buf.append(name().isEmpty()? "<root>" : name()) .append(' ') .append(timeToLive()) .append(' '); DnsMessageUtil.appendRecordClass(buf, dnsClass()) .append(' ') .append(type.name()); buf.append(' ') .append(hostname); return buf.toString(); } }
/** * Decodes a record from the information decoded so far by {@link #decodeRecord(ByteBuf)}. * * @param name the domain name of the record * @param type the type of the record * @param dnsClass the class of the record * @param timeToLive the TTL of the record * @param in the {@link ByteBuf} that contains the RDATA * @param offset the start offset of the RDATA in {@code in} * @param length the length of the RDATA * * @return a {@link DnsRawRecord}. Override this method to decode RDATA and return other record implementation. */ 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))); } return new DefaultDnsRawRecord( name, type, dnsClass, timeToLive, in.retainedDuplicate().setIndex(offset, offset + length)); }
@Override public String toString() { final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('('); final DnsRecordType type = type(); buf.append(name().isEmpty()? "<root>" : name()) .append(' ') .append(timeToLive()) .append(' '); DnsMessageUtil.appendRecordClass(buf, dnsClass()) .append(' ') .append(type.name()); buf.append(' ') .append(hostname); return buf.toString(); } }
/** * Decodes a record from the information decoded so far by {@link #decodeRecord(ByteBuf)}. * * @param name the domain name of the record * @param type the type of the record * @param dnsClass the class of the record * @param timeToLive the TTL of the record * @param in the {@link ByteBuf} that contains the RDATA * @param offset the start offset of the RDATA in {@code in} * @param length the length of the RDATA * * @return a {@link DnsRawRecord}. Override this method to decode RDATA and return other record implementation. */ 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) { in.setIndex(offset, offset + length); return new DefaultDnsPtrRecord( name, dnsClass, timeToLive, decodeName0(in.duplicate().setIndex(offset, offset + length))); } return new DefaultDnsRawRecord( name, type, dnsClass, timeToLive, in.duplicate().setIndex(offset, offset + length).retain()); }
@Override public String toString() { final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('('); final DnsRecordType type = type(); buf.append(name().isEmpty()? "<root>" : name()) .append(' ') .append(timeToLive()) .append(' '); DnsMessageUtil.appendRecordClass(buf, dnsClass()) .append(' ') .append(type.name()); buf.append(' ') .append(hostname); return buf.toString(); } }
/** * Decodes a record from the information decoded so far by {@link #decodeRecord(ByteBuf)}. * * @param name the domain name of the record * @param type the type of the record * @param dnsClass the class of the record * @param timeToLive the TTL of the record * @param in the {@link ByteBuf} that contains the RDATA * @param offset the start offset of the RDATA in {@code in} * @param length the length of the RDATA * * @return a {@link DnsRawRecord}. Override this method to decode RDATA and return other record implementation. */ 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))); } return new DefaultDnsRawRecord( name, type, dnsClass, timeToLive, in.retainedDuplicate().setIndex(offset, offset + length)); }
@Override public String toString() { final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('('); final DnsRecordType type = type(); buf.append(name().isEmpty()? "<root>" : name()) .append(' ') .append(timeToLive()) .append(' '); DnsMessageUtil.appendRecordClass(buf, dnsClass()) .append(' ') .append(type.name()); buf.append(' ') .append(hostname); return buf.toString(); } }
/** * Decodes a record from the information decoded so far by {@link #decodeRecord(ByteBuf)}. * * @param name the domain name of the record * @param type the type of the record * @param dnsClass the class of the record * @param timeToLive the TTL of the record * @param in the {@link ByteBuf} that contains the RDATA * @param offset the start offset of the RDATA in {@code in} * @param length the length of the RDATA * * @return a {@link DnsRawRecord}. Override this method to decode RDATA and return other record implementation. */ 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))); } return new DefaultDnsRawRecord( name, type, dnsClass, timeToLive, in.retainedDuplicate().setIndex(offset, offset + length)); }