AlkantarClanX12

Your IP : 18.218.73.233


Current Path : /proc/self/root/lib/python3.6/site-packages/dns/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/dns/__pycache__/update.cpython-36.pyc

3

�b�W'�@s`dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
Gdd�dejj�Z
dS)zDNS Dynamic Update Support�N�)�string_typescsxeZdZejjddejjf�fdd�	Zddd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zddd�Zd�fdd�	Z�ZS)�UpdateNcs�tt|�j�|jtjjtjj�O_t|t	�r>tj
j|�}||_t|t	�rZtj
j|�}||_|j|j|j|tjjddd�|dk	r�|j|||d�dS)a�Initialize a new DNS Update object.

        @param zone: The zone which is being updated.
        @type zone: A dns.name.Name or string
        @param rdclass: The class of the zone; defaults to dns.rdataclass.IN.
        @type rdclass: An int designating the class, or a string whose value
        is the name of a class.
        @param keyring: The TSIG keyring to use; defaults to None.
        @type keyring: dict
        @param keyname: The name of the TSIG key to use; defaults to None.
        The key must be defined in the keyring.  If a keyring is specified
        but a keyname is not, then the key used will be the first key in the
        keyring.  Note that the order of keys in a dictionary is not defined,
        so applications should supply a keyname when a keyring is used, unless
        they know the keyring contains only one key.
        @type keyname: dns.name.Name or string
        @param keyalgorithm: The TSIG algorithm to use; defaults to
        dns.tsig.default_algorithm.  Constants for TSIG algorithms are defined
        in dns.tsig, and the currently implemented algorithms are
        HMAC_MD5, HMAC_SHA1, HMAC_SHA224, HMAC_SHA256, HMAC_SHA384, and
        HMAC_SHA512.
        @type keyalgorithm: string
        T)ZcreateZforce_uniqueN)�	algorithm)�superr�__init__�flags�dnsZopcodeZto_flagsZUPDATE�
isinstancer�name�	from_text�origin�
rdataclass�zone_rdclass�
find_rrsetZquestion�	rdatatypeZSOAZuse_tsig)�selfZzoneZrdclassZkeyringZkeynameZkeyalgorithm)�	__class__��/usr/lib/python3.6/update.pyrs


zUpdate.__init__c	CsB|dkr|j}|j�}|j|||j|j||dd�}|j||�dS)z&Add a single RR to the update section.NT)�	authority�coversrr�rdtype�add)rr�ttl�rdZdeleting�sectionrZrrsetrrr�_add_rrEszUpdate._add_rrc
Gs:t|t�rtjj|d�}t|dtjj�rnx@|D]8}|rF|j||j�x |D]}|j	||j
||d�qLWq0Wn�t|�}t|j
d��}t|dtjj�r�|r�|j||dj�x�|D]}|j	||||d�q�Wnh|j
d�}t|t�r�tjj|�}|r�|j||�x6|D].}	tjj|j||	|j�}|j	||||d��qWdS)a�Add records.  The first argument is the replace mode.  If
        false, RRs are added to an existing RRset; if true, the RRset
        is replaced with the specified contents.  The second
        argument is the section to add to.  The third argument
        is always a name.  The other arguments can be:

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...Nr)r)r
rr	rr�rdataset�Rdataset�deleterrr�list�int�pop�rdata�Rdatarrr
)
r�replacerr�args�rdsrrr�srrr�_addOs0






zUpdate._addcGs|jd|j|f|��dS)z�Add records.  The first argument is always a name.  The other
        arguments can be:

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...FN)r*r)rrr'rrrrws	z
Update.addc	Gsft|t�rtjj|d�}t|�dkrR|j|j|tjj	tj
j	tj
jtj
j	dd��nt|dtjj
�r�x�|D]&}x |D]}|j|d|tjj�qtWqjWn�t|�}t|dtjj�r�x�|D]}|j|d|tjj�q�Wn�|jd�}t|t�r�tj
j|�}t|�dk�r(|j|j||j|tj
jtjj	dd�n:x8|D]0}tjj|j|||j�}|j|d|tjj��q.WdS)z�Delete records.  The first argument is always a name.  The other
        arguments can be:

                - I{nothing}

                - rdataset...

                - rdata...

                - rdtype, [string...]NrT)r
rr	rr�lenrrr�ANYr�NONErrrr!r$r%r#rr
)rrr'r(rrr)rrrr �s6








z
Update.deletecGs|jd|j|f|��dS)aQReplace records.  The first argument is always a name.  The other
        arguments can be:

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...

        Note that if you want to replace the entire node, you should do
        a delete of the name followed by one or more calls to add.TN)r*r)rrr'rrrr&�s
zUpdate.replacec	Gs�t|t�rtjj|d�}t|�dkrL|j|j|tjj	tj
j	tj
jddd�n�t|dtjj
�s|t|dtjj�s|t|�dkr�t|dtjj
�s�t|�}|jdd�|jd|j|f|��n@|d}t|t�r�tj
j|�}|j|j|tjj	|tj
jddd�dS)aBRequire that an owner name (and optionally an rdata type,
        or specific rdataset) exists as a prerequisite to the
        execution of the update.  The first argument is always a name.
        The other arguments can be:

                - rdataset...

                - rdata...

                - rdtype, string...NrTrF)r
rr	rrr+r�answerrr,rr-rrr$r%r!�insertr*)rrr'rrrr�present�s*




zUpdate.presentc	Cs�t|t�rtjj|d�}|dkrH|j|j|tjjtj	j
tj	jddd�n8t|t�r^tj	j|�}|j|j|tjj|tj	jddd�dS)z�Require that an owner name (and optionally an rdata type) does
        not exist as a prerequisite to the execution of the update.NT)r
rr	rrrr.rr-rr,)rrrrrr�absent�s




z
Update.absent�cs |dkr|j}tt|�j||�S)zcReturn a string containing the update in DNS compressed wire
        format.
        @rtype: stringN)r
rr�to_wire)rr
Zmax_size)rrrr3�szUpdate.to_wire)NN)N)Nr2)�__name__�
__module__�__qualname__r	r�INZtsigZdefault_algorithmrrr*rr r&r0r1r3�
__classcell__rr)rrrs%

(+$
r)�__doc__Zdns.messager	Zdns.nameZ
dns.opcodeZ	dns.rdataZdns.rdataclassZdns.rdatasetZdns.tsigZ_compatr�messageZMessagerrrrr�<module>s