本文整理汇总了Python中twisted.names.dns.SOA属性的典型用法代码示例。如果您正苦于以下问题:Python dns.SOA属性的具体用法?Python dns.SOA怎么用?Python dns.SOA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类twisted.names.dns
的用法示例。
在下文中一共展示了dns.SOA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_authority
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def test_authority(self):
"""
Two L{dns.Message} instances compare equal if they have the same
authority records.
"""
self.assertNormalEqualityImplementation(
self.messageFactory(authority=[dns.RRHeader(
b'example.com',
type=dns.SOA, payload=dns.Record_SOA())]),
self.messageFactory(authority=[dns.RRHeader(
b'example.com',
type=dns.SOA, payload=dns.Record_SOA())]),
self.messageFactory(authority=[dns.RRHeader(
b'example.org',
type=dns.SOA, payload=dns.Record_SOA())]),
)
示例2: lookupZone
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def lookupZone(self, name, timeout = 10):
if self.soa[0].lower() == name.lower():
# Wee hee hee hooo yea
default_ttl = max(self.soa[1].minimum, self.soa[1].expire)
if self.soa[1].ttl is not None:
soa_ttl = self.soa[1].ttl
else:
soa_ttl = default_ttl
results = [dns.RRHeader(self.soa[0], dns.SOA, dns.IN, soa_ttl, self.soa[1], auth=True)]
for (k, r) in self.records.items():
for rec in r:
if rec.ttl is not None:
ttl = rec.ttl
else:
ttl = default_ttl
if rec.TYPE != dns.SOA:
results.append(dns.RRHeader(k, rec.TYPE, dns.IN, ttl, rec, auth=True))
results.append(results[0])
return defer.succeed((results, (), ()))
return defer.fail(failure.Failure(dns.DomainError(name)))
示例3: class_IN
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def class_IN(self, ttl, type, domain, rdata):
record = getattr(dns, 'Record_%s' % type, None)
if record:
r = record(*rdata)
r.ttl = ttl
self.records.setdefault(domain.lower(), []).append(r)
print 'Adding IN Record', domain, ttl, r
if type == 'SOA':
self.soa = (domain, r)
else:
raise NotImplementedError, "Record type %r not supported" % type
#
# This file ends here. Read no further.
#
示例4: messageReceived
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def messageReceived(self, message, protocol):
# Caveat: We have to handle two cases: All records are in 1
# message, or all records are in N messages.
# According to http://cr.yp.to/djbdns/axfr-notes.html,
# 'authority' and 'additional' are always empty, and only
# 'answers' is present.
self.records.extend(message.answers)
if not self.records:
return
if not self.soa:
if self.records[0].type == dns.SOA:
#print "first SOA!"
self.soa = self.records[0]
if len(self.records) > 1 and self.records[-1].type == dns.SOA:
#print "It's the second SOA! We're done."
if self.timeoutCall is not None:
self.timeoutCall.cancel()
self.timeoutCall = None
if self.deferred is not None:
self.deferred.callback(self.records)
self.deferred = None
示例5: lookupZone
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def lookupZone(self, name, timeout=10):
if self.soa[0].lower() == name.lower():
# Wee hee hee hooo yea
default_ttl = max(self.soa[1].minimum, self.soa[1].expire)
if self.soa[1].ttl is not None:
soa_ttl = self.soa[1].ttl
else:
soa_ttl = default_ttl
results = [
dns.RRHeader(
self.soa[0], dns.SOA, dns.IN, soa_ttl, self.soa[1],
auth=True
)
]
for (k, r) in self.records.items():
for rec in r:
if rec.ttl is not None:
ttl = rec.ttl
else:
ttl = default_ttl
if rec.TYPE != dns.SOA:
results.append(
dns.RRHeader(
k, rec.TYPE, dns.IN, ttl, rec, auth=True
)
)
results.append(results[0])
return defer.succeed((results, (), ()))
return defer.fail(failure.Failure(dns.DomainError(name)))
示例6: class_IN
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def class_IN(self, ttl, type, domain, rdata):
"""
Simulate a class IN and recurse into the actual class.
@param ttl: time to live for the record
@type ttl: L{int}
@param type: record type
@type type: str
@param domain: the domain
@type domain: bytes
@param rdata:
@type rdate: bytes
"""
record = getattr(dns, 'Record_%s' % (nativeString(type),), None)
if record:
r = record(*rdata)
r.ttl = ttl
self.records.setdefault(domain.lower(), []).append(r)
if type == 'SOA':
self.soa = (domain, r)
else:
raise NotImplementedError(
"Record type %r not supported" % (nativeString(type),)
)
示例7: _cbZone
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def _cbZone(self, zone):
ans, _, _ = zone
self.records = r = {}
for rec in ans:
if not self.soa and rec.type == dns.SOA:
self.soa = (str(rec.name).lower(), rec.payload)
else:
r.setdefault(str(rec.name).lower(), []).append(rec.payload)
示例8: lookupAuthority
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def lookupAuthority(self, name, timeout=None):
return self._lookup(name, dns.IN, dns.SOA, timeout)
示例9: test_authority
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def test_authority(self):
"""Test DNS 'SOA' record queries"""
return self.namesTest(
self.resolver.lookupAuthority('test-domain.com'),
[soa_record]
)
示例10: test_soa
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def test_soa(self):
"""
The repr of a L{dns.Record_SOA} instance includes all of the
authority fields.
"""
self.assertEqual(
repr(dns.Record_SOA(mname=b'mName', rname=b'rName', serial=123,
refresh=456, retry=789, expire=10,
minimum=11, ttl=12)),
"<SOA mname=mName rname=rName serial=123 refresh=456 "
"retry=789 expire=10 minimum=11 ttl=12>")
示例11: test_authorityOverride
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def test_authorityOverride(self):
"""
L{dns._EDNSMessage.authority} can be overridden in the constructor.
"""
msg = self.messageFactory(
authority=[
dns.RRHeader(
b'example.com',
type=dns.SOA,
payload=dns.Record_SOA())])
self.assertEqual(
msg.authority,
[dns.RRHeader(b'example.com', type=dns.SOA,
payload=dns.Record_SOA())])
示例12: test_lookupAuthority
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def test_lookupAuthority(self):
"""
See L{test_lookupAddress}
"""
d = client.lookupAuthority(self.hostname)
d.addCallback(self.checkResult, dns.SOA)
return d
示例13: lookupAuthority
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def lookupAuthority(self, name, timeout = None):
"""
@see: twisted.names.client.lookupAuthority
"""
return self._lookup(name, dns.IN, dns.SOA, timeout)
示例14: testAuthority
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def testAuthority(self):
"""Test DNS 'SOA' record queries"""
return self.namesTest(
self.resolver.lookupAuthority('test-domain.com'),
[soa_record]
)
示例15: setUp
# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import SOA [as 别名]
def setUp(self):
self.results = None
self.d = defer.Deferred()
self.d.addCallback(self._gotResults)
self.controller = client.AXFRController('fooby.com', self.d)
self.soa = dns.RRHeader(name='fooby.com', type=dns.SOA, cls=dns.IN, ttl=86400, auth=False,
payload=dns.Record_SOA(mname='fooby.com',
rname='hooj.fooby.com',
serial=100,
refresh=200,
retry=300,
expire=400,
minimum=500,
ttl=600))
self.records = [
self.soa,
dns.RRHeader(name='fooby.com', type=dns.NS, cls=dns.IN, ttl=700, auth=False,
payload=dns.Record_NS(name='ns.twistedmatrix.com', ttl=700)),
dns.RRHeader(name='fooby.com', type=dns.MX, cls=dns.IN, ttl=700, auth=False,
payload=dns.Record_MX(preference=10, exchange='mail.mv3d.com', ttl=700)),
dns.RRHeader(name='fooby.com', type=dns.A, cls=dns.IN, ttl=700, auth=False,
payload=dns.Record_A(address='64.123.27.105', ttl=700)),
self.soa
]