| Class | Dnsruby::SingleResolver |
| In: |
lib/Dnsruby/SingleResolver.rb
|
| Parent: | Object |
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).
These methods raise an exception or return a response message with rcode==NOERROR
These methods use a response queue, or an EventMachine::Deferrable to return the response and the error to the client. See Dnsruby::Resolver for details of how to enable the EventMachine implementation. More information about the EventMachine implementation is available in the EVENTMACHINE file in the Dnsruby distribution
| 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 | [R] | The TSIG record to sign/verify messages with |
| udp_size | [R] |
The max UDP packet size
Defaults to 512 |
| use_tcp | [RW] |
Use TCP rather than UDP as the transport.
Defaults to false |
Can take a hash with the following optional keys :
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. The send can be done using just Dnsruby, or using EventMachine.
A client_queue is supplied by the client, along with an optional client_query_id to identify the response. The client_query_id is generated, if not supplied, and returned to the client. 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 :
Returns :
generated if it is not passed in by the client
If the native Dsnruby networking layer is being used, then this method returns the client_query_id
id = res.send_async(msg, queue)
NOT SUPPORTED : id = res.send_async(msg, queue, use_tcp)
id = res.send_async(msg, queue, id)
id = res.send_async(msg, queue, id, use_tcp)
If EventMachine is being used (see Dnsruby::Resolver::use_eventmachine),then this method returns an EM::Deferrable object. If a queue (and ID) is passed in, then the response will also be pushed to the Queue (as well as the deferrable completing).
deferrable = res.send_async(msg)
deferrable = res.send_async(msg, use_tcp)
deferrable = res.send_async(msg, q, id, 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
Sets the TSIG to sign outgoing messages with. Pass in either a Dnsruby::RR::TSIG, or a key_name and key (or just a key) Pass in nil to stop tsig signing. It is possible for client code to sign packets prior to sending - see Dnsruby::RR::TSIG#apply and Dnsruby::Message#sign Note that pre-signed packets will not be signed by SingleResolver.