fdZddlZddlmZmZmZddlZddlZejZ ejZ de de de fdZde de de fd Zde de fd Zde defd Zde defd Z dd ee e fdee defdZdZde de fdZy)z*Generic Internet address helper functions.N)AnyOptionalTuplefamilytextreturnc|tk(rtjj|S|tk(r tj j|dSt )aConvert the textual form of a network address into its binary form. *family* is an ``int``, the address family. *text* is a ``str``, the textual address. Raises ``NotImplementedError`` if the address family specified is not implemented. Returns a ``bytes``. T)AF_INETdnsipv4 inet_atonAF_INET6ipv6NotImplementedError)rrs Q/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/inet.py inet_ptonr!sFxx!!$'' 8 xx!!$--!!addressc|tk(rtjj|S|tk(rtj j|St )a0Convert the binary form of a network address into its textual form. *family* is an ``int``, the address family. *address* is a ``bytes``, the network address in binary form. Raises ``NotImplementedError`` if the address family specified is not implemented. Returns a ``str``. )r r r inet_ntoarrr)rrs r inet_ntopr6sDxx!!'** 8 xx!!'**!!rc tjj|tS#t$r= tj j|dt cYS#t$rtwxYwwxYw)zDetermine the address family of a textual-form network address. *text*, a ``str``, the textual address. Raises ``ValueError`` if the address family cannot be determined from the input. Returns an ``int``. T)r r r r Exceptionrr ValueErrorrs raf_for_addressrKs` 4    HH  tT *O    s $' A-%AA-A))A-c tjj|d}|dk\xr|dkS#t$r? tjj|dd}|dk(cYS#t$rt wxYwwxYw)zIs the textual-form network address a multicast address? *text*, a ``str``, the textual address. Raises ``ValueError`` if the address family cannot be determined from the input. Returns a ``bool``. rT)r r r rrr)rfirsts r is_multicastr"as""4(+|, ,  HH&&tT215EC<     s -0 A8'A$!A8$A44A8c tjj|y#t$r4 tjj|dYy#t$rYYywxYwwxYw)z{Is the specified string an IPv4 or IPv6 address? *text*, a ``str``, the textual address. Returns a ``bool``. TF)r r r rrrs r is_addressr$wsY 4    HH  tT *   s&" A A AAAA high_tupleafc|\}}| t|}|tk(r||fS|tk(rb|jd}|dkr||ddfS|d|}||dzd}|j r||dt |fS ||dt j|fStd|#t$r2t j}t j|||^^}} }| cYSwxYw)aXGiven a "high-level" address tuple, i.e. an (address, port) return the appropriate "low-level" address tuple suitable for use in socket calls. If an *af* other than ``None`` is provided, it is assumed the address in the high-level tuple is valid and has that af. If af is ``None``, then af_for_address will be called. N%r)flagsunknown address family ) rr rfindisdigitintsocketif_nametoindexAttributeErrorAI_NUMERICHOST getaddrinfor) r%r&rportiaddrpartscopeai_flags_tups rlow_level_address_tupler;sMGT z G $ W} x LL  q5T1a( (2A;A  ==?dAs5z2 2 dAv'<'rHs$1 '' .. ??"c"""*"c"E"c"*,st,ST(6:!Bc3h!B%-c]!B!BH>ssr