a Me/@sdZddlmZmZmZmZddlZddlZddl Zddl Zddl Zddl Zddl ZddlZGdddejjZGdddejjZeZejZejZejZejZdS)zDNS Dynamic Update Support)AnyListOptionalUnionNc@s,eZdZdZdZdZdZdZeddZ dS) UpdateSectionzUpdate sectionsrcCsdS)Nr )clsr r ./usr/lib/python3.9/site-packages/dns/update.py_maximum(szUpdateSection._maximumN) __name__ __module__ __qualname____doc__ZONEPREREQUPDATE ADDITIONAL classmethodr r r r r r srcseZdZeZdejjddejj dfe e ej j efejje ee ej j e ej j efe edfdd ZeeejjdddZejddZeeejjdd d Zejd d Zeeejjdd d Zejdd Zd#ddZddZe ej j efeddddZe ej j efeddddZe ej j efeddddZe ej j efeddddZ d$e ej j efe e ej!j"efddddZ#dd Z$d!d"Z%Z&S)% UpdateMessageN)zonerdclasskeyringkeyname keyalgorithmidcstj|d|jtjtjjO_t|tr>tj |}||_ tj j |}||_|j r||j|j|j |tjjddd|dur|j|||ddS)axInitialize a new DNS Update object. See the documentation of the Message class for a complete description of the keyring dictionary. *zone*, a ``dns.name.Name``, ``str``, or ``None``, the zone which is being updated. ``None`` should only be used by dnspython's message constructors, as a zone is required for the convenience methods like ``add()``, ``replace()``, etc. *rdclass*, an ``int`` or ``str``, the class of the zone. The *keyring*, *keyname*, and *keyalgorithm* parameters are passed to ``use_tsig()``; see its documentation for details. )rT)ZcreateZ force_uniqueN) algorithm)super__init__flagsdnsZopcodeZto_flagsr isinstancestrname from_textorigin rdataclass RdataClassmake zone_rdclass find_rrsetr rdatatypeSOAZuse_tsig)selfrrrrrr __class__r r r 1s$  zUpdateMessage.__init__)returncCs |jdS)zThe zone section.rZsectionsr/r r r r\szUpdateMessage.zonecCs||jd<dS)Nrr3r/vr r r rascCs |jdS)zThe prerequisite section.rr3r4r r r prerequisiteeszUpdateMessage.prerequisitecCs||jd<dS)Nrr3r5r r r r7jscCs |jdS)zThe update section.rr3r4r r r updatenszUpdateMessage.updatecCs||jd<dS)Nrr3r5r r r r8ssc CsB|dur|j}|}||||j|j||dd}|||dS)z&Add a single RR to the update section.NT)r8coversr,r+rdtypeadd)r/r%ttlrddeletingsectionr9rrsetr r r _add_rrwszUpdateMessage._add_rrc Gst|trtj|d}t|dtjjrf|D]4}|rD|||j|D]}|j ||j ||dqHq.nt |}t | d}t|dtjjr|r|||dj|D]}|j ||||dqnVtjj| d}|r||||D],} tj|j|| |j}|j ||||dqdS)aAdd records. *replace* is the replacement 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#r$r"r%r&rdatasetRdatasetdeleter:rAr<listintpoprdataRdatar- RdataTyper*r+r') r/replacer?r%argsrdsr=r<r:sr r r _adds*  zUpdateMessage._add)r%rLr2cGs|jd|j|g|RdS)zAdd records. The first argument is always a name. The other arguments can be: - rdataset... - ttl, rdata... - ttl, rdtype, string... FNrOr8r/r%rLr r r r;s zUpdateMessage.addc GsHt|trtj|d}t|dkrP||j|tjj tj j tj j tjj ddnt|dtj j r|D]"}|D]}||d|tjj qnqfnt|}t|dtjjr|D]}||d|tjj qn~tj j|d}t|dkr||j||j|tj j tjj ddn6|D]0}tj|j|||j}||d|tjj qdS)zDelete records. The first argument is always a name. The other arguments can be: - *empty* - rdataset... - rdata... - rdtype, [string...] NrT)r#r$r"r%r&lenr,r8r(ANYr-NONErBrCrArErHrIrJr*rGr+r')r/r%rLrMr=largsr:rNr r r rDsR    zUpdateMessage.deletecGs|jd|j|g|RdS)abReplace 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. TNrPrQr r r rKszUpdateMessage.replacec Gst|trtj|d}t|dkrL||j|tjj tj j tj j dddnt|dtj j s|t|dtjjs|t|dkrt|dtj j st|}|dd|jd|j|g|Rn|jd|j|g|Rn4tj j|d}||j|tjj |tj j ddddS)aSRequire 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#r$r"r%r&rRr,r7r(rSr-rTrBrCrHrIrEinsertrOrJr*)r/r%rLrUr:r r r presentsF     zUpdateMessage.present)r%r:r2c Cs|t|trtj|d}|durH||j|tjjtj j tj jdddn0tj j |}||j|tjj|tj jddddS)zRequire that an owner name (and optionally an rdata type) does not exist as a prerequisite to the execution of the update.NT) r#r$r"r%r&r,r7r(rTr-rSrJr*)r/r%r:r r r absent<s0  zUpdateMessage.absentcCsdS)NTr )r/valuer r r _get_one_rr_per_rrset^sz#UpdateMessage._get_one_rr_per_rrsetcCsd}d}|tjkr:tj|s0|tjjks0|jrtjj nH|jsHtjj |tjj tjj fvr|}|jdj }|tjj kp|tj k}||||fS)NFr)rrr"r(Z is_metaclassr-r.r exceptionZ FormErrorrSrTrr)r/r?r%rr:r>emptyr r r _parse_rr_headerbs$     zUpdateMessage._parse_rr_header)NN)N)'rrrrZ _section_enumr"r(INZtsigZdefault_algorithmrrr%Namer$r)rrFr propertyrr@ZRRsetrsetterr7r8rArOr;rDrKrWr-rJrXrZr] __classcell__r r r0r r-sR +    (<8 "r)rtypingrrrrZ dns.messager"Zdns.nameZ dns.opcodeZ dns.rdataZdns.rdataclassZ dns.rdatasetZ dns.rdatatypeZdns.tsigenumIntEnumrmessageZMessagerZUpdaterrrrr r r r s$ N