public class DnsResponseDecoder
extends io.netty.handler.codec.MessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>
DatagramPacket
and encodes to
DnsResponse
. This class also contains methods for decoding parts of
DnsResponses such as questions and resource records.Constructor and Description |
---|
DnsResponseDecoder() |
Modifier and Type | Method and Description |
---|---|
protected void |
decode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.socket.DatagramPacket packet,
List<Object> out)
Decodes a response from a
DatagramPacket containing a
ByteBuf with a DNS packet. |
protected static DnsResponse |
decodeResponse(io.netty.buffer.ByteBuf buf,
io.netty.buffer.ByteBufAllocator allocator)
Decodes a full DNS response packet.
|
static String |
getName(io.netty.buffer.ByteBuf buf,
int offset)
Retrieves a domain name given a buffer containing a DNS packet without
advancing the readerIndex for the buffer.
|
static String |
readName(io.netty.buffer.ByteBuf buf)
Retrieves a domain name given a buffer containing a DNS packet.
|
acceptInboundMessage, channelRead
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
handlerAdded, handlerRemoved, isSharable
public static String readName(io.netty.buffer.ByteBuf buf)
buf
- the byte buffer containing the DNS packetpublic static String getName(io.netty.buffer.ByteBuf buf, int offset)
buf
- the byte buffer containing the DNS packetoffset
- the position at which the name beginsprotected static DnsResponse decodeResponse(io.netty.buffer.ByteBuf buf, io.netty.buffer.ByteBufAllocator allocator)
buf
- the raw DNS response packetDnsResponse
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.socket.DatagramPacket packet, List<Object> out) throws Exception
DatagramPacket
containing a
ByteBuf
with a DNS packet. Responses are sent from a DNS server
to a client in response to a query. This method writes the decoded
response to the specified List
to be handled by a specialized
message handler.decode
in class io.netty.handler.codec.MessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>
ctx
- the ChannelHandlerContext
this
DnsResponseDecoder
belongs topacket
- the message being decoded, a DatagramPacket
containing
a DNS packetout
- the List
to which decoded messages should be addedException
Copyright © 2015. All Rights Reserved.