Search in sources :

Example 6 with DnsQuery

use of io.netty.handler.codec.dns.DnsQuery in project netty by netty.

the class DnsQueryContext method query.

void query(boolean flush, ChannelPromise writePromise) {
    final DnsQuestion question = question();
    final InetSocketAddress nameServerAddr = nameServerAddr();
    final DnsQuery query = newQuery(id);
    query.setRecursionDesired(recursionDesired);
    query.addRecord(DnsSection.QUESTION, question);
    for (DnsRecord record : additionals) {
        query.addRecord(DnsSection.ADDITIONAL, record);
    }
    if (optResource != null) {
        query.addRecord(DnsSection.ADDITIONAL, optResource);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("{} WRITE: {}, [{}: {}], {}", channel(), protocol(), id, nameServerAddr, question);
    }
    sendQuery(query, flush, writePromise);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DnsQuestion(io.netty.handler.codec.dns.DnsQuestion) DnsQuery(io.netty.handler.codec.dns.DnsQuery) DnsRecord(io.netty.handler.codec.dns.DnsRecord)

Aggregations

DnsQuery (io.netty.handler.codec.dns.DnsQuery)6 Channel (io.netty.channel.Channel)5 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)5 SimpleChannelInboundHandler (io.netty.channel.SimpleChannelInboundHandler)5 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)5 DefaultDnsQuestion (io.netty.handler.codec.dns.DefaultDnsQuestion)5 Bootstrap (io.netty.bootstrap.Bootstrap)4 SocketChannel (io.netty.channel.socket.SocketChannel)4 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)4 DefaultDnsQuery (io.netty.handler.codec.dns.DefaultDnsQuery)4 DefaultDnsResponse (io.netty.handler.codec.dns.DefaultDnsResponse)4 ChannelPipeline (io.netty.channel.ChannelPipeline)3 EventLoopGroup (io.netty.channel.EventLoopGroup)3 TcpDnsQueryEncoder (io.netty.handler.codec.dns.TcpDnsQueryEncoder)3 TcpDnsResponseDecoder (io.netty.handler.codec.dns.TcpDnsResponseDecoder)3 Random (java.util.Random)3 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)2 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)2 DnsQuestion (io.netty.handler.codec.dns.DnsQuestion)2 InetSocketAddress (java.net.InetSocketAddress)2