Skip to content
This repository

Aug 17, 2011

  1. Simone Carletti

    Fixed `Errno::EINVAL: Invalid argument - bind(2)' error that occasion…

    …ally might occur connecting to a WHOIS server.
    
    This bug is related to issue #40. In fact, the cause of this bug is the workaround introduced in commit ffbbaff to solve the incompatibility with TCPSocket.new when resolv-replace.rb is required and you're trying to pass a nil value as :local_host argument to TCPSocket.new. The workaround was to always default the :local_host to "0.0.0.0", that obviously means localhost. Unfortunately,
    
    This solution works quite well as long as there are not connectivity or server issues. In fact, when for whatever reason "0.0.0.0" can't connect to the remote host, you get an error `Errno::EINVAL: Invalid argument - bind(2)'. Because I don't wont to add extra-complexity when not required, I decided to revert to the original code and default :local_host and :local_port to nil when they are not present. But hey, an other issue is just around the corner!
    
    It turns that resolv-replace.rb tries to resolve the :local_host even if it's nil (ruby bug?) because it checks the existence of any local parameter, regardless you are providing :local_port or local_host.
    
        class TCPSocket < IPSocket
          # :stopdoc:
          alias original_resolv_initialize initialize
          # :startdoc:
          def initialize(host, serv, *rest)
            rest[0] = IPSocket.getaddress(rest[0]) unless rest.empty?
            original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
          end
        end
    
    While the following statement is perfectly fine with TCPSocket
    
        TCPSocket.new("whois.nic.it", 43, nil, nil)
    
    it doesn't work when you require resolv-replace.rb.
    
        ArgumentError: cannot interpret as DNS name: nil
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:1121:in `create'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:967:in `generate_candidates'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:992:in `resolv'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:498:in `each_resource'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:391:in `each_address'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:115:in `block in each_address'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:114:in `each'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:114:in `each_address'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:92:in `getaddress'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv.rb:43:in `getaddress'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv-replace.rb:10:in `getaddress'
        	from /Users/weppos/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/resolv-replace.rb:22:in `initialize'
    
    At this point, the only solution is to check the :local_host and :local_port parameter and avoid passing them if nil.
    authored

Mar 15, 2011

  1. Simone Carletti

    Rename Whois::Answer to Whois::Record

    authored

Jan 24, 2011

  1. Simone Carletti

    Fixed incompatibility with Ruby 1.8.7 resolv-replace and :bind_host (…

    …references #40).
    
    When bind_host is not passed, the following error is raised: 
    
        ArgumentError: cannot interpret as DNS name: nil
        
        /usr/local/lib/ruby/1.8/resolv.rb:1060:in `create'
        /usr/local/lib/ruby/1.8/resolv.rb:906:in `generate_candidates'
        /usr/local/lib/ruby/1.8/resolv.rb:931:in `resolv'
        /usr/local/lib/ruby/1.8/resolv.rb:481:in `each_resource'
        /usr/local/lib/ruby/1.8/resolv.rb:386:in `each_address'
        /usr/local/lib/ruby/1.8/resolv.rb:115:in `each_address'
        /usr/local/lib/ruby/1.8/resolv.rb:114:in `each'
        /usr/local/lib/ruby/1.8/resolv.rb:114:in `each_address'
        /usr/local/lib/ruby/1.8/resolv.rb:92:in `getaddress'
        /usr/local/lib/ruby/1.8/resolv.rb:43:in `getaddress'
        /usr/local/lib/ruby/1.8/resolv-replace.rb:8:in `getaddress'
        /usr/local/lib/ruby/1.8/resolv-replace.rb:18:in `initialize'
    authored

Dec 20, 2010

  1. Simone Carletti

    When a :bind_host or :bind_port are supplied, the TCPSocket is binded…

    … to given local settings.
    authored
  2. Simone Carletti

    Convert Test::Unit to RSpec

    authored
Something went wrong with that request. Please try again.