U mf/@sdZddlmZmZmZmZddlZddlZddl Zddl Zddl Zddl Zddl ZddlZGdddejjZGdddejjZeZejZejZejZejZdS)zDNS Dynamic Update Support)AnyListOptionalUnionNc@s,eZdZdZdZdZdZdZeddZ dS) UpdateSectionzUpdate sectionsrcCsdS)Nr )clsr r 8/opt/hc_python/lib/python3.8/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|dk r|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)createZ force_uniqueN) algorithm)super__init__flagsdnsopcodeZto_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.rsectionsr1r r r r\szUpdateMessage.zonecCs||jd<dS)Nrr5r1vr r r rascCs |jdS)zThe prerequisite section.rr5r7r r r prerequisiteeszUpdateMessage.prerequisitecCs||jd<dS)Nrr5r8r r r r:jscCs |jdS)zThe update section.rr5r7r r r updatenszUpdateMessage.updatecCs||jd<dS)Nrr5r8r r r r;ssc CsB|dkr|j}|}||||j|j||dd}|||dS)z&Add a single RR to the update section.NT)r;coversr.r-rdtypeadd)r1r'ttlrddeletingsectionr<rrsetr 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)rB)r%r&r#r'r(rdatasetRdatasetdeleter=rDr?listintpoprdataRdatar/ RdataTyper,r-r)) r1replacerBr'argsrdsr@r?r=sr r r _adds*  zUpdateMessage._add)r'rOr4cGs|jd|j|f|dS)zAdd records. The first argument is always a name. The other arguments can be: - rdataset... - ttl, rdata... - ttl, rdtype, string... FNrRr;r1r'rOr 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.r;r*ANYr/NONErErFrDrHrKrLrMr,rJr-r))r1r'rOrPr@largsr=rQr r r rGsR    zUpdateMessage.deletecGs|jd|j|f|dS)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. TNrSrTr r r rNszUpdateMessage.replacec Gs t|trtj|d}t|dkrL||j|tjj tj j tj j dddnt|dtj j s|t|dtjjs|t|dkrt|dtj j st|}|dd|jd|j|f|n|jd|j|f|n4tj 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(rUr.r:r*rVr/rWrErFrKrLrHinsertrRrMr,)r1r'rOrXr=r r r presentsF     zUpdateMessage.present)r'r=r4c Cs|t|trtj|d}|dkrH||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.r:r*rWr/rVrMr,)r1r'r=r r r absent<s0  zUpdateMessage.absentcCsdS)NTr )r1valuer r r _get_one_rr_per_rrset^sz#UpdateMessage._get_one_rr_per_rrsetcCsd}d}|tjkr:tj|s0|tjjks0|jrtjj nH|jsHtjj |tjj tjj fkr|}|jdj }|tjj kp|tj k}||||fS)NFr)rrr#r*Z is_metaclassr/r0r exceptionZ FormErrorrVrWrr)r1rBr'rr=rAemptyr r r _parse_rr_headerbs$     zUpdateMessage._parse_rr_header)NN)N)'rrrrZ _section_enumr#r*INZtsigZdefault_algorithmrrr'Namer&r+rrIr!propertyrrCZRRsetrsetterr:r;rDrRr>rGrNrZr/rMr[r]r` __classcell__r r r2r r-sR +    (<8 "r)rtypingrrrrZ dns.messager#Zdns.nameZ dns.opcodeZ dns.rdataZdns.rdataclassZ dns.rdatasetZ dns.rdatatypeZdns.tsigenumIntEnumrmessageMessagerZUpdaterrrrr r r r s$ N