o
    f|                     @   s&  d Z ddlZddlmZ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mZ ddlmZ e	ee
jd	d	d
G dd dZe	ee
jd	d	d
G dd dZe	eG dd dZe
jd	d	d
e	eG dd dZe
jdddd	de	eG dd dZG dd deZdS )z*
Address objects for network connections.
    N)LiteralOptionalUnion)warn)implementer)IAddress)_asFilesystemBytes_coerceToFilesystemEncoding)platformT)hashauto_attribsc                   @   sR   e Zd ZU dZejejddgdZe	e
d e
d f ed< eed< eed< dS )	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 r    r    :/usr/lib/python3/dist-packages/twisted/internet/address.pyr      s   
 r   c                   @   sr   e Zd ZU dZejejddgd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
< dS )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"   .   s   
 r"   c                   @   s   e Zd ZdZdS )_ProcessAddresszD
    An L{interfaces.IAddress} provider for process transports.
    N)r   r   r   r   r    r    r    r!   r%   P   s    r%   c                   @   s"   e Zd ZU dZeed< eed< dS )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&   W   s   
 
r&   F)r   repreqr   c                   @   s   e Zd ZU dZejejedZ	e
e ed< eejdddur*dedefdd	Zn	dedefd
d	ZdefddZdd ZdS )UNIXAddressz
    Object representing a UNIX socket endpoint.

    @ivar name: The filename associated with this socket.
    @type name: C{bytes}
    )	converternamesamefileNotherreturnc              
   C   s   t || jstS | j|jk}|sE| jrE|jrEz
tj| j|jW S  ty*   Y |S  tt	fyD } zt
 s9|W Y d}~|S d}~ww |S )z
            Overriding C{attrs} to ensure the os level samefile
            check is done if the name attributes do not match.
            N)
isinstance	__class__NotImplementedr-   ospathr.   OSError	TypeError
ValueErrorr
   isLinux)selfr/   reser    r    r!   __eq__x   s"   
zUNIXAddress.__eq__c                 C   s   t || jr| j|jkS tS N)r1   r2   r-   r3   )r:   r/   r    r    r!   r=      s   c                 C   s"   | j }|rtd| j }d|dS )N zUNIXAddress())r-   r	   )r:   r-   r    r    r!   __repr__   s   zUNIXAddress.__repr__c                 C   sT   | j d u rt| jd fS zt| j }t|j|jfW S  ty)   t| j  Y S w r>   )r-   r   r2   r4   statst_inost_devr6   )r:   s1r    r    r!   __hash__   s   
zUNIXAddress.__hash__)r   r   r   r   r   r   
convertersoptionalr   r-   r   r(   r   getattrr4   r5   objectboolr=   r   rA   rF   r    r    r    r!   r+   h   s   
 
r+   c                   @   s"   e Zd ZdZdedefddZdS )_ServerFactoryIPv4Addressz@Backwards compatibility hack. Just like IPv4Address in practice.r/   r0   c                 C   s^   t |trtdtdd | j| jf|kS t |tr-| j| j| jf}|j|j|jf}||kS tS )Nz?IPv4Address.__getitem__ is deprecated.  Use attributes instead.   )category
stacklevel)	r1   tupler   DeprecationWarningr   r   r   r   r3   )r:   r/   abr    r    r!   r=      s   

z _ServerFactoryIPv4Address.__eq__N)r   r   r   r   rJ   rK   r=   r    r    r    r!   rL      s    rL   )r   r4   typingr   r   r   warningsr   zope.interfacer   r   twisted.internet.interfacesr   twisted.python.filepathr   r	   twisted.python.runtimer
   sr   r"   r%   r&   r+   rL   r    r    r    r!   <module>   s0    =