o
    pj|  ã                   @   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    =