f; UdZddlZddlZddlZddlZddlmZmZmZm Z ddl Z ddl Z ddl Z ddlZ Gdde jj ZGddZGdd eZGd d eZGd d e jj ZGddeZGddeZej0eej2eej4eiZeeefed<dedefdZde eefdddefdZde eefde de!de!def dZ"dededdfdZ#ej4ZejHZ$ejJZ%ejLZ&ej0ZejNZ'ejPZ(ejRZ)ejTZ*ejVZ+ej2Zy)z EDNS OptionsN)AnyDictOptionalUnioncHeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ed Zy ) OptionType cyNiclss Q/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/edns.py_maximumzOptionType._maximum8N)__name__ __module__ __qualname__NSIDDAUDHUN3UECSEXPIRECOOKIE KEEPALIVEPADDINGCHAINEDE classmethodrrrrrr sK D C C C C F FIG E CrrceZdZdZdeeeffdZddee dee fdZ defdZ e ded d ddfd Zd Zd ZdZdZdZdZdZdZy)Optionz%Base class for all EDNS option types.otypec8tj||_y)z_Initialize an option. *otype*, a ``dns.edns.OptionType``, is the option type. N)rmaker.)selfr.s r__init__zOption.__init__@s  __U+ rNfilereturnct)zUConvert an option to wire format. Returns a ``bytes`` or ``None``. NotImplementedErrorr1r3s rto_wirezOption.to_wireGs "!rctNr6r1s rto_textzOption.to_textOs!!rparserdns.wire.Parserct)aBuild an EDNS option object from wire format. *otype*, a ``dns.edns.OptionType``, is the option type. *parser*, a ``dns.wire.Parser``, the parser, which should be restructed to the option length. Returns a ``dns.edns.Option``. r6rr.r>s rfrom_wire_parserzOption.from_wire_parserRs "!rc\|j}|j}||k(ry||kDryy)zCompare an EDNS option with another option of the same type. Returns < 0 if < *other*, 0 if == *other*, and > 0 if > *other*. r)r9)r1otherwireowires r_cmpz Option._cmp_s1 ||~  5= %<rct|tsy|j|jk7ry|j|dk(S)NFr isinstancer-r.rIr1rFs r__eq__z Option.__eq__ls6%( :: $yy1$$rct|tsy|j|jk7ry|j|dk7S)NTrrKrMs r__ne__z Option.__ne__ss6%( :: $yy1$$rct|tr|j|jk7rtS|j |dkSNrrLr-r.NotImplementedrIrMs r__lt__z Option.__lt__z5%(DJJ%++,E! !yy!##rct|tr|j|jk7rtS|j |dkSrRrSrMs r__le__z Option.__le__5%(DJJ%++,E! !yy1$$rct|tr|j|jk7rtS|j |dk\SrRrSrMs r__ge__z Option.__ge__rYrct|tr|j|jk7rtS|j |dkDSrRrSrMs r__gt__z Option.__gt__rVrc"|jSr;)r=r<s r__str__zOption.__str__s||~rr;)rrr__doc__rrstrr2rrbytesr9r=r+rBrIrNrPrUrXr[r]r_rrrr-r-=s/,eJO4,"HSM"Xe_""" "Z "9J "x " " %%$ % % $ rr-ceZdZdZdeeefdeeefffd Zd de e de efdZ defdZ e deeefd d defd ZxZS) GenericOptionzwGeneric Option Class This class is used for EDNS option types for which we have no better implementation. r.datact||tjjj |d|_y)NT)superr2dnsrdataRdata _as_bytesre)r1r.re __class__s rr2zGenericOption.__init__s, IIOO--dD9 rr3r4cV|r|j|jy|jSr;)writerer8s rr9zGenericOption.to_wire"  JJtyy !99 rc d|jzS)Nz Generic %d)r.r<s rr=zGenericOption.to_textsdjj((rr>r?c0|||jSr; get_remainingrAs rrBzGenericOption.from_wire_parsers5&..011rr;)rrrr`rrrarbr2rrr9r=r+r-rB __classcell__rls@rrdrds :eJO4:E%*> !DK~iioo66w?GYY__,,VQ;Fyy..xB?H12 2!!!    88%%b'2TYYv|,-!&)   A:;;sC bc(:$;tE ?R$STD MM#2.5DM rr4cddj|j|j|jS)NzECS {}/{} scope/{})formatrxryrzr<s rr=zECSOption.to_texts##**4<<dmmTTrtextcd}|j}d}t|dk(r|d}nPt|dk(r(|d|k7rtdj||d}ntdj||j d}|dk(r|jd\}}d}n5|dk(r|jd\}}}ntdj| t |} t |} t || |S#t$rtd d j|zwxYw#t$rtd d j|zwxYw) aConvert a string into a `dns.edns.ECSOption` *text*, a `str`, the text form of the option. Returns a `dns.edns.ECSOption`. Examples: >>> import dns.edns >>> >>> # basic example >>> dns.edns.ECSOption.from_text('1.2.3.4/24') >>> >>> # also understands scope >>> dns.edns.ECSOption.from_text('1.2.3.4/24/32') >>> >>> # IPv6 >>> dns.edns.ECSOption.from_text('2001:4b98::1/64/64') >>> >>> # it understands results from `dns.edns.ECSOption.to_text()` >>> dns.edns.ECSOption.from_text('ECS 1.2.3.4/24/32') r$NrDrr|zcould not parse ECS from "{}"/0zinvalid scope z"{}": scope must be an integerzinvalid srclen z"{}": srclen must be an integer)splitlenrrcountrrw) roptional_prefixtokensecs_text n_slashesrxtsrclentscopescoperys r from_textzECSOption.from_textsm0  v;! ayH [A ayO+ !@!G!G!MNNayH<CCDIJ JNN3' >'~~c2 GWF !^'/~~c': $GWf<CCDIJ J KE  \F &%00  #C#J#J6#RR    !$E$L$LW$UU  s D( D*'D'*'Er3ctjd|j|j|j|j z}|r|j |y|S)N!HBB)rrrryrzrrnr1r3values rr9zECSOption.to_wiresG KK T[[$-- H4== X   JJu Lrr.r>r?cz|jd\}}}ttj|dz }|j |}|dk(r+d|z }t j j|d|zz} n;|dk(r+d|z }t jj|d|zz} n td|| ||S) NrrrDr|zunsupported family) get_structrrr get_bytesrhipv4 inet_ntoaipv6r) rr.r>rsrcraddrlenprefixpadaddrs rrBzECSOption.from_wire_parser&s$..v6Udiic *+!!'* Q;g+C88%%fw}&<=D q[w,C88%%fw}&<=D12 24e$$rrRr;)rrrr`rarrr2r= staticmethodr-rrrbr9r+rrrBrtrus@rrwrws+-6-6Xc]-6S-6^UU61616161pHSMXe_%*c/*%4E% %%rrwceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZedZy)EDECoderrDr|r rr r r r rrrrrrrrcyrrrs rrzEDECode._maximumTrrN)rrrOTHERUNSUPPORTED_DNSKEY_ALGORITHMUNSUPPORTED_DS_DIGEST_TYPE STALE_ANSWER FORGED_ANSWERDNSSEC_INDETERMINATE DNSSEC_BOGUSSIGNATURE_EXPIREDSIGNATURE_NOT_YET_VALIDDNSKEY_MISSINGRRSIGS_MISSINGNO_ZONE_KEY_BIT_SET NSEC_MISSING CACHED_ERROR NOT_READYBLOCKEDCENSOREDFILTERED PROHIBITEDSTALE_NXDOMAIN_ANSWERNOT_AUTHORITATIVE NOT_SUPPORTEDNO_REACHABLE_AUTHORITY NETWORK_ERROR INVALID_DATAr+rrrrrr9s E#$ !"LMLNNLLIGHHJMMLrrceZdZdZhdZddeeefdeeffd Z defdZ ddee dee fd Z ed eeefd d defd ZxZS) EDEOptionz!Extended DNS Error (EDE, RFC8914)>DSNSECDNSKEYDNSSECRRSIGsNXDOMAINcoderct|tjtj ||_|t|ts td||_ y)z*code*, a ``dns.edns.EDECode`` or ``str``, the info code of the extended error. *text*, a ``str`` or ``None``, specifying additional information about the error. Nztext must be string or None) rgr2rr*rr0rrLrarr)r1rrrls rr2zEDEOption.__init__^sH (LL&  JtS$9:; ; rr4c(dj}jtvrQtjj}djfd|j dD}|d|dz }j |dj z }|S)NzEDE  c3^K|]$}|jvr|n|j&ywr;)_preserve_casetitle).0wordr1s r z$EDEOption.to_text..qs1 3 33Es*-_z ()z: )rrr=joinrr)r1outputdescs` rr=zEDEOption.to_textms {# 99 ??499-D88 JJsOD 4&l "F 99 499+& &F rr3ctjd|j}|j||jj dz }|r|j |y|S)Nz!Hutf8)rrrrencodernrs rr9zEDEOption.to_wirezsP D$)), 99 TYY%%f- -E  JJu Lrr.r>r?ctj|j}|j}|r|ddk(r|dd}|j d}nd}|||S)NrErr)rr0 get_uint16rsdecode)rr.r>rrbtexts rrBzEDEOption.from_wire_parsersb||F--/0##% Bx1}CRyKK'EE4rr;)rrrr`rrrrarr2r=rrbr9r+rr-rBrtrus@rrrYs+MN U7C<0     HSM Xe_   *c/*  4E      rrceZdZdeffd Zd dedeefdZdefdZ e de e efde jjdefd ZxZS) NSIDOptionnsidcNt|tj||_yr;)rgr2rr r)r1rrls rr2zNSIDOption.__init__s ) rr3r4cV|r|j|jy|jSr;)rnrr8s rr9zNSIDOption.to_wirerorctd|jDr|jj}n-tj|jj}d|S)Nc34K|]}|dk\xr|dkyw)r~Nr)rcs rrz%NSIDOption.to_text..s :1qDy&Q$Y&:szNSID )allrrbinasciihexlify)r1rs rr=zNSIDOption.to_textsO : : :II$$&E$$TYY/668Eugrr.r>c.||jSr;rrrAs rrBzNSIDOption.from_wire_parsers6'')**rr;)rrrrbr2rrr9rar=r+rrrhrGParserr-rBrtrus@rrrsoUC8E?+*c/*+47HHOO+ ++rr_type_to_classr.r4c@tj|}|t}|S)zReturn the class for the specified option type. The GenericOption class is used if a more specific class is not known. )rgetrd)r.rs rget_option_classrs#   U #C { Jrr>r?cftj|}t|}|j||S)aBuild an EDNS option object from wire format. *otype*, an ``int``, is the option type. *parser*, a ``dns.wire.Parser``, the parser, which should be restricted to the option length. Returns an instance of a subclass of ``dns.edns.Option``. )rr0rrB)r.r>rs roption_from_wire_parserrs/ OOE "E 5 !C   v ..rrGcurrentolenctjj||}|j|5t ||cdddS#1swYyxYw)arBuild an EDNS option object from wire format. *otype*, an ``int``, is the option type. *wire*, a ``bytes``, is the wire-format message. *current*, an ``int``, is the offset in *wire* of the beginning of the rdata. *olen*, an ``int``, is the length of the wire-format option data Returns an instance of a subclass of ``dns.edns.Option``. N)rhrGr  restrict_tor)r.rGrrr>s roption_from_wirersE XX__T7 +F   D !6&uf5666s AAimplementationc|t|<y)zRegister the implementation of an option type. *implementation*, a ``class``, is a subclass of ``dns.edns.Option``. *otype*, an ``int``, is the option type. N)r)rr.s r register_typers+N5r),r`r rrrtypingrrrrdns.enumrhdns.inet dns.rdatadns.wireenumIntEnumrr-rdrwrrrr$r*r r__annotations__rrarrbrrrr!r"r#r%r&r'r(r)rrrr$s$ --!!:RRj2F28H%H%Vchh@: : z++8NNINNIOOZ)Z_% J 3 / S !/+</ /"6 S !6).69<6DG6 6*+#+j+T+nnnnnnnn          nnr