Internet: Use whois-servers.net for all whois lookups.

rs.internic.net seems to be broken and using $tld.whois-servers.net looks to
be working for everything.

Also need to update the line termination string to use '\r\n' instead of '\n'
since some servers are strict about receiving the former.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2010-03-03 08:33:44 -05:00
parent 4a9596608a
commit 397cbbe0d3
2 changed files with 7 additions and 16 deletions

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2003-2005, Jeremiah Fincher
# Copyright (c) 2010, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -61,7 +62,6 @@ class Internet(callbacks.Plugin):
irc.reply('Host not found.')
dns = wrap(dns, ['something'])
_tlds = set(['com', 'net', 'edu'])
_domain = ['Domain Name', 'Server Name', 'domain']
_registrar = ['Sponsoring Registrar', 'Registrar', 'source']
_updated = ['Last Updated On', 'Domain Last Updated Date', 'Updated Date',
@ -76,24 +76,15 @@ class Internet(callbacks.Plugin):
"""
usertld = domain.split('.')[-1]
if '.' not in domain:
irc.error('<domain> must be in .com, .net, .edu, or .org.')
irc.errorInvalid('domain')
return
elif len(domain.split('.')) != 2:
irc.error('<domain> must be a domain, not a hostname.')
return
if usertld in self._tlds:
server = 'rs.internic.net'
search = '=%s' % domain
else:
server = '%s.whois-servers.net' % usertld
search = domain
try:
t = telnetlib.Telnet(server, 43)
t = telnetlib.Telnet('%s.whois-servers.net' % usertld, 43)
except socket.error, e:
irc.error(str(e))
return
t.write(search)
t.write('\n')
t.write(domain)
t.write('\r\n')
s = t.read_all()
server = registrar = updated = created = expires = status = ''
for line in s.splitlines():

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2003-2005, Jeremiah Fincher
# Copyright (c) 2010, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -39,11 +40,10 @@ class InternetTestCase(PluginTestCase):
def testWhois(self):
self.assertNotError('internet whois ohio-state.edu')
self.assertError('internet whois www.ohio-state.edu')
self.assertNotError('internet whois kuro5hin.org')
self.assertError('internet whois www.kuro5hin.org')
self.assertNotError('internet whois microsoft.com')
self.assertNotError('internet whois inria.fr')
self.assertNotError('internet whois slime.com.au')
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: