Class Dnsruby::SingleResolver
In: lib/Dnsruby/SingleResolver.rb
Parent: Object

Dnsruby::SingleResolver

 The SingleResolver class targets a single resolver, and controls the sending of a single
 packet with a packet timeout. It performs no retries. Only two threads are used - the client
 thread and a select thread (which is reused across all queries).

Methods

Synchronous

These methods raise an exception or return a response message with rcode==NOERROR

Asynchronous

These methods use a response queue to return the response and the error

Methods

Attributes

ignore_truncation  [RW]  Don‘t worry if the response is truncated - return it anyway.

Defaults to false

packet_timeout  [RW] 
persistent_tcp  [RW]  Should the TCP socket persist between queries?

Defaults to false

persistent_udp  [RW]  Should the UDP socket persist between queries?

Defaults to false

port  [RW]  The port on the resolver to send queries to.

Defaults to 53

recurse  [RW]  should the Recursion Desired bit be set on queries?

Defaults to true

server  [R]  The address of the resolver to send queries to
src_address  [RW]  The source address to send queries from

Defaults to localhost

src_port  [RW]  The source port to send queries from

Defaults to 0 - random port

tsig_key  [RW] 
udp_size  [RW]  The max UDP packet size

Defaults to 512

use_tcp  [RW]  Use TCP rather than UDP as the transport.

Defaults to false

Public Class methods

Can take a hash with the following optional keys :

  • :server
  • :port
  • :use_tcp
  • :ignore_truncation
  • :src_addr
  • :src_port
  • :udp_size
  • :persistent_tcp
  • :persistent_udp
  • :tsig_key
  • :packet_timeout
  • :recurse

Public Instance methods

Synchronously send a query for the given name. The type will default to A, and the class to IN.

Asynchronously send a Message to the server. A client_queue is supplied by the client, along with a client_query_id to identify the response. When the response is known, the tuple (query_id, response_message, response_exception) is put in the queue for the client to process.

The query is sent synchronously in the caller‘s thread. The select thread is then used to listen for and process the response (up to pushing it to the client_queue). The client thread is then used to retrieve the response and deal with it.

Takes :

  • msg - the message to send
  • client_query_id - an ID to identify the query to the client
  • client_queue - a Queue to push the response to, when it arrives
  • use_tcp - whether to use TCP (defaults to SingleResolver.use_tcp)

Synchronously send a Message to the server. If a valid response is returned, then that is returned to the client. Otherwise a ResolvError or ResolvTimeout will be thrown.

Takes the message to send, and an optional use_tcp parameter which defaults to SingleResolver.use_tcp

Return the packet size to use for UDP

[Validate]