Class: Dnsruby::SingleResolver
- Defined in:
- lib/dnsruby/single_resolver.rb
Overview
Dnsruby::SingleResolver
This class has been deprecated.
This implementation exists for legacy clients. New code should use the Dnsruby::Resolver class.
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
-
Dnsruby::SingleResolver#send_message(msg [, use_tcp]))
-
Dnsruby::SingleResolver#query(name [, type [, klass]])
Asynchronous
These methods use a response queue to return the response and the error to the client. Support for EventMachine has been deprecated
-
Dnsruby::SingleResolver#send_async(…)
Constant Summary
Constants inherited from Resolver
Resolver::AbsoluteMinDnssecUdpSize, Resolver::DefaultDnssec, Resolver::DefaultPacketTimeout, Resolver::DefaultPipeLiningMaxQueries, Resolver::DefaultPort, Resolver::DefaultQueryTimeout, Resolver::DefaultRetryDelay, Resolver::DefaultRetryTimes, Resolver::DefaultUDPSize, Resolver::MinDnssecUdpSize
Instance Attribute Summary
Attributes inherited from Resolver
#config, #dnssec, #do_caching, #do_validation, #ignore_truncation, #no_tcp, #packet_timeout, #port, #recurse, #retry_delay, #retry_times, #src_address, #src_address6, #tcp_pipelining, #tcp_pipelining_max_queries, #tsig, #udp_size, #use_tcp
Instance Method Summary collapse
-
#add_opt_rr(m) ⇒ Object
Add the appropriate EDNS OPT RR for the specified packet.
-
#initialize(*args) ⇒ SingleResolver
constructor
Can take a hash with the following optional keys :.
- #packet_timeout=(t) ⇒ Object (also: #query_timeout=)
-
#retry_delay=(n) ⇒ Object
:nodoc:.
-
#retry_times=(n) ⇒ Object
:nodoc:.
- #server ⇒ Object
- #server=(s) ⇒ Object
Methods inherited from Resolver
#add_config_nameservers, #add_server, #add_src_port, check_port, #close, #generate_timeouts, get_ports_from, get_tsig, #nameserver=, #nameservers=, #persistent_tcp=, #persistent_udp=, port_in_range, #query, #query!, #query_no_validation_or_recursion, #query_raw, #reset_attributes, #send_async, #send_message, #send_message!, #send_plain_message, #set_config_nameserver, #single_res_mutex, #single_resolvers, #single_resolvers=, #src_port, #src_port=, #update, #update_internal_res
Constructor Details
#initialize(*args) ⇒ SingleResolver
Can take a hash with the following optional keys :
* :server
* :port
* :use_tcp
* :no_tcp
* :ignore_truncation
* :src_address
* :src_address6
* :src_port
* :udp_size
* :persistent_tcp
* :persistent_udp
* :tsig
* :packet_timeout
* :recurse
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/dnsruby/single_resolver.rb', line 57 def initialize(*args) arg=args[0] @single_res_mutex = Mutex.new @packet_timeout = Resolver::DefaultPacketTimeout @query_timeout = @packet_timeout @port = Resolver::DefaultPort @udp_size = Resolver::DefaultUDPSize @dnssec = Resolver::DefaultDnssec @use_tcp = false @no_tcp = false @tsig = nil @ignore_truncation = false @src_address = nil @src_address6 = nil @src_port = [0] @recurse = true @persistent_udp = false @persistent_tcp = false @retry_times = 1 @retry_delay = 0 @single_resolvers = [] @configured = false @do_caching = true @config = Config.new if (arg==nil) # Get default config @config = Config.new @config.get_ready @server = @config.nameserver[0] elsif (arg.kind_of?String) @config.get_ready @configured= true @config.nameserver=[arg] @server = @config.nameserver[0] # @server=arg elsif (arg.kind_of?Name) @config.get_ready @configured= true @config.nameserver=arg @server = @config.nameserver[0] # @server=arg elsif (arg.kind_of?Hash) arg.keys.each do |attr| if (attr == :server) @config.get_ready @configured= true @config.nameserver=[arg[attr]] @server = @config.nameserver[0] else begin send(attr.to_s+"=", arg[attr]) rescue Exception Dnsruby.log.error{"Argument #{attr} not valid\n"} end end end end isr = PacketSender.new({:server=>@server, :port=>@port, :dnssec=>@dnssec, :use_tcp=>@use_tcp, :no_tcp=>@no_tcp, :packet_timeout=>@packet_timeout, :tsig => @tsig, :ignore_truncation=>@ignore_truncation, :src_address=>@src_address, :src_address6=>@src_address6, :src_port=>@src_port, :recurse=>@recurse, :udp_size=>@udp_size}) @single_resolvers = [isr] # ResolverRegister::register_single_resolver(self) end |
Instance Method Details
#add_opt_rr(m) ⇒ Object
Add the appropriate EDNS OPT RR for the specified packet. This is done
automatically, unless you are using Resolver#send_plain_message
168 169 170 171 172 |
# File 'lib/dnsruby/single_resolver.rb', line 168 def add_opt_rr(m) @single_res_mutex.synchronize { @single_resolvers[0].add_opt_rr(m) } end |
#packet_timeout=(t) ⇒ Object Also known as: query_timeout=
161 162 163 164 |
# File 'lib/dnsruby/single_resolver.rb', line 161 def packet_timeout=(t) @packet_timeout = t @query_timeout = t end |
#retry_delay=(n) ⇒ Object
:nodoc:
157 158 159 |
# File 'lib/dnsruby/single_resolver.rb', line 157 def retry_delay=(n) # :nodoc: raise NoMethodError.new("SingleResolver does not have retry_delay") end |
#retry_times=(n) ⇒ Object
:nodoc:
154 155 156 |
# File 'lib/dnsruby/single_resolver.rb', line 154 def retry_times=(n) # :nodoc: raise NoMethodError.new("SingleResolver does not have retry_times") end |
#server ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/dnsruby/single_resolver.rb', line 144 def server # @single_res_mutex.synchronize { if (!@configured) @config.get_ready add_config_nameservers end return @single_resolvers[0].server # } end |
#server=(s) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/dnsruby/single_resolver.rb', line 128 def server=(s) if (!@configured) @config.get_ready end @server = Config.resolve_server(s).to_s isr = PacketSender.new({:server=>@server, :dnssec=>@dnssec, :use_tcp=>@use_tcp, :no_tcp=>@no_tcp, :packet_timeout=>@packet_timeout, :tsig => @tsig, :ignore_truncation=>@ignore_truncation, :src_address=>@src_address, :src_address6=>@src_address6, :src_port=>@src_port, :recurse=>@recurse, :udp_size=>@udp_size}) @single_res_mutex.synchronize { @single_resolvers = [isr] } end |