Hi! I wrote an application using PyDNS - SPF queries
(Sender-Permitted-From) neat anti-spam technology.
This uses PyDNS pretty thoroughly, and I discovered some
issues, which I've fixed.
1. On Windows 2000 using DHCP, or using multiple name
servers;
2. DNS.bin2addr() and DNS.addr2bin() don't parse IP
addresses to spec.
3. On Mac OS X, which decides for some reason to leave
'domain' blank in /etc/resolv.conf, causing
DNS.DiscoverNameServers() to fail.
So I fixed them all, with minimal code changes. Patches are
attached.
To fix Windows 2000 DHCP, I added a registry query for
'DhcpNameServer' I also put in a split() so multiple space-
separated names on the list get stuck into defaults['server']
correctly... as a list.
To fix DNS.bin2addr() and DNS.addr2bin(), I use
socket.inet_ntoa() and socket.inet_aton(). The old stuff
couldn't parse perfectly legitimate IP addresses like:
0x7e.0.0.1,
127.1
The old stuff also didn't barf on incorrect addresses like:
127.0.0.256
The upside is that the new code is about twice as fast.
100000 iterations of the new code takes 14.4 seconds on my
G3 powerbook, 100000 iterations of the old code takes 28.0
seconds.
The downside is that now DNS.addr2bin('255.255.255.255')
barfs, cuz the C code for inet_aton cannot differentiate
between error (return -1) and the broadcast addr.
To fix the rude Mac OS X problem, just test to see if
len(fields) > 1.
I also updated the test code so the headers read #!/usr/bin/
env python
The code has been tested on both byte-orderings (Mac
PowerPC and Intel) and Windows 2000 DHCP (1 and 2
servers) and non DHCP,
The patch is attached, you'll probably also get an email
about a patch submission via SourceForge.
Cheers!
terry@wayforward.net
patch to pydns-2.3.0
Logged In: YES
user_id=1300068
Originator: NO
A fix for this issue has been included in the latest python-dns update in Ubuntu Linux. See https://launchpad.net/ubuntu/+source/python-dns/2.3.0-5.1ubuntu2 for details.
Logged In: YES
user_id=1300068
Originator: NO
Fixed in 2.3.1