[Sussex] Ruby DNS library MX resolution problem

Thomas Adam thomas at edulinux.homeunix.org
Mon Jun 20 12:22:20 UTC 2005


On Mon, Jun 20, 2005 at 12:22:51PM +0100, Ronan Chilvers wrote:
>
> Why is it that an explicit string works, but using a property with
> .to_s (or without for that matter doesn't), despite the fact that it
> echoes out the domain name correctly (it just won't do any resolution
> on it).

Well, I can't seem to reproduce your problem.  Here's my irb session
output:

  >> class Checker
  >> def initialize(address)
  >>   @recipient, @domain = address.split("@", 2)
  >>   puts "Checking #{@domain.to_s}"
  >>   Resolv::DNS.open() {|dns|
  ?>       dns.getresources("#{@domain.to_str}",
  ?>       Resolv::DNS::Resource::IN::MX).collect {|rec|
  ?>         puts rec.exchange.to_s
  >>       }
  >>   }
  >> #rescue StandardError => err
  ?> #puts err
  ?> end
  >> end
  => nil
  >> 
  ?> d=Checker.new("foo at hotmail.com")
  Checking hotmail.com
  mx3.hotmail.com
  mx4.hotmail.com
  mx1.hotmail.com
  mx2.hotmail.com
  => #<Checker:0x403d6700 @domain="hotmail.com", @recipient="foo">

Note that I transliterated the instance variable to interpolate
"#{@domain.to_str}".  But even without that, it still resolves.

-- Thomas Adam

--  
"One of us is a cigar stand, and one of us is a lovely blue incandescent
guillotine" -- Stephen Malkmus, "Type Slowly" from "Brighten The Corners"




More information about the Sussex mailing list