U
    2ÜŸj¹  ã                   @   s.  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
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)ÚOptionalÚUnion)Úwarn)Úimplementer)ÚLiteral)ÚIAddress)Ú_asFilesystemBytesÚ_coerceToFilesystemEncoding)ÚplatformT)Úunsafe_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©Z	validatorÚtypeÚhostÚportN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚattrÚibÚ
validatorsÚin_r   r   r   Ú__annotations__ÚstrÚint© r   r   ú</tmp/pip-unpacked-wheel-4b529toj/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$   Q   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%   X   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k	rReedœdd„Zneedœd	d„Zed
œ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}|s†| jr†|jr†ztj | j|j¡W S  tk
rT   Y n2 tt	fk
r„ } zt
 ¡ st|‚W 5 d}~X Y nX |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
   ZisLinux)Úselfr/   ÚresÚer   r   r    Ú__eq__y   s    zUNIXAddress.__eq__c                 C   s   t || jƒr| j|jkS tS ©N)r1   r2   r,   r3   )r9   r/   r   r   r    r<   �   s    )r0   c                 C   s(   | j }|d k	rtd|ƒnd }d|›d�S )NÚ zUNIXAddress(ú))r,   r	   )r9   r,   Úshowr   r   r    Ú__repr__”   s    zUNIXAddress.__repr__c                 C   sZ   | j d krt| jd fƒS zt | j ¡}t|j|jfƒW S  tk
rT   t| j ƒ Y S X d S r=   )r,   Úhashr2   r4   ÚstatÚst_inoÚst_devr6   )r9   Ú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   rG   r   r   r   r    r*   i   s   

ÿr*   c                   @   s    e Zd ZdZeedœdd„ZdS )Ú_ServerFactoryIPv4Addressz@Backwards compatibility hack. Just like IPv4Address in practice.r.   c                 C   s^   t |tƒr(tdtdd� | j| jf|kS t |tƒrZ| 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   )r9   r/   ÚaÚbr   r   r    r<   ª   s    
ý
z _ServerFactoryIPv4Address.__eq__N)r   r   r   r   rK   rL   r<   r   r   r   r    rM   §   s   rM   )r   r4   Útypingr   r   Úwarningsr   Zzope.interfacer   r   Ztyping_extensionsr   Ztwisted.internet.interfacesr   Ztwisted.python.filepathr   r	   Ztwisted.python.runtimer
   Úsr   r!   r$   r%   r*   rM   r   r   r   r    Ú<module>   s0    <