3
¢báW$- ã @ s¼ d Z ddlZddlmZ ddlZddlZddlZddlZddl Zddl
ZddlmZ ej
jZG dd„ dejjƒZG dd „ d ejjƒZG d
d„ dej
jƒZdd
„ Zdd„ Zdd„ Zdd„ ZdS )zHDNS rdatasets (an rdataset is a set of rdatas of a given type and class)é N)ÚStringIOé )Ústring_typesc @ s e Zd ZdZdS )ÚDifferingCoversz~An attempt was made to add a DNS SIG/RRSIG whose covered type
is not the same as that of the other rdatas in the rdataset.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r
r
ú/usr/lib/python3.6/rdataset.pyr ! s r c @ s e Zd ZdZdS )ÚIncompatibleTypesz?An attempt was made to add DNS RR data of an incompatible type.N)r r r r r
r
r
r r ' s r c sº e Zd ZdZddddgZejjf‡ fdd„ Z‡ fdd „Z d
d„ Z
d$‡ fd
d„ Z‡ fdd„Z‡ fdd„Z
‡ fdd„Zdd„ Zdd„ Z‡ fdd„Zdd„ Zd%dd„Zd&d d!„Zd"d#„ Z‡ ZS )'ÚRdatasetaÝ A DNS rdataset.
@ivar rdclass: The class of the rdataset
@type rdclass: int
@ivar rdtype: The type of the rdataset
@type rdtype: int
@ivar covers: The covered type. Usually this value is
dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or
dns.rdatatype.RRSIG, then the covers value will be the rdata
type the SIG/RRSIG covers. The library treats the SIG and RRSIG
types as if they were a family of
types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA). This makes RRSIGs much
easier to work with than if RRSIGs covering different rdata
types were aggregated into a single RRSIG rdataset.
@type covers: int
@ivar ttl: The DNS TTL (Time To Live) value
@type ttl: int
ÚrdclassÚrdtypeÚcoversÚttlc s* t t| ƒjƒ || _|| _|| _d| _dS )z©Create a new rdataset of the specified class and type.
@see: the description of the class instance variables for the
meaning of I{rdclass} and I{rdtype}r N)Úsuperr
Ú__init__r r r r )Úselfr r r )Ú __class__r
r r C s
zRdataset.__init__c s2 t t| ƒjƒ }| j|_| j|_| j|_| j|_|S )N)r r
Ú_cloner r r r )r Úobj)r r
r r O s zRdataset._clonec C s( t | ƒdkr|| _n|| jk r$|| _dS )zàSet the TTL of the rdataset to be the lesser of the set's current
TTL or the specified TTL. If the set contains no rdatas, set the TTL
to the specified TTL.
@param ttl: The TTL
@type ttl: intr N)Úlenr )r r r
r
r Ú
update_ttlW s
zRdataset.update_ttlNc s¸ | j |j ks| j|jkrt‚|dk r.| j|ƒ | jtjjksJ| jtjjkr‚|jƒ }t | ƒdkrt| jtjj
krt|| _n| j|kr‚t‚tjj|jƒr¤t | ƒdkr¤| j
ƒ tt| ƒj|ƒ dS )a% Add the specified rdata to the rdataset.
If the optional I{ttl} parameter is supplied, then
self.update_ttl(ttl) will be called prior to adding the rdata.
@param rd: The rdata
@type rd: dns.rdata.Rdata object
@param ttl: The TTL
@type ttl: intNr )r r r r ÚdnsÚ rdatatypeZRRSIGZSIGr r ÚNONEr Zis_singletonÚclearr r
Úadd)r Úrdr r )r r
r r c s
zRdataset.addc s | j |jƒ tt| ƒj|ƒ d S )N)r r r r
Úunion_update)r Úother)r r
r r ƒ s zRdataset.union_updatec s | j |jƒ tt| ƒj|ƒ d S )N)r r r r
Úintersection_update)r r! )r r
r r" ‡ s zRdataset.intersection_updatec s | j |jƒ tt| ƒj|ƒ dS )z‹Add all rdatas in other to self.
@param other: The rdataset from which to update
@type other: dns.rdataset.Rdataset objectN)r r r r
Úupdate)r r! )r r
r r# ‹ s zRdataset.updatec C sR | j dkrd}ndtjj| j ƒ d }dtjj| jƒ d tjj| jƒ | d S )Nr Ú ú(ú)z