Method: Dnsruby::Resolver#initialize
- Defined in:
- lib/dnsruby/resolver.rb
#initialize(*args) ⇒ Resolver
Create a new Resolver object. If no parameters are passed in, then the default system configuration will be used. Otherwise, a Hash may be passed in with the following optional elements :
- :port
- :use_tcp
- :tsig
- :ignore_truncation
- :src_address
- :src_address6
- :src_port
- :recurse
- :udp_size
- :config_info - see Config
- :nameserver - can be either a String or an array of Strings
- :packet_timeout
- :query_timeout
- :retry_times
- :retry_delay
- :do_caching
- :tcp_pipelining
- :tcp_pipelining_max_queries - can be a number or :infinite symbol
- :tcp_idle_timeout - positive seconds, defaults to 10
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'lib/dnsruby/resolver.rb', line 475 def initialize(*args) # @TODO@ Should we allow :nameserver to be an RRSet of NS records? Would then need to randomly order them? @resolver_ruby = nil @src_address = nil @src_address6 = nil @single_res_mutex = Mutex.new @process_pid = Process.pid @configured = false @do_caching = true @config = Config.new() reset_attributes # Process args if args.length == 1 if args[0].class == Hash args[0].keys.each do |key| begin if key == :config_info @config.set_config_info(args[0][:config_info]) add_config_nameservers elsif key == :nameserver set_config_nameserver(args[0][:nameserver]) elsif key == :nameservers set_config_nameserver(args[0][:nameservers]) else send(key.to_s + '=', args[0][key]) end rescue Exception => e raise if key.to_s == 'tsig' || ValidationBudget.abort?(e) Dnsruby.log.error{"Argument #{key} not valid : #{e}\n"} end end elsif args[0].class == String set_config_nameserver(args[0]) elsif args[0].class == Config # also accepts a Config object from Dnsruby::Resolv @config = args[0] end else # Anything to do? end update end |