/usr/lib/python3.9/site-packages/dns/__pycache__
Edit: /usr/lib/python3.9/site-packages/dns/__pycache__/inet.cpython-39.pyc (4603B)
a
àMÒeŒ ã @ sÌ d Z ddlZddlmZmZmZ ddlZddlZej Z ej
Z
eee
dœdd„Zee
edœdd „Zeed
œdd„Zeed
œd
d„Zeed
œdd„Zdeeef ee edœdd„Zdd„ Zeed
œdd„ZdS )z*Generic Internet address helper functions.é N)ÚAnyÚOptionalÚTuple)ÚfamilyÚtextÚreturnc C s2 | t krtj |¡S | tkr*tj |d¡S t‚dS )a Convert 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``.
TN)ÚAF_INETÚdnsÚipv4Ú inet_atonÚAF_INET6Úipv6ÚNotImplementedError)r r © r ú,/usr/lib/python3.9/site-packages/dns/inet.pyÚ inet_pton! s
r )r Úaddressr c C s0 | t krtj |¡S | tkr(tj |¡S t‚dS )a0 Convert 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``.
N)r r r
Z inet_ntoar r
r )r r r r r Ú inet_ntop6 s
r )r r c C sZ zt j | ¡ tW S tyT zt j | d¡ tW Y S tyN t‚Y n0 Y n0 dS )zäDetermine 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``.
TN)r r
r r Ú Exceptionr
r Ú
ValueError©r r r r Úaf_for_addressK s
r c C sr z"t j | ¡d }|dko |dkW S tyl z t j | d¡d }|dkW Y S tyf t‚Y n0 Y n0 dS )zÝIs 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``.
r éà éï Téÿ N)r r
r r r
r )r Úfirstr r r Úis_multicasta s r c C sX zt j | ¡ W dS tyR zt j | d¡ W Y dS tyL Y Y dS 0 Y n0 dS )z{Is the specified string an IPv4 or IPv6 address?
*text*, a ``str``, the textual address.
Returns a ``bool``.
TFN)r r
r r r
r r r r Ú
is_addressw s r )Ú
high_tupleÚafr c
C sâ | \}}|du rt |ƒ}|tkr(||fS |tkrÐ| d¡}|dk rN||ddfS |d|… }||d d… }| ¡ r‚||dt|ƒfS z||dt |¡fW S tyÌ tj }tj
|||d�^�^ }} }| Y S 0 ntd|› �ƒ‚dS )aX Given 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 é )Úflagsúunknown address family )r r r ÚfindÚisdigitÚintÚsocketZif_nametoindexÚAttributeErrorZAI_NUMERICHOSTZgetaddrinfor )
r r r ÚportÚiZaddrpartZscopeZai_flagsÚ_Útupr r r Úlow_level_address_tupleŠ s(
r- c C s. | t jkrdS | t jkrdS td| › �ƒ‚dS )z:Return the 'any' address for the specified address family.z0.0.0.0z::r# N)r' r r r )r r r r Ú
any_for_af® s
r. c C sP zt j | ¡W S tyJ zt j | ¡W Y S tyD t‚Y n0 Y n0 dS )a Verify that *address* is a valid text form IPv4 or IPv6 address and return its
canonical text form. IPv6 addresses with scopes are rejected.
*text*, a ``str``, the address in textual form.
Raises ``ValueError`` if the text is not valid.
N)r r
Úcanonicalizer r
r r r r r r/ · s r/ )N)Ú__doc__r' Útypingr r r Zdns.ipv4r Zdns.ipv6r r r&