Change directory structure
This commit is contained in:
parent
11fbe99fcd
commit
51a108d7d5
0
src/tlds/ch
Normal file
0
src/tlds/ch
Normal file
0
src/tlds/com
Normal file
0
src/tlds/com
Normal file
0
src/tlds/im
Normal file
0
src/tlds/im
Normal file
0
src/tlds/in
Normal file
0
src/tlds/in
Normal file
0
src/tlds/jp
Normal file
0
src/tlds/jp
Normal file
1
src/tlds/kr
Normal file
1
src/tlds/kr
Normal file
@ -0,0 +1 @@
|
|||||||
|
server = "kr.whois-servers.net"
|
||||||
0
src/tlds/net
Normal file
0
src/tlds/net
Normal file
0
src/tlds/org
Normal file
0
src/tlds/org
Normal file
0
src/tlds/so
Normal file
0
src/tlds/so
Normal file
0
src/tlds/st
Normal file
0
src/tlds/st
Normal file
20
src/whois.py
20
src/whois.py
@ -9,18 +9,26 @@ class Whois(object):
|
|||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.tld = self.domain.split(".")[-1]
|
self.tld = self.domain.split(".")[-1]
|
||||||
|
|
||||||
self.whoisServers = {}
|
self.currPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
f = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "whois-servers.conf"), "r")
|
self.tldPath = os.path.join(self.currPath, "tlds")
|
||||||
exec("self.whoisServers = %s"%(f.read()))
|
self.tldList = os.listdir(self.tldPath)
|
||||||
|
|
||||||
def chooseServer(self):
|
def chooseServer(self):
|
||||||
if self.whoisServers.has_key(self.tld):
|
if self.tld in self.tldList:
|
||||||
return self.whoisServers[self.tld]
|
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:
|
else:
|
||||||
return self.tld + ".whois-servers.net"
|
return self.tld + ".whois-servers.net"
|
||||||
|
|
||||||
|
|
||||||
def run(self, redirect=True):
|
def run(self, redirect=True):
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
self.whoisServer = self.chooseServer()
|
||||||
try:
|
try:
|
||||||
s.connect((self.whoisServer, 43))
|
s.connect((self.whoisServer, 43))
|
||||||
except:
|
except:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user