Change directory structure

This commit is contained in:
Larry Kim 2013-01-28 03:00:32 +09:00
parent 11fbe99fcd
commit 51a108d7d5
11 changed files with 15 additions and 6 deletions

0
src/tlds/ch Normal file
View File

0
src/tlds/com Normal file
View File

0
src/tlds/im Normal file
View File

0
src/tlds/in Normal file
View File

0
src/tlds/jp Normal file
View File

1
src/tlds/kr Normal file
View File

@ -0,0 +1 @@
server = "kr.whois-servers.net"

0
src/tlds/net Normal file
View File

0
src/tlds/org Normal file
View File

0
src/tlds/so Normal file
View File

0
src/tlds/st Normal file
View File

View File

@ -9,18 +9,26 @@ class Whois(object):
self.domain = domain
self.tld = self.domain.split(".")[-1]
self.whoisServers = {}
f = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "whois-servers.conf"), "r")
exec("self.whoisServers = %s"%(f.read()))
self.currPath = os.path.dirname(os.path.realpath(__file__))
self.tldPath = os.path.join(self.currPath, "tlds")
self.tldList = os.listdir(self.tldPath)
def chooseServer(self):
if self.whoisServers.has_key(self.tld):
return self.whoisServers[self.tld]
if self.tld in self.tldList:
settings = {}
execfile(os.path.join(self.tldPath, self.tld), {}, settings)
if "server" in settings:
return settings["server"]
else:
return self.tld + ".whois-servers.net"
else:
return self.tld + ".whois-servers.net"
return self.tld + ".whois-servers.net"
def run(self, redirect=True):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.whoisServer = self.chooseServer()
try:
s.connect((self.whoisServer, 43))
except: