alexdalitz / dnsruby

Dnsruby is a feature-complete DNS(SEC) client for Ruby, as used by many of the world's largest DNS registries and the OpenDNSSEC project
Other
197 stars 77 forks source link

ArgumentError (invalid port config: nil) on Dns.new() with no network connection #153

Closed smlsml closed 5 years ago

smlsml commented 5 years ago

Calling Dnsruby::DNS.new without a network connection raises and error:

2.5.5 :002 > require "dnsruby"
 => true 
2.5.5 :003 > Dnsruby::VERSION
 => "1.61.2" 
2.5.5 :004 > Dnsruby::DNS.new
Traceback (most recent call last):
        9: from /Users/loaner/.rvm/rubies/ruby-2.5.5/bin/irb:11:in `<main>'
        8: from (irb):4
        7: from (irb):4:in `new'
        6: from /Users/loaner/.rvm/gems/ruby-2.5.5@manager-ruby255/gems/dnsruby-1.61.2/lib/dnsruby/DNS.rb:121:in `initialize'
        5: from /Users/loaner/.rvm/gems/ruby-2.5.5@manager-ruby255/gems/dnsruby-1.61.2/lib/dnsruby/config.rb:80:in `set_config_info'
        4: from /Users/loaner/.rvm/gems/ruby-2.5.5@manager-ruby255/gems/dnsruby-1.61.2/lib/dnsruby/config.rb:97:in `parse_config'
        3: from /Users/loaner/.rvm/gems/ruby-2.5.5@manager-ruby255/gems/dnsruby-1.61.2/lib/dnsruby/config.rb:97:in `synchronize'
        2: from /Users/loaner/.rvm/gems/ruby-2.5.5@manager-ruby255/gems/dnsruby-1.61.2/lib/dnsruby/config.rb:137:in `block in parse_config'
        1: from /Users/loaner/.rvm/gems/ruby-2.5.5@manager-ruby255/gems/dnsruby-1.61.2/lib/dnsruby/config.rb:170:in `port='
ArgumentError (invalid port config: nil)

This used to work in 1.60.2 -- obviously in production the lack of a network connection causes other problems, but we want/expect our rspecs to run without network or reliance on the DNS config of the worker (CI) machine.

It looks like this was introduced when this was added:

Be able to supply port to Dnsruby::DNS

100 opened on Feb 4, 2016 by dentarg • updated on Jul 4, 2018

This would fix it:

- send("port=", p)
+ send("port=", p || @port)
alexdalitz commented 5 years ago

Thanks for this! Thanks to your patches, this should now be fixed.

smlsml commented 5 years ago

Thanks for the thanks and the quick actions and responses! Love it!