python中socket修改ttl_Python dns.ttl方法代碼示例

# 需要導入模塊: import dns [as 別名]

# 或者: from dns import ttl [as 別名]

def from_xfr(xfr, zone_factory=Zone, relativize=True, check_origin=True):

"""Convert the output of a zone transfer generator into a zone object.

@param xfr: The xfr generator

@type xfr: generator of dns.message.Message objects

@param relativize: should names be relativized? The default is True.

It is essential that the relativize setting matches the one specified

to dns.query.xfr().

@type relativize: bool

@param check_origin: should sanity checks of the origin node be done?

The default is True.

@type check_origin: bool

@raises dns.zone.NoSOA: No SOA RR was found at the zone origin

@raises dns.zone.NoNS: No NS RRset was found at the zone origin

@rtype: dns.zone.Zone object

"""

z = None

for r in xfr:

if z is None:

if relativize:

origin = r.origin

else:

origin = r.answer[0].name

rdclass = r.answer[0].rdclass

z = zone_factory(origin, rdclass, relativize=relativize)

for rrset in r.answer:

znode = z.nodes.get(rrset.name)

if not znode:

znode = z.node_factory()

z.nodes[rrset.name] = znode

zrds = znode.find_rdataset(rrset.rdclass, rrset.rdtype,

rrset.covers, True)

zrds.update_ttl(rrset.ttl)

for rd in rrset:

rd.choose_relativity(z.origin, relativize)

zrds.add(rd)

if check_origin:

z.check_origin()

return z

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值