fvdZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!m"Z"m#Z#m$Z$GddejJjLZ'Gdde'Z(Gd d e'Z)Gd d e'Z*Gd dejJjLZ+GddejJjLZ,GddejJjLZ-GddejJjLZ.dej^j`de ej^j`de1dej^j`fdZ2GddejfjhZ5GddejljnZ8ejrjrGdde8Z:Gd d!Z;Gd"d#e;Zdej~jd(e5dd)d(dd(f d*ede eej^j`eAfd+ej~jde1d,ed-e eAd.e1d/e1d0e ej^jd1ee1eeAfde5fd2ZDdej~jd(e5dd)d(dd(f d*eAde eej^j`eAfd+ej~jde1d,ed-e eAd.e1d/e1d0e ej^jd1ee1eeAfde5fd3ZEdej~jd(e5dd(d(dd(f d4ede eej^j`eAfd+ej~jde1d,ed-e eAd.e1d/e1d0e ej^jd1ee1eeAfde5fd5ZFe5d(d(fd6ed,ede1d/e1de5f d7ZGy)8z DNS Zones.N) AnyCallableIterableIteratorListMutableMappingOptionalSetTupleUnion)DigestHashAlgorithm DigestScheme_digest_hashersceZdZdZy)BadZonezThe DNS zone is malformed.N__name__ __module__ __qualname____doc__Q/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/zone.pyrr8s$rrceZdZdZy)NoSOAz)The DNS zone has no SOA RR at its origin.Nrrrrrr<s3rrceZdZdZy)NoNSz+The DNS zone has no NS RRset at its origin.Nrrrrrr@s5rrceZdZdZy) UnknownOriginz!The DNS zone's origin is unknown.NrrrrrrDs+rrceZdZdZy)UnsupportedDigestSchemez(The zone digest's scheme is unsupported.Nrrrrr!r!H2rr!ceZdZdZy)UnsupportedDigestHashAlgorithmz(The zone digest's origin is unsupported.Nrrrrr$r$Lr"rr$ceZdZdZy)NoDigestz/The DNS zone has no ZONEMD RRset at its origin.Nrrrrr&r&Ps9rr&ceZdZdZy)DigestVerificationFailurez#The ZONEMD digest failed to verify.Nrrrrr(r(Ts-rr(nameorigin relativizereturnc&| td|jr1|j|s td|r|j|}|S |j |}|s|}|S#t j j$r tdwxYw)Nzno zone origin is definedz5name parameter must be a subdomain of the zone originzrelative name too long for zone)KeyError is_absolute is_subdomainr+ derelativizednsr) NameTooLong)r)r*r+abs_names r_validate_namer5Xs ~233   (RS S ??6*D K >((0H D Kxx## ><= = >s A'')Bc0eZdZUdZej j Zegej j fe d<e Z ege ejjej j ffe d<dZeegdfe d<dZeegdfe d<gd Zej&j(d fd eeejjefd ej&j.d efdZdZdZdeejjefdejjfdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ% dFdeejjefdedej j fdZ& dFdeejjefdedeej j fd Z'deejjefddfd!Z(ejRjTdfdeejjefd"eejRjVefd#eejRjVefdedejXjZf d$Z.ejRjTdfdeejjefd"eejRjVefd#eejRjVefdedeejXjZf d%Z/ejRjTfdeejjefd"eejRjVefd#eejRjVefddfd&Z0deejjefd'ejXjZddfd(Z1ejRjTfdeejjefd"eejRjVefd#eejRjVefdejdjffd)Z4ejRjTfdeejjefd"eejRjVefd#eejRjVefdeejdjffd*Z5ejRjlejRjTfd"eejRjVefd#eejRjVefde7e8ejjejXjZffd+Z9ejRjlejRjTfd"eejRjVefd#eejRjVefde7e8ejje:ejvjxffd,Z= dGd-e>d.ed ed/eed0ed1eddfd2Z? dGd.ed ed/eed0ed1edef d3Z@dHd4ZA dId5eejjdejjljjfd6ZFeGjfd7eId8eGdeJfd9ZKeGjfd7eId8eGdejjljjfd:ZM dId;eejjljjddfd<ZNdJd>ZOdFd'edd=fd?ZPde8eejjeeejjffd@ZQdAZRdBZSdCZTdDZUdEZVy)KZoneazA DNS zone. A ``Zone`` is a mapping from names to nodes. The zone object may be treated like a Python dictionary, e.g. ``zone[name]`` will retrieve the node associated with that name. The *name* may be a ``dns.name.Name object``, or it may be a string. In either case, if the name is relative it is treated as relative to the origin of the zone. node_factory map_factoryNWritableVersionwritable_version_factoryImmutableVersionimmutable_version_factory)rdclassr*nodesr+Tr*r>r+cP|zt|tr tjj |}n/t|tjj s t d|js t d||_||_ |j|_ ||_ y)aInitialize a zone object. *origin* is the origin of the zone. It may be a ``dns.name.Name``, a ``str``, or ``None``. If ``None``, then the zone's origin will be set by the first ``$ORIGIN`` line in a zone file. *rdclass*, an ``int``, the zone's rdata class; the default is class IN. *relativize*, a ``bool``, determine's whether domain names are relativized to the zone's origin. The default is ``True``. Nz2origin parameter must be convertible to a DNS namez)origin parameter must be an absolute name) isinstancestrr2r) from_textName ValueErrorr/r*r>r9r?r+)selfr*r>r+s r__init__z Zone.__init__s$  &#&++F3 6 !UVV%%' !LMM  CGCSCSCU $rct|tsy|j|jk7s2|j|jk7s|j|jk7ryy)zqTwo zones are equal if they have the same origin, class, and nodes. Returns a ``bool``. FT)rAr7r>r*r?rFothers r__eq__z Zone.__eq__sG%& LLEMM ){{ell*zzU[[(rc&|j| S)z>Are two zones not equal? Returns a ``bool``. )rKrIs r__ne__z Zone.__ne__s ;;u%%%rr)r,ct|tr!tjj |d}n/t|tjj s t dt||j|jS)Nz0name parameter must be convertible to a DNS name) rArBr2r)rCrDr.r5r*r+rFr)s rr5zZone._validate_namesY dC 88%%dD1DD#((--0MN NdDKKAArcB|j|}|j|SNr5r?rFkeys r __getitem__zZone.__getitem__s !!#&zz#rcD|j|}||j|<yrQrR)rFrTvalues r __setitem__zZone.__setitem__s!!#& 3rc@|j|}|j|=yrQrRrSs r __delitem__zZone.__delitem__s!!#& JJsOrc6|jjSrQ)r?__iter__rFs rr\z Zone.__iter__szz""$$rc6|jjSrQr?keysr]s rr`z Zone.keyszz  rc6|jjSrQ)r?valuesr]s rrcz Zone.valuesszz  ""rc6|jjSrQr?itemsr]s rrfz Zone.itemszz!!rcZ|j|}|jj|SrQr5r?getrSs rrjzZone.gets%!!#&zz~~c""rc@|j|}||jvSrQrRrSs r __contains__zZone.__contains__s!!!#&djj  rFcreatec|j|}|jj|}|'|st|j }||j|<|S)aNFind a node in the zone, possibly creating it. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *create*, a ``bool``. If true, the node will be created if it does not exist. Raises ``KeyError`` if the name is not known and create was not specified, or if the name was not a subdomain of the origin. Returns a ``dns.node.Node``. )r5r?rjr.r8rFr)rmnodes r find_nodezZone.find_nodesT&""4(zz~~d# <$$&D#DJJt  rcP |j||}|S#t$rd}Y|SwxYw)aGet a node in the zone, possibly creating it. This method is like ``find_node()``, except it returns None instead of raising an exception if the node does not exist and creation has not been requested. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *create*, a ``bool``. If true, the node will be created if it does not exist. Returns a ``dns.node.Node`` or ``None``. N)rqr.ros rget_nodez Zone.get_nodes9( >>$/D  D  s  %%c^|j|}||jvr|j|=yy)akDelete the specified node if it exists. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. It is not an error if the node does not exist. NrRrOs r delete_nodezZone.delete_node s1""4( 4::  4  rrdtypecoversc(|j|}tjjj |}tjjj |}|j ||}|j |j|||S)aLook for an rdataset with the specified name and type in the zone, and return an rdataset encapsulating it. The rdataset returned is not a copy; changes to it will change the zone. KeyError is raised if the name or type are not found. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *rdtype*, a ``dns.rdatatype.RdataType`` or ``str``, the rdata type desired. *covers*, a ``dns.rdatatype.RdataType`` or ``str`` 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. *create*, a ``bool``. If true, the node will be created if it does not exist. Raises ``KeyError`` if the name is not known and create was not specified, or if the name was not a subdomain of the origin. Returns a ``dns.rdataset.Rdataset``. )r5r2 rdatatype RdataTypemakerq find_rdatasetr>)rFr)rvrwrmrps rr|zZone.find_rdataset/stR""4(((--f5((--f5~~dF+!!$,,GGrcT |j||||}|S#t$rd}Y|SwxYw)a%Look for an rdataset with the specified name and type in the zone. This method is like ``find_rdataset()``, except it returns None instead of raising an exception if the rdataset does not exist and creation has not been requested. The rdataset returned is not a copy; changes to it will change the zone. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *rdtype*, a ``dns.rdatatype.RdataType`` or ``str``, the rdata type desired. *covers*, a ``dns.rdatatype.RdataType`` or ``str``, 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. *create*, a ``bool``. If true, the node will be created if it does not exist. Raises ``KeyError`` if the name is not known and create was not specified, or if the name was not a subdomain of the origin. Returns a ``dns.rdataset.Rdataset`` or ``None``. N)r|r.)rFr)rvrwrmrdatasets r get_rdatasetzZone.get_rdataset^s@T ))$GH H s  ''cl|j|}tjjj |}tjjj |}|j |}|>|j |j||t|dk(r|j|yyy)aDelete the rdataset matching *rdtype* and *covers*, if it exists at the node specified by *name*. It is not an error if the node does not exist, or if there is no matching rdataset at the node. If the node has no rdatasets after the deletion, it will itself be deleted. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *rdtype*, a ``dns.rdatatype.RdataType`` or ``str``, the rdata type desired. *covers*, a ``dns.rdatatype.RdataType`` or ``str`` or ``None``, 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. Nr) r5r2ryrzr{rsdelete_rdatasetr>lenrurFr)rvrwrps rrzZone.delete_rdatasets:""4(((--f5((--f5}}T"    vv >4yA~  & r replacementc|j|jk7r td|j|d}|j|y)aReplace an rdataset at name. It is not an error if there is no rdataset matching I{replacement}. Ownership of the *replacement* object is transferred to the zone; in other words, this method does not store a copy of *replacement* at the node, it stores *replacement* itself. If the node does not exist, it is created. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *replacement*, a ``dns.rdataset.Rdataset``, the replacement rdataset. z#replacement.rdclass != zone.rdclassTN)r>rErqreplace_rdataset)rFr)rrps rrzZone.replace_rdatasets@*   $,, .BC C~~dD) k*rc|j|}tjjj |}tjjj |}|j |j |j||}tjj||j||}|j||S)aLook for an rdataset with the specified name and type in the zone, and return an RRset encapsulating it. This method is less efficient than the similar ``find_rdataset()`` because it creates an RRset instead of returning the matching rdataset. It may be more convenient for some uses since it returns an object which binds the owner name to the rdataset. This method may not be used to create new nodes or rdatasets; use ``find_rdataset`` instead. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *rdtype*, a ``dns.rdatatype.RdataType`` or ``str``, the rdata type desired. *covers*, a ``dns.rdatatype.RdataType`` or ``str``, 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. *create*, a ``bool``. If true, the node will be created if it does not exist. Raises ``KeyError`` if the name is not known and create was not specified, or if the name was not a subdomain of the origin. Returns a ``dns.rrset.RRset`` or ``None``. ) r5r2ryrzr{r?r|r>rrsetRRsetupdate)rFr)rvrwvnamer~rs r find_rrsetzZone.find_rrsetsX##D)((--f5((--f5::e$224<<P t||VVD X rcR |j|||}|S#t$rd}Y|SwxYw)a.Look for an rdataset with the specified name and type in the zone, and return an RRset encapsulating it. This method is less efficient than the similar ``get_rdataset()`` because it creates an RRset instead of returning the matching rdataset. It may be more convenient for some uses since it returns an object which binds the owner name to the rdataset. This method may not be used to create new nodes or rdatasets; use ``get_rdataset()`` instead. *name*: the name of the node to find. The value may be a ``dns.name.Name`` or a ``str``. If absolute, the name must be a subdomain of the zone's origin. If ``zone.relativize`` is ``True``, then the name will be relativized. *rdtype*, a ``dns.rdataset.Rdataset`` or ``str``, the rdata type desired. *covers*, a ``dns.rdataset.Rdataset`` or ``str``, 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. *create*, a ``bool``. If true, the node will be created if it does not exist. Returns a ``dns.rrset.RRset`` or ``None``. N)rr.)rFr)rvrwrs r get_rrsetzZone.get_rrsets<P OOD&&9E  E  s  &&c#tKtjjj|}tjjj|}|j D]O\}}|D]E}|tjj k(s |j |k(s0|j|k(s@||fGQyw)aReturn a generator which yields (name, rdataset) tuples for all rdatasets in the zone which have the specified *rdtype* and *covers*. If *rdtype* is ``dns.rdatatype.ANY``, the default, then all rdatasets will be matched. *rdtype*, a ``dns.rdataset.Rdataset`` or ``str``, the rdata type desired. *covers*, a ``dns.rdataset.Rdataset`` or ``str``, 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. N)r2ryrzr{rfANYrvrw)rFrvrwr)rprdss riterate_rdatasetszZone.iterate_rdatasets0s.((--f5((--f5**,JD$S]]...JJ&(SZZ6-A+% 'sBB8B8- B8c#Ktjjj|}tjjj|}|j D]a\}}|D]W}|tjj k(s |j |k(s0|j|k(s@|D]}||j|fYcyw)aReturn a generator which yields (name, ttl, rdata) tuples for all rdatas in the zone which have the specified *rdtype* and *covers*. If *rdtype* is ``dns.rdatatype.ANY``, the default, then all rdatas will be matched. *rdtype*, a ``dns.rdataset.Rdataset`` or ``str``, the rdata type desired. *covers*, a ``dns.rdataset.Rdataset`` or ``str``, 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. N) r2ryrzr{rfrrvrwttl)rFrvrwr)rprrdatas riterate_rdataszZone.iterate_rdatasPs.((--f5((--f5**,JD$S]]...JJ&(SZZ6-A!$#SWWe44"% 'sBC C -C fsortednl want_comments want_originc"t|tr t|d}ntj|}|5}t |dd}|d}|"t jj|} d}n4t|tr|j|} n|} |j}|r_|jJd|jjz} | j|} |j| |j| |r*t|j} | j!n|j} | D]X} || j| |j||} | j|} |j| |j| Z dddy#t$r%|j| |j|YwxYw#t$r%|j| |j|YwxYw#1swYyxYw)a=Write a zone to a file. *f*, a file or `str`. If *f* is a string, it is treated as the name of a file to open. *sorted*, a ``bool``. If True, the default, then the file will be written with the names sorted in DNSSEC order from least to greatest. Otherwise the names will be written in whatever order they happen to have in the zone's dictionary. *relativize*, a ``bool``. If True, the default, then domain names in the output will be relativized to the zone's origin if possible. *nl*, a ``str`` or None. The end of line string. If not ``None``, the output will use the platform's native end-of-line marker (i.e. LF on POSIX, CRLF on Windows). *want_comments*, a ``bool``. If ``True``, emit end-of-line comments as part of writing the file. If ``False``, the default, do not emit them. *want_origin*, a ``bool``. If ``True``, emit a $ORIGIN line at the start of the file. If ``False``, the default, do not emit one. wbencodingNzutf-8 z$ORIGIN )r*r+r)rArBopen contextlib nullcontextgetattroslinesepencodedecoder*to_textwrite TypeErrorlistr`sort)rFrrr+rrrcmfile_encnl_bll_bnamesns rto_filez Zone.to_fileqsH a 48DMB''*B / 1q*d3H"zzz((2B$yy*YY[{{...!4!4!66hhx( GGCLGGDM TYY[)  GOO;;)"/ $ hhx( GGCLGGDMC/ / 0! GGAJGGBK *! GGAJGGBK [/ / sUB(H"F#A4H5"GH#+GHGH+H?HHHHctj}|j|||||||j}|j |S)aReturn a zone's text as though it were written to a file. *sorted*, a ``bool``. If True, the default, then the file will be written with the names sorted in DNSSEC order from least to greatest. Otherwise the names will be written in whatever order they happen to have in the zone's dictionary. *relativize*, a ``bool``. If True, the default, then domain names in the output will be relativized to the zone's origin if possible. *nl*, a ``str`` or None. The end of line string. If not ``None``, the output will use the platform's native end-of-line marker (i.e. LF on POSIX, CRLF on Windows). *want_comments*, a ``bool``. If ``True``, emit end-of-line comments as part of writing the file. If ``False``, the default, do not emit them. *want_origin*, a ``bool``. If ``True``, emit a $ORIGIN line at the start of the output. If ``False``, the default, do not emit one. Returns a ``str``. )ioStringIOrgetvalueclose)rFrr+rrr temp_buffer return_values rrz Zone.to_textsFBkkm  [&*b-U"++- rcF|jrtjj}n|jJ|j}|j |tj jt|j |tj jty)zDo some simple checking of the zone's origin. Raises ``dns.zone.NoSOA`` if there is no SOA RRset. Raises ``dns.zone.NoNS`` if there is no NS RRset. Raises ``KeyError`` if there is no origin node. N) r+r2r)emptyr*rrySOArNSrrOs r check_originzZone.check_originsz ??88>>D;;* **;;D   T3==#4#4 5 =K   T3==#3#3 4 <J =rtxncT|jrtjj}n|jt |j}|r+|j |tjj}n*|j|tjj}|t |dS)zGet the zone SOA rdata. Raises ``dns.zone.NoSOA`` if there is no SOA RRset. Returns a ``dns.rdtypes.ANY.SOA.SOA`` Rdata. r) r+r2r)rr*rrjryrr)rFr origin_namesoas rget_soaz Zone.get_soas~ ??((..K{{" ++K ''+s}}'8'89C##K1B1BCC ;K1v rhash_algorithmschemec tj|}|st|tjk7rt |j rtjj}n|jJ|j}|}t|jD]\}}|j|j}t|dD]} ||k(r3tjj| j | j"fvr;t%j&d| j | j(| j*} | D cgc]} | j|j} } t| D];} t%j&dt-| } |j/|| z| z| z=|j1Scc} w)Nc2|j|jfSrQ)rvrw)rs rz&Zone._compute_digest..1s#**cjj9Qr)rTz!HHIz!H)rrjr$rSIMPLEr!r+r2r)rr*rrf to_digestableryZONEMDrvrwstructpackr>rrrdigest)rFrrhashinforhasherr)rp rrnamebufr~rrfixedrrdatasrrlens r_compute_digestzZone._compute_digestss #&&~60 0 \(( () ) ??((..K;;* **++K .JD$**4;;7I"4-QR;&3==+?+?OOOOD, ++HOOX-=-=x||IQQu%--dkk:QQ#F^E"KKc%j9EMM)g"5"="EF,S/}} Rs="F?c|jj}|j||}tjj j j |jtjj ||||SrQ) rserialrr2rdtypesrrr>ry)rFrrrrs rcompute_digestzZone.compute_digest@sd &&%%nf={{%%,, LL#--..PV  rzonemdcN|r|g}nL|jJ|j|jtjj}|t |}|D]:} |j |j|j}||jk(ry<t#t$rYNwxYwrQ) r*rr2ryrr&rrrr Exceptionr()rFrdigestsrrcomputeds r verify_digestzZone.verify_digestKs hG;;* **##DKK1E1EFC{GF //0E0Ev}}Uv}},-('  s5B B$#B$ Transactionc \t|dt|d|j|jS)NF)rVersionr?r*r]s rreaderz Zone.readerbs$4aT[[(QRRrc>t||}|j|SrQ)r_setup_version)rFrrs rwriterz Zone.writeres$ ,  rc|jrtjj}n |j}|j|j|fSrQ)r+r2r)rr*)rF effectives rorigin_informationzZone.origin_informationjs6 ??I I T__i88rc|jSrQ)r>r]s r get_classzZone.get_classts ||rcyrQrrFrs r _end_readzZone._end_ready rcyrQrrs r _end_writezZone._end_write|rrcN|j|_|j||_yyrQ)r?r*)rF_versionr*s r_commit_versionzZone._commit_versions#]] ;;  DK rcy)Nrrr]s r_get_next_version_idzZone._get_next_version_idsrF)TTNFF)r,NrQ)r,r)Wrrrrr2rpNoder8r__annotations__dictr9rr)rDr;r r= __slots__ rdataclassINr rB RdataClassboolrGrKrMr5rUrXrZr\r`rcrfrjrlrqrsruryNONErzr~Rdatasetr|rrrrrrrrrr rintrRdatarrrrr transactionrrrrrrr bytesrrrrrrrrrrrrrrrr7r7xs14 L(2sxx}},-=NRK"nSXX]]CHHMM-IJJKRJNhx4E0E'FGNLPx5G1G(HIP-> %sxx}}c123%**% %<"&B5);#<BB %!#"#! ?D#((--,-7; :?D#((--,-7; #((-- 4 !chhmmS&8 9 !d !&7:mm6H6H -HCHHMM3&'-Hcmm--s23-Hcmm--s23 -H  -H    -Hf7:mm6H6H .CHHMM3&'.cmm--s23.cmm--s23 .  . #,,'' ( .h7:mm6H6H $'CHHMM3&'$'cmm--s23$'cmm--s23 $'  $'L+#((--,-+ &D7:mm6G6G69mm6H6H5cmm--s235cmm--s235 % sCIIOO;< = 5H #!W W W  W SM W  W W  W v #! %%% SM %  %  % %N(<@COO778    : ,22 +    J ,22  +        & &  AE(s{{55<<=( (.S$= 9 x &hsxx}}.EE F9   ! rr7c$eZdZdgZfdZxZS) VersionedNodeidc0t|d|_yNr)superrGr )rF __class__s rrGzVersionedNode.__init__s r)rrrrrG __classcell__rs@rr r sIrr c eZdZfdZej j dfdejjdej jdej jde dejjf fd Z ej j dfdejjdej jdej jde deejjf fd Zej j fdejjdej jdej jdd fd Zd ejjdd fd Zde fdZxZS)ImmutableVersionedNodect||j|_t|jDcgc]!}t j j|#c}|_ycc}wrQ)rrGr tuple rdatasetsr2r~ImmutableRdataset)rFrprrs rrGzImmutableVersionedNode.__init__sI ''<@NN KSS\\ + +C 0 K  Ks&A'Fr>rvrwrmr,cB|r tdt| |||dSN immutableF)rrr|rFr>rvrwrmrs rr|z$ImmutableVersionedNode.find_rdatasets) K( (w$WffeDDrcB|r tdt| |||dSr)rrrrs rrz#ImmutableVersionedNode.get_rdatasets) K( (w#GVVUCCrNctdNrr)rFr>rvrws rrz&ImmutableVersionedNode.delete_rdatasets  $$rrctdrr )rFrs rrz'ImmutableVersionedNode.replace_rdatasets  $$rcyNTrr]s r is_immutablez#ImmutableVersionedNode.is_immutablesr)rrrrGr2ryrrrrzrr~rr|r rrrr$rrs@rrrsx +.--*<*< E** E '' E '' E  E    E+.--*<*< D** D '' D '' D  D #,,'' ( D+.--*<*< %**% ''% '' %  %%CLL,A,A%d%drrc HeZdZ ddededeeejjejjfdeejjfdZ dejjdejjfd Z dejjdeejjfd Zdejjd ejj d ejj deej"j$fd ZdZdZy)rNzoner r?r*cz||_||_|||_||_y|j|_||_yrQ)r&r r?r9r*)rFr&r r?r*s rrGzVersion.__init__sA   DJ ))+DJ rr)r,cXt||j|jjSrQ)r5r*r&r+rOs rr5zVersion._validate_namesdDKK1E1EFFrcZ|j|}|jj|SrQrirOs rrszVersion.get_nodes%""4(zz~~d##rrvrwcx|j|}|y|j|jj||SrQ)rsrr&r>rs rrzVersion.get_rdatasets9 }}T" <  !2!2FFCCrc6|jjSrQr_r]s rr`z Version.keysrarc6|jjSrQrer]s rrfz Version.itemsrgr)NN)rrrr7rr rr2r)rDrprrGr5rsryrzr~rrr`rfrrrrrs IM*.    sxx}}chhmm'CDE  ' G388==GSXX]]G$SXX]]$x /F$ Dhhmm D '' D '' D #,,'' ( D!"rrceZdZddedeffd ZdejjdejjfdZ dejjddfdZ dejjd ejjddfd Zdejjd ej j"d ej j"ddfd ZxZS)r:r&rc|j}t| |||s%|jj |j|j |_t |_yrQ)rrrGr?rr*setchanged)rFr&rr rs rrGzWritableVersion.__init__sS & & ( r" JJ  djj )kk +.5 rr)r,c|j|}|jj|}|||jvr|jj }t |dr|j|_|%|jj|j||j|<|jj||S|S)Nr ) r5r?rjr0r&r8hasattrr rextendadd)rFr)rpnew_nodes r _maybe_cowzWritableVersion._maybe_cows""4(zz~~d# <4t||3yy--/Hx&#gg ""))$..9'DJJt  LL  T "OKrNc|j|}||jvr)|j|=|jj|yyrQ)r5r?r0r4rOs rruzWritableVersion.delete_nodesA""4( 4::  4 LL  T " rr~cH|j|}|j|yrQ)r6r)rFr)r~rps r put_rdatasetzWritableVersion.put_rdatasets t$ h'rrvrwc|j|}|j|jj||t |dk(r|j |=yyr)r6rr&r>rr?rs rrzWritableVersion.delete_rdataset$sJ t$ TYY..? t9> 4  rr)rrrr7rrGr2r)rDrprr6rur~rr9ryrzrrrs@rr:r:s1T11 sxx}},# #$# (HHMM(-0\\-B-B( ( !hhmm ! '' ! '' !  !rr:c$eZdZdeffd ZxZS)r<rct||jd|j|_|j|_|j D]8}|j j|}|s!t||j |<:tjj|j d|jj|_yr#) rrGr&r r*r0r?rjrr2rDictr9)rFrr)rprs rrGzImmutableVersion.__init__2s t,**nn OOD==$$T*D&>rcX|jrJ|jj||yrQ)rArr9)rFr)r~s r _put_rdatasetzTransaction._put_rdataset]s#>>!! !!$1rcV|jrJ|jj|yrQ)rArrurOs r _delete_namezTransaction._delete_nameas!>>!!   &rcZ|jrJ|jj|||yrQ)rArrrGs r_delete_rdatasetzTransaction._delete_rdatasetes%>>!! $$T66:rc<|jj|duSrQrrsrOs r _name_existszTransaction._name_existsis||$$T*$66rc`|jryt|jjdkDS)NFr)rArrr0r]s r_changedzTransaction._changedls& >>t||++,q0 0rc|jr|jj|y|rt|jj dkDr{|j r1|jj}|t}||j}n |j}|jj|||jjy|jj|yr) rAr&rrrr0r@rCr=r<rr*r)rFcommitrErs r_end_transactionzTransaction._end_transactionrs >> II   % DLL001A5"",,@@?.G!$,,/,, II % %dGT\\5H5H I II  &rcT|jj||j_yyrQ)rr*)rFr*s r _set_originzTransaction._set_origins# <<   &"(DLL  'rc#jK|jjD]\}}|D]}||f ywrQ)rrf)rFr)rpr~s r_iterate_rdatasetszTransaction._iterate_rdatasetss6,,,,.JD$ X&&!/s13c6|jjSrQ)rr`r]s r_iterate_nameszTransaction._iterate_namess||  ""rc8|jj|SrQrPrOs r _get_nodezTransaction._get_nodes||$$T**rc|jj\}}}|K|jj5|jj}|rtj j }n|}|||fSrQ)rCrrr*r2r)r)rFabsoluter+rs r_origin_informationzTransaction._origin_informationsc,0LL,K,K,M):y   3 3 ?||**HHHNN $ *i00r)NF)rrrrGpropertyr&rrHrJrLrNrQrSrVrXrZr\r^rarrs@rrrHs]- <?2';71 ' )' #+ 1rrTFtextr> zone_factoryfilename allow_includer idna_codecallow_directivesc |d}||||} | jd5} tjj|||} tjj | || || } | j  ddd|r| j| S#tjj$rtjjwxYw#1swYXxYw)Nzr+T)rg)rfrh) rr2 tokenizer TokenizerzonefileReaderreadrr&r)rcr*r>r+rdrerfrrgrhr&rtokrs r _from_textrqs& J ?D T  )cmm%%dH%L$$   '- %  ) KKM )  K ||)) )(((( ( ) ) )sAC)B8CCCc *t|||||||||| S)aBuild a zone object from a zone file format string. *text*, a ``str``, the zone file format input. *origin*, a ``dns.name.Name``, a ``str``, or ``None``. The origin of the zone; if not specified, the first ``$ORIGIN`` statement in the zone file will determine the origin of the zone. *rdclass*, a ``dns.rdataclass.RdataClass``, the zone's rdata class; the default is class IN. *relativize*, a ``bool``, determine's whether domain names are relativized to the zone's origin. The default is ``True``. *zone_factory*, the zone factory to use or ``None``. If ``None``, then ``dns.zone.Zone`` will be used. The value may be any class or callable that returns a subclass of ``dns.zone.Zone``. *filename*, a ``str`` or ``None``, the filename to emit when describing where an error occurred; the default is ``''``. *allow_include*, a ``bool``. If ``True``, the default, then ``$INCLUDE`` directives are permitted. If ``False``, then encoutering a ``$INCLUDE`` will raise a ``SyntaxError`` exception. *check_origin*, a ``bool``. If ``True``, the default, then sanity checks of the origin node will be made by calling the zone's ``check_origin()`` method. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder. If ``None``, the default IDNA 2003 encoder/decoder is used. *allow_directives*, a ``bool`` or an iterable of `str`. If ``True``, the default, then directives are permitted, and the *allow_include* parameter controls whether ``$INCLUDE`` is permitted. If ``False`` or an empty iterable, then no directive processing is done and any directive-like text will be treated as a regular owner name. If a non-empty iterable, then only the listed directives (including the ``$``) are allowed. Raises ``dns.zone.NoSOA`` if there is no SOA RRset. Raises ``dns.zone.NoNS`` if there is no NS RRset. Raises ``KeyError`` if there is no origin node. Returns a subclass of ``dns.zone.Zone``. )rq) rcr*r>r+rdrerfrrgrhs rrCrCs0x    rrc t|tr||}t|} ntj|} | 5}t |||||||||| cdddS#1swYnxYwJ)aRead a zone file and build a zone object. *f*, a file or ``str``. If *f* is a string, it is treated as the name of a file to open. *origin*, a ``dns.name.Name``, a ``str``, or ``None``. The origin of the zone; if not specified, the first ``$ORIGIN`` statement in the zone file will determine the origin of the zone. *rdclass*, an ``int``, the zone's rdata class; the default is class IN. *relativize*, a ``bool``, determine's whether domain names are relativized to the zone's origin. The default is ``True``. *zone_factory*, the zone factory to use or ``None``. If ``None``, then ``dns.zone.Zone`` will be used. The value may be any class or callable that returns a subclass of ``dns.zone.Zone``. *filename*, a ``str`` or ``None``, the filename to emit when describing where an error occurred; the default is ``''``. *allow_include*, a ``bool``. If ``True``, the default, then ``$INCLUDE`` directives are permitted. If ``False``, then encoutering a ``$INCLUDE`` will raise a ``SyntaxError`` exception. *check_origin*, a ``bool``. If ``True``, the default, then sanity checks of the origin node will be made by calling the zone's ``check_origin()`` method. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder. If ``None``, the default IDNA 2003 encoder/decoder is used. *allow_directives*, a ``bool`` or an iterable of `str`. If ``True``, the default, then directives are permitted, and the *allow_include* parameter controls whether ``$INCLUDE`` is permitted. If ``False`` or an empty iterable, then no directive processing is done and any directive-like text will be treated as a regular owner name. If a non-empty iterable, then only the listed directives (including the ``$``) are allowed. Raises ``dns.zone.NoSOA`` if there is no SOA RRset. Raises ``dns.zone.NoNS`` if there is no NS RRset. Raises ``KeyError`` if there is no origin node. Returns a subclass of ``dns.zone.Zone``. N)rArBrrrrq) rr*r>r+rdrerfrrgrhrs r from_filertszz!S  H04Q  # #A &  q               5s AAxfrcd}|D]}|L|r |j}n|jdj}|jdj}||||}|jD]}|jj |j} | s)|j } | |j|j<| j|j|j|jd} | j|j|D]} | j| | td|r|j|S)aNConvert the output of a zone transfer generator into a zone object. *xfr*, a generator of ``dns.message.Message`` objects, typically ``dns.query.xfr()``. *relativize*, a ``bool``, determine's whether domain names are relativized to the zone's origin. The default is ``True``. It is essential that the relativize setting matches the one specified to the generator. *check_origin*, a ``bool``. If ``True``, the default, then sanity checks of the origin node will be made by calling the zone's ``check_origin()`` method. Raises ``dns.zone.NoSOA`` if there is no SOA RRset. Raises ``dns.zone.NoNS`` if there is no NS RRset. Raises ``KeyError`` if there is no origin node. Raises ``ValueError`` if no messages are yielded by the generator. Returns a subclass of ``dns.zone.Zone``. NrrjTzempty transfer)r*answerr)r>r?rjr8r|rvrw update_ttlrr4rEr) rurdr+rzrr*r>rznodezrdsrds rfrom_xfrr~es > A  9!))hhqk))GVWDAXXEGGKK +E(&+ #&&u}}ellELLRVWD OOEII & " y)**  Hr)Hrrrrrtypingrrrrrrr r r r dns.exceptionr2 dns.grange dns.immutabledns.namedns.node dns.rdatadns.rdataclass dns.rdataset dns.rdatatypedns.rdtypes.ANY.SOAdns.rdtypes.ANY.ZONEMD dns.rrset dns.tokenizerdns.transactiondns.ttl dns.zonefile dns.zonetypesr rr exception DNSExceptionrrrrr!r$r&r(r)rDrr5rTransactionManagerr7rprr rrrr:r<rrrrBr IDNACodecrqrCrtr~rrrrs$    LL%cmm((%4G4676,G,3cmm8833S]]%?%?3:s}})):. : :. ((-- SXX]] # XX]] @N 3?? - -N rCHHMM*]**Z&"&"R<!g<!~ w  .S1#//--S1p37),):):"/337' ' U388==#-. /'^^ & &' '  ' sm '''++,'D(3-/0' 'X37),):):"/337G G U388==#-. /G^^ & &G G  G sm GGG++,GD(3-/0G GX37),):):"/337P P U388==#-. /P^^ & &P P  P sm PPP++,PD(3-/0P Pj 5 5 5 5  5  5 r