From be9128b3ec4b61170eebd98b97e33db8d338dc9b Mon Sep 17 00:00:00 2001 From: James Vega Date: Wed, 3 Mar 2010 08:33:44 -0500 Subject: [PATCH] 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 (cherry picked from commit 397cbbe0d3d8ac2ae6ec17ff4f9bfd4fc3297912) --- plugins/Internet/plugin.py | 19 +++++-------------- plugins/Internet/test.py | 4 ++-- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/plugins/Internet/plugin.py b/plugins/Internet/plugin.py index d2ca86839..490c9165c 100644 --- a/plugins/Internet/plugin.py +++ b/plugins/Internet/plugin.py @@ -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(' must be in .com, .net, .edu, or .org.') + irc.errorInvalid('domain') return - elif len(domain.split('.')) != 2: - irc.error(' 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(): diff --git a/plugins/Internet/test.py b/plugins/Internet/test.py index b4bca2114..e098fdeee 100644 --- a/plugins/Internet/test.py +++ b/plugins/Internet/test.py @@ -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: