本文整理汇总了Python中DNS.revlookup方法的典型用法代码示例。如果您正苦于以下问题:Python DNS.revlookup方法的具体用法?Python DNS.revlookup怎么用?Python DNS.revlookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DNS
的用法示例。
在下文中一共展示了DNS.revlookup方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testLazy
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
def testLazy(self):
x = DNS.lazy.mxlookup('lathspell.de')
self.assertEqual([(10, "mail3av.westend.com")], x)
x = DNS.revlookup("212.117.79.2")
self.assertEqual("www2.westend.com", x)
reqobj=DNS.Request(server='dns1.netcologne.de')
x = reqobj.req("lathspell.de", qtype=DNS.Type.A)
self.assertEqual("NOERROR", x.header['status'])
self.assertEqual(1, x.header['aa']) # authoritative answer
self.assertEqual(1, len(x.answers))
self.assertEqual('212.117.79.2', x.answers[0]['data'])
示例2: getDomainPtrEntry
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
def getDomainPtrEntry(self,ip,timeout = 5,dnsservers = ['8.8.8.8', '8.8.4.4']):
try:
if (ip != ""):
DNS.defaults['server'] = dnsservers
DNS.defaults['timeout'] = timeout
resul = DNS.revlookup(ip)
if (len(resul) > 0):
return resul
else:
return -1
else:
return -1
except DNS.ServerError as e:
if e.rcode == 3:
return -1
else:
return -2
except Exception as e:
return -2
示例3: __call__
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
def __call__(self, line):
for pat in (self.pat, self.php_error_pat):
m = pat.match(line)
if m: break
if not m: return line
gd = m.groupdict()
gd['x'] = self.x
# reverse lookup client
if gd.get('client') == self.last_ip:
gd['client'] = gd['client-dn'] = ''
else:
self.last_ip = gd.get('client')
try:
gd['client-dn'] = self.dns_format.format('', DNS.revlookup(gd['client']), **gd)
except DNS.DNSError, e:
gd['client-dn'] = self.dns_format.format('', '(%s)' % str(e), **gd)
except:
示例4:
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
# Uses PyDNS.
import DNS
#req = DNS.Request( name="www.google.com", qtype="A", protocol= "udp", server="10.211.55.3" )
#req = DNS.Request( name="www.google.com", qtype="A", protocol= "udp", server="127.0.0.1" )
#req = DNS.Request( name="www.google.com", qtype="A", protocol= "udp", server="localhost" )
#print "www.google.com: ", req.req().show()
tlds = ["com", "net", "org"] # add more here.
name = DNS.revlookup( "77.46.197.147" )
names = name.split('.')
while names and names[0] not in tlds:
name = "_bittorrent._tcp." + ".".join(names)
req = DNS.Request( name=name, qtype="SRV", protocol="udp", server="localhost")
response = req.req()
if response.answers:
break
del names[0]
print "response=", response.show()
示例5: nameserver
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
#!/opt/python/bin/python1.5
import DNS
# automatically load nameserver(s) from /etc/resolv.conf
# (works on unix - on others, YMMV)
DNS.ParseResolvConf()
r=DNS.Request(qtype='mx')
res = r.req('connect.com.au')
res.show()
r=DNS.Request(qtype='soa')
res = r.req('connect.com.au')
res.show()
print DNS.revlookup('192.189.54.17')
示例6: range
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
import DNS
DNS.AddNameServer('172.16.0.4')
res = []
res2 = []
for i in range(255):
for j in range(254):
yo = '172.16.%s.%s' % (i, j)
try:
print "%s - %s" % (yo, DNS.revlookup(yo))
pizda = DNS.revlookup(yo)
res.append([yo, pizda])
res2.append(pizda.lower() + "\n")
except:
#print "%s - error" % (yo)
pass
print len(res)
open("wss_1.txt", "w").writelines(res2)
示例7: nameserver
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
#!/usr/bin/python3
import sys ; sys.path.insert(0, '..')
import DNS
# automatically load nameserver(s) from /etc/resolv.conf
# (works on unix - on others, YMMV)
DNS.ParseResolvConf()
r=DNS.Request(qtype='mx')
res = r.req('connect.com.au')
res.show()
r=DNS.Request(qtype='soa')
res = r.req('connect.com.au')
res.show()
print(DNS.revlookup('192.189.54.17'))
示例8: range
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
import DNS
DNS.AddNameServer('172.16.0.4')
res = []
res2 = []
for i in range(255):
for j in range(254):
try:
yo = '172.16.%s.%s' % (i, j)
print "%s - %s" % (yo, DNS.revlookup(yo))
res.append([yo, DNS.revlookup(yo)])
res2.append(DNS.revlookup(yo).lower() + "\n")
except:
#print "error"
pass
print len(res)
open("wss.txt", "w").writelines(res2)
示例9: eat_input
# 需要导入模块: import DNS [as 别名]
# 或者: from DNS import revlookup [as 别名]
eat_input()
hostname = m.group('host')
m = re.match("^(?P<host>.*):(?P<port>[0-9]+)$", hostname)
if m:
host = m.group('host')
port = m.group('port')
else:
port = "80"
if port != "25":
bad_port(hostname);
sys.exit()
if is_ipaddr(host):
try:
hostname = DNS.revlookup(host)
except:
hostname = ""
elif re.match("^.*\.(edu|com|org)$", host):
hostname = host
else:
hostname = ""
good_port();
arguments = [sys.argv[0]]
if hostname != "":
arguments.append("-h")
arguments.append(hostname)
for arg in sys.argv[1:]:
arguments.append(arg)