
    Ϫf                        d Z ddlZddlmZmZ ddlmZ ddlmZ ddl	Z	ddlm
Z
 ddlmZ ddlmZmZ dd	lmZ  ee       e	j$                  d
d
       G d d                    Z ee       e	j$                  d
d
       G d d                    Z ee       G d d             Z e	j$                  d
d
       ee       G d d                    Z e	j$                  dddd
       ee       G d d                    Z G d de      Zy)z*
Address objects for network connections.
    N)OptionalUnion)warn)implementer)Literal)IAddress)_asFilesystemBytes_coerceToFilesystemEncoding)platformT)hashauto_attribsc                       e Zd ZU dZ ej
                  ej                  j                  ddg            Ze	e
d   e
d   f   ed<   eed<   eed<   y)	IPv4Addressat  
    An L{IPv4Address} represents the address of an IPv4 socket endpoint.

    @ivar type: A string describing the type of transport, either 'TCP' or
        'UDP'.

    @ivar host: A string containing a dotted-quad IPv4 address; for example,
        "127.0.0.1".
    @type host: C{str}

    @ivar port: An integer representing the port number.
    @type port: C{int}
    TCPUDP	validatortypehostportN)__name__
__module____qualname____doc__attrib
validatorsin_r   r   r   __annotations__strint     :/usr/lib/python3/dist-packages/twisted/internet/address.pyr   r      sT     3:$''//%%uen53D%.
/  I
Ir#   r   c                       e Zd ZU dZ ej
                  ej                  j                  ddg            Ze	e
d   e
d   f   ed<   eed<   eed<   dZeed	<   dZe	eef   ed
<   y)IPv6Addressa  
    An L{IPv6Address} represents the address of an IPv6 socket endpoint.

    @ivar type: A string describing the type of transport, either 'TCP' or
        'UDP'.

    @ivar host: A string containing a colon-separated, hexadecimal formatted
        IPv6 address; for example, "::1".
    @type host: C{str}

    @ivar port: An integer representing the port number.
    @type port: C{int}

    @ivar flowInfo: the IPv6 flow label.  This can be used by QoS routers to
        identify flows of traffic; you may generally safely ignore it.
    @type flowInfo: L{int}

    @ivar scopeID: the IPv6 scope identifier - roughly analagous to what
        interface traffic destined for this address must be transmitted over.
    @type scopeID: L{int} or L{str}
    r   r   r   r   r   r   r   flowInfoscopeIDN)r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r'   r(   r"   r#   r$   r&   r&   /   sp    , 3:$''//%%uen53D%.
/  I
IHc GU38_ r#   r&   c                       e Zd ZdZy)_ProcessAddresszD
    An L{interfaces.IAddress} provider for process transports.
    N)r   r   r   r   r"   r#   r$   r*   r*   Q   s    r#   r*   c                   &    e Zd ZU dZeed<   eed<   y)HostnameAddressa  
    A L{HostnameAddress} represents the address of a L{HostnameEndpoint}.

    @ivar hostname: A hostname byte string; for example, b"example.com".
    @type hostname: L{bytes}

    @ivar port: An integer representing the port number.
    @type port: L{int}
    hostnamer   N)r   r   r   r   bytesr   r!   r"   r#   r$   r,   r,   X   s     O
Ir#   r,   F)r   repreqr   c                       e Zd ZU dZ ej
                  ej                  j                  e            Z	e
e   ed<    eej                  dd      	dedefdZndedefd	Zdefd
Zd Zy)UNIXAddressz
    Object representing a UNIX socket endpoint.

    @ivar name: The filename associated with this socket.
    @type name: C{bytes}
    )	converternamesamefileNotherreturnc                    t        || j                        st        S | j                  |j                  k(  }|sM| j                  rA|j                  r5	 t        j
                  j                  | j                  |j                        S |S # t        $ r Y |S t        t        f$ r!}t        j                         s|Y d}~|S d}~ww xY w)z
            Overriding C{attrs} to ensure the os level samefile
            check is done if the name attributes do not match.
            N)
isinstance	__class__NotImplementedr4   ospathr5   OSError	TypeError
ValueErrorr   isLinux)selfr6   reses       r$   __eq__zUNIXAddress.__eq__y   s    
 eT^^4%%))uzz)C499 77++DIIuzzBB J   J ":.   $++- .J s   3B 	CC!B==Cc                 l    t        || j                        r| j                  |j                  k(  S t        S N)r9   r:   r4   r;   )rB   r6   s     r$   rE   zUNIXAddress.__eq__   s)    %0yyEJJ..!!r#   c                 F    | j                   }|t        d|      nd }d|dS )N zUNIXAddress())r4   r
   )rB   r4   shows      r$   __repr__zUNIXAddress.__repr__   s.    yy8<8H*2t4ddXQ''r#   c                    | j                   t        | j                  d f      S 	 t        j                  | j                         }t        |j
                  |j                  f      S # t        $ r t        | j                         cY S w xY wrG   )r4   r   r:   r<   statst_inost_devr>   )rB   s1s     r$   __hash__zUNIXAddress.__hash__   sl    99.//	##BBII.// 	#		?"	#s   ?A% %BB)r   r   r   r   r   r   
convertersoptionalr	   r4   r   r.   r   getattrr<   r=   objectboolrE   r    rL   rR   r"   r#   r$   r2   r2   i   s     $DGG//**+=>D(5/  rww
D)5	 	4 	,	" 	"4 	"
(# (
#r#   r2   c                        e Zd ZdZdedefdZy)_ServerFactoryIPv4Addressz@Backwards compatibility hack. Just like IPv4Address in practice.r6   r7   c                 >   t        |t              r-t        dt        d       | j                  | j
                  f|k(  S t        |t              rK| j                  | j                  | j
                  f}|j                  |j                  |j
                  f}||k(  S t        S )Nz?IPv4Address.__getitem__ is deprecated.  Use attributes instead.   )category
stacklevel)	r9   tupler   DeprecationWarningr   r   r   r   r;   )rB   r6   abs       r$   rE   z _ServerFactoryIPv4Address.__eq__   s    eU#T+
 IItyy)U22{+DIItyy1AUZZ4A6Mr#   N)r   r   r   r   rV   rW   rE   r"   r#   r$   rY   rY      s    JF t r#   rY   )r   r<   typingr   r   warningsr   zope.interfacer   r   r   twisted.internet.interfacesr   twisted.python.filepathr	   r
   twisted.python.runtimer   sr   r&   r*   r,   r2   rY   r"   r#   r$   <module>ri      s#  
 
 "  &   0 S + XT%  & , XT%! ! & !@ X   T%X   & U5t<X5# 5#  =5#x r#   