U
    
W[~                     @   s4  d Z ddlmZmZ ddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ ee
ejd
dG dd deZee
ejd
dG dd deZee
G dd deZejd
dee
G dd deZejddddee
G dd deZG dd deZdS )z*
Address objects for network connections.
    )divisionabsolute_importN)implementer)IAddress)_asFilesystemBytes)_coerceToFilesystemEncoding)platform)_PY3T)hashc                   @   s8   e Zd ZdZejejddgdZe Z	e Z
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	validatorN)__name__
__module____qualname____doc__attrib
validatorsin_typehostport r   r   :/usr/lib/python3/dist-packages/twisted/internet/address.pyr      s   r   c                   @   sP   e Zd ZdZejejddgdZe Z	e Z
ejddZejddZ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   )defaultN)r   r   r   r   r   r   r   r   r   r   r   ZflowInfoZscopeIDr   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   K   s   r   c                   @   s    e Zd ZdZe Ze Z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}
    N)r   r   r   r   r   r   Zhostnamer   r   r   r   r   r   S   s   
r   F)r
   reprZcmpc                   @   s`   e Zd ZdZejejedZ	e
ejdddk	r<dd Zndd Zdd	 Z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}
    )Z	convertersamefileNc              
   C   s   t || jr| j|jk}ndS |s| jr|jrztj| j|jW S  tk
rV   Y n6 ttfk
r } zt	szt
 sz|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.
            FN)
isinstance	__class__nameospathr"   OSError	TypeError
ValueErrorr	   r   ZisLinux)selfotherreser   r   r   __eq__r   s    zUNIXAddress.__eq__c                 C   s   t || jr| j|jkS dS )NF)r#   r$   r%   r+   r,   r   r   r   r/      s    c                 C   s   t || jr| | S dS )NT)r#   r$   r/   r0   r   r   r   __ne__   s    zUNIXAddress.__ne__c                 C   s    | j }|rtd| j }d|f S )N zUNIXAddress(%r))r%   r   )r+   r%   r   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 )N)r%   r
   r$   r&   statst_inost_devr(   )r+   s1r   r   r   __hash__   s    
zUNIXAddress.__hash__)r   r   r   r   r   r   Z
convertersZoptionalr   r%   getattrr&   r'   r/   r1   r3   r8   r   r   r   r   r!   e   s   
r!   c                   @   s   e Zd ZdZdd ZdS )_ServerFactoryIPv4Addressz@Backwards compatibility hack. Just like IPv4Address in practice.c                 C   s`   t |tr*tjdtdd | j| jf|kS t |tr\| j| j| jf}|j|j|jf}||kS dS )Nz?IPv4Address.__getitem__ is deprecated.  Use attributes instead.   )category
stacklevelF)	r#   tuplewarningswarnDeprecationWarningr   r   r   r   )r+   r,   abr   r   r   r/      s    
 
z _ServerFactoryIPv4Address.__eq__N)r   r   r   r   r/   r   r   r   r   r:      s   r:   )r   Z
__future__r   r   r   r?   r&   Zzope.interfacer   Ztwisted.internet.interfacesr   Ztwisted.python.filepathr   r   Ztwisted.python.runtimer   Ztwisted.python.compatr	   sobjectr   r   r   r   r!   r:   r   r   r   r   <module>   s0   


A