[Sussex] Ruby DNS library MX resolution problem
Ronan Chilvers
ronan at thelittledot.com
Mon Jun 20 11:22:06 UTC 2005
Hi folks
Is anyone a ruby user here? Having a problem which I
can't understand
- I think the reasons are beyond my knowledge so need someone to hand
hold me. I'm trying to write a script to (at its most basic), read in
a list of email addresses from a file and produce a list of MXs for
each email address' domain. The MX resolution is causing me
headaches. I have a Checker class which gets initialized elsewhere
into an array of threads which scuttle off to do their thang. The start
of the class definition is as follows:-
class Checker
def initialize(address)
@recipient, @domain = address.split("@", 2)
puts "Checking #{@domain.to_s}"
Resolv::DNS.open() {|dns|
dns.getresources(@domain.to_s,
Resolv::DNS::Resource::IN::MX).collect {|rec| puts
rec.exchange.to_s }
}
rescue StandardError => err
puts err
end
<snip some methods, etc>
end
The DNS never resolves - it always returns an error. However if I
replace the dns.getresources line with
dns.getresources("hotmail.com",
Resolv::DNS::Resource::IN::MX).collect {|rec| puts
rec.exchange.to_s }
(note the explicit provision of a domain name) it resolves the MXs just
fine. Works for any domain name, even ones that it has failed for with
the original code.
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).
Hope the above code survived enough to be readable.
Anyone got any clues before I go completely insane? I'm
rapidly losing my hair, fingernails and patience, in that order!!!!!!!!
BTW, lovely weather innit!?!
Cheers
Ronan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20050620/b01b67ae/attachment.pgp
More information about the Sussex
mailing list