%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/endpoints.cpython-312.pyc

�

Ϫ�f\2���dZddlZddlZddlZddlZddlmZmZmZddl	m
Z
ddlmZm
Z
mZddlmZmZddlmZddlmZmZmZmZmZdd	lmZmZdd
lmZmZm Z m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/	dd
l0m1Z1m2Z2ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z=m>Z>ddl?m@Z@mAZAddlBmCZCmDZDmEZEddlFmGZGddlHmIZIddlJmKZKddlLmMZMddlNmOZOmPZP	ddlQmRZSddlTmUZUmVZVmWZWmXZXmYZYmZZZddl[m\Z]e]Z\gd�Z^Gd�d e/�Z_Gd!�d"e,�Z`e
ej��Gd#�d$��ZbGd%�d&ej�ej�ej��ZfGd'�d(eGefd)��ZgGd*�d+e.�ZhGd,�d-e�Zie
ej��Gd.�d/��Zke
ej��Gd0�d1��ZlGd2�d3el�ZmGd4�d5el�Zne
ej��Gd6�d7��Zoe
ej��Gd8�d9��Zpe
e$�Gd:�d;��Zqe
ej��Gd<�d=��Zre
ej��Gd>�d?��Zse
ej��Gd@�dA��Zte
ej��GdB�dC��Zue
ej��GdD�dE��Zve
ej��GdF�dG��ZwdkdH�ZxdldI�Zy							dmdJ�Zze
e=e*�GdK�dL��Z{e
e=e*�GdM�dN��Z|e
e=e*�GdO�dP��Z}exeyezdQ�Z~edR�\Z�Z�dS�Z�dT�Z�emeseudU�Z�eoetevdU�Z�dV�Z�dW�Z�dX�Z�dY�Z�dZ�Z�d[�Z�d\�Z�d]�Z�d^�Z�d_�Z�d`�Z�e�e�e�dU�Z�da�Z�db�Z�e
ej��Gdc�dd��Z�e
ej��Gde�df��Z�dg�Z�						dndh�Z�e
e=e)�Gdi�dj��Z�y#e3$rdZ2dZ1Y��qwxYw#e3$rdZ\Y��wxYw)oa7
Implementations of L{IStreamServerEndpoint} and L{IStreamClientEndpoint} that
wrap the L{IReactorTCP}, L{IReactorSSL}, and L{IReactorUNIX} interfaces.

This also implements an extensible mini-language for describing endpoints,
parsed by the L{clientFromString} and L{serverFromString} functions.

@since: 10.1
�N)�Optional�Sequence�Type)�	normalize)�directlyProvides�implementer�provider)�
NamedConstant�Names)�Version)�defer�error�fdesc�
interfaces�threads)�isIPAddress�
isIPv6Address)�HostnameAddress�IPv4Address�IPv6Address�_ProcessAddress)�IAddress�IHostnameResolver�IHostResolution�IReactorPluggableNameResolver�IReactorSocket�IResolutionReceiver�,IStreamClientEndpointStringParserWithReactor�!IStreamServerEndpointStringParser)�
ClientFactory�Factory�ProcessProtocol�Protocol)�PipeAddress�
StandardIO)�HostResolution)�Deferred)�LoopingCall)�Logger)�IPlugin�
getPlugins)�	deprecate�log)�_matchingString�	iterbytes�nativeString)�proxyForInterface)�Failure)�FilePath)�	ListenFDs�)�
_idnaBytes�	_idnaText)�Error)�Certificate�CertificateOptions�KeyPair�PrivateCertificate�optionsForClientTLS�trustRootFromCertificates��TLSMemoryBIOFactory)�clientFromString�serverFromString�TCP4ServerEndpoint�TCP6ServerEndpoint�TCP4ClientEndpoint�TCP6ClientEndpoint�UNIXServerEndpoint�UNIXClientEndpoint�SSL4ServerEndpoint�SSL4ClientEndpoint�AdoptedStreamServerEndpoint�StandardIOEndpoint�ProcessEndpoint�HostnameEndpoint�StandardErrorBehavior�connectProtocol�
wrapClientTLSc�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�_WrappingProtocolz_
    Wrap another protocol in order to notify my user when a connection has
    been made.
    c���||_||_tjtjtj
fD]*}|j
|j�s�t||��,y)z�
        @param connectedDeferred: The L{Deferred} that will callback
            with the C{wrappedProtocol} when it is connected.

        @param wrappedProtocol: An L{IProtocol} provider that will be
            connected.
        N)�_connectedDeferred�_wrappedProtocolr�IHalfCloseableProtocol�IFileDescriptorReceiver�IHandshakeListener�
providedByr)�self�connectedDeferred�wrappedProtocol�ifaces    �</usr/lib/python3/dist-packages/twisted/internet/endpoints.py�__init__z_WrappingProtocol.__init__psb��#4��� /���
�-�-��.�.��)�)�
�	.�E�
���� 5� 5�6� ��u�-�
	.�c���tjj|j�r|jj	�S|jj
jS)zO
        Transparently pass through the wrapped protocol's log prefix.
        )r�ILoggingContextrZrV�	logPrefix�	__class__�__name__�r[s r_rdz_WrappingProtocol.logPrefix�sK���%�%�0�0��1F�1F�G��(�(�2�2�4�4��$�$�.�.�7�7�7rac��|jj|j�|jj	|j�y)z�
        Connect the C{self._wrappedProtocol} to our C{self.transport} and
        callback C{self._connectedDeferred} with the C{self._wrappedProtocol}
        N)rV�makeConnection�	transportrU�callbackrgs r_�connectionMadez _WrappingProtocol.connectionMade�s6��
	
���,�,�T�^�^�<����(�(��)>�)>�?rac�8�|jj|�S)zM
        Proxy C{dataReceived} calls to our C{self._wrappedProtocol}
        )rV�dataReceived)r[�datas  r_rnz_WrappingProtocol.dataReceived�s���$�$�1�1�$�7�7rac�8�|jj|�S)zW
        Proxy C{fileDescriptorReceived} calls to our C{self._wrappedProtocol}
        )rV�fileDescriptorReceived)r[�
descriptors  r_rqz(_WrappingProtocol.fileDescriptorReceived�s���$�$�;�;�J�G�Grac�8�|jj|�S)zO
        Proxy C{connectionLost} calls to our C{self._wrappedProtocol}
        )rV�connectionLost�r[�reasons  r_rtz _WrappingProtocol.connectionLost�s���$�$�3�3�F�;�;rac�8�|jj�y)zl
        Proxy L{IHalfCloseableProtocol.readConnectionLost} to our
        C{self._wrappedProtocol}
        N)rV�readConnectionLostrgs r_rxz$_WrappingProtocol.readConnectionLost����
	
���0�0�2rac�8�|jj�y)zm
        Proxy L{IHalfCloseableProtocol.writeConnectionLost} to our
        C{self._wrappedProtocol}
        N)rV�writeConnectionLostrgs r_r{z%_WrappingProtocol.writeConnectionLost�s��
	
���1�1�3rac�8�|jj�y)za
        Proxy L{interfaces.IHandshakeListener} to our
        C{self._wrappedProtocol}.
        N)rV�handshakeCompletedrgs r_r}z$_WrappingProtocol.handshakeCompleted�ryraN)
rf�
__module__�__qualname__�__doc__r`rdrlrnrqrtrxr{r}�rar_rSrSjs6���
.�&8�@�8�H�<�3�4�3rarSc�>�eZdZdZeZd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zy	)
�_WrappingFactorya�
    Wrap a factory in order to wrap the protocols it builds.

    @ivar _wrappedFactory: A provider of I{IProtocolFactory} whose buildProtocol
        method will be called and whose resulting protocol will be wrapped.

    @ivar _onConnection: A L{Deferred} that fires when the protocol is
        connected

    @ivar _connector: A L{connector <twisted.internet.interfaces.IConnector>}
        that is managing the current or previous connection attempt.
    c�\�||_tj|j��|_y)z�
        @param wrappedFactory: A provider of I{IProtocolFactory} whose
            buildProtocol method will be called and whose resulting protocol
            will be wrapped.
        ��	cancellerN)�_wrappedFactoryr
r'�
_canceller�
_onConnection)r[�wrappedFactorys  r_r`z_WrappingFactory.__init__�s!�� .���"�^�^�d�o�o�F��rac��||_y)z~
        A connection attempt was started.  Remember the connector which started
        said attempt, for use later.
        N)�
_connector)r[�	connectors  r_�startedConnectingz"_WrappingFactory.startedConnecting�s��
$��rac��|jtj|jj	���|jj�y)a;
        The outgoing connection attempt was cancelled.  Fail that L{Deferred}
        with an L{error.ConnectingCancelledError}.

        @param deferred: The L{Deferred <defer.Deferred>} that was cancelled;
            should be the same as C{self._onConnection}.
        @type deferred: L{Deferred <defer.Deferred>}

        @note: This relies on startedConnecting having been called, so it may
            seem as though there's a race condition where C{_connector} may not
            have been set.  However, using public APIs, this condition is
            impossible to catch, because a connection API
            (C{connectTCP}/C{SSL}/C{UNIX}) is always invoked before a
            L{_WrappingFactory}'s L{Deferred <defer.Deferred>} is returned to
            C{connect()}'s caller.

        @return: L{None}
        N)�errbackr�ConnectingCancelledErrorr��getDestination�stopConnecting)r[�deferreds  r_r�z_WrappingFactory._canceller�s?��&	����*�*�4�?�?�+I�+I�+K�L�	
�	
���&�&�(rac�8�|jj�y)zY
        Start notifications are passed straight through to the wrapped factory.
        N)r��doStartrgs r_r�z_WrappingFactory.doStart�s��	
���$�$�&rac�8�|jj�y)zX
        Stop notifications are passed straight through to the wrapped factory.
        N)r��doStoprgs r_r�z_WrappingFactory.doStop�s��	
���#�#�%rac���	|jj|�}|�tj��	|j	|j
|�S#t$r|j
j�YywxYw)a
        Proxy C{buildProtocol} to our C{self._wrappedFactory} or errback the
        C{self._onConnection} L{Deferred} if the wrapped factory raises an
        exception or returns L{None}.

        @return: An instance of L{_WrappingProtocol} or L{None}
        N)r��
buildProtocolr�
NoProtocol�protocolr��
BaseExceptionr�)r[�addr�protos   r_r�z_WrappingFactory.buildProtocolsr��	<��(�(�6�6�t�<�E��}��&�&�(�(��
�=�=��!3�!3�U�;�;���	)����&�&�(�	)�s�1A�#A6�5A6c�h�|jjs|jj|�yy)zi
        Errback the C{self._onConnection} L{Deferred} when the
        client connection fails.
        N)r��calledr�)r[r�rvs   r_�clientConnectionFailedz'_WrappingFactory.clientConnectionFaileds,��
�!�!�(�(����&�&�v�.�)raN)
rfr~rr�rSr�r`r�r�r�r�r�r�r�rar_r�r��s2���!�H�G�$�)�0'�&�<�"/rar�c� �eZdZdZeZd�Zd�Zy)rLz�
    A Standard Input/Output endpoint

    @ivar _stdio: a callable, like L{stdio.StandardIO}, which takes an
        L{IProtocol} provider and a C{reactor} keyword argument (interface
        dependent upon your platform).
    c��||_y)z?
        @param reactor: The reactor for the endpoint.
        N)�_reactor�r[�reactors  r_r`zStandardIOEndpoint.__init__&s�� ��
rac��tj|j|jt	��|j
��S)zU
        Implement L{IStreamServerEndpoint.listen} to listen on stdin/stdout
        )r�)r
�execute�_stdior�r$r�)r[�stdioProtocolFactorys  r_�listenzStandardIOEndpoint.listen,s3���}�}��K�K� �.�.�{�}�=��M�M�
�	
raN)rfr~rr�r%r�r`r�r�rar_rLrLs����F� �
rarLc��eZdZdZy)�)_IProcessTransportWithConsumerAndProducera)
    An L{_IProcessTransportWithConsumerAndProducer} combines various interfaces
    to work around the issue that L{interfaces.IProcessTransport} is
    incompletely defined and doesn't specify flow-control interfaces, and that
    L{proxyForInterface} doesn't allow for multiple interfaces.
    N�rfr~rr�r�rar_r�r�7s��rar�c��eZdZdZy)�_ProcessEndpointTransportaj
    An L{ITransport}, L{IProcessTransport}, L{IConsumer}, and L{IPushProducer}
    provider for the L{IProtocol} instance passed to the process endpoint.

    @ivar _process: An active process transport which will be used by write
        methods on this object to write data to a child process.
    @type _process: L{interfaces.IProcessTransport} provider
    Nr�r�rar_r�r�Bs��rar��_processc�(�eZdZdZd�Zd�Zd�Zd�Zy)�_WrapIProtocolz�
    An L{IProcessProtocol} provider that wraps an L{IProtocol}.

    @ivar transport: A L{_ProcessEndpointTransport} provider that is hooked to
        the wrapped L{IProtocol} provider.

    @see: L{protocol.ProcessProtocol}
    c�.�||_||_||_y)z�
        @param proto: An L{IProtocol} provider.
        @param errFlag: A constant belonging to L{StandardErrorBehavior}
            that determines if stderr is logged or dropped.
        @param executable: The file name (full path) to spawn.
        N)r��errFlag�
executable)r[r�r�r�s    r_r`z_WrapIProtocol.__init__\s����
����$��rac�l�t|�|_|jj|j�S)z�
        Call L{IProtocol} provider's makeConnection method with an
        L{ITransport} provider.

        @param process: An L{IProcessTransport} provider.
        )r�rjr�ri)r[�processs  r_riz_WrapIProtocol.makeConnectiongs)��3�7�;����}�}�+�+�D�N�N�;�;rac���|dk(r|jj|�S|dk(rL|jtjk(r.tjd|j|j|��yyy)z�
        This is called with data from the process's stdout or stderr pipes. It
        checks the status of the errFlag to setermine if stderr should be
        logged (default) or dropped.
        r5�zGProcess %(executable)r wrote stderr unhandled by %(protocol)s: %(data)s)�formatr�r�roN)r�rnr�rO�LOGr-�msgr�)r[�childFDros   r_�childDataReceivedz _WrapIProtocol.childDataReceivedqsc���a�<��=�=�-�-�d�3�3�
��\�d�l�l�.C�.G�.G�G��G�G�)��?�?�����
�H�\rac�6�|jtj�tjk(rO|jjdk(r6|j
j
ttj���S|j
j
|�S)z�
        If the process ends with L{error.ProcessDone}, this method calls the
        L{IProtocol} provider's L{connectionLost} with a
        L{error.ConnectionDone}

        @see: L{ProcessProtocol.processEnded}
        r)	�checkr�ProcessDone�value�statusr�rtr2�ConnectionDonerus  r_�processEndedz_WrapIProtocol.processEnded�sk��
�L�L��*�*�+�u�/@�/@�@��L�L���1�$��=�=�/�/���8L�8L�8N�0O�P�P��=�=�/�/��7�7raN)rfr~rr�r`rir�r�r�rar_r�r�Rs���	%�<��"
8rar�c�,�eZdZdZe�Ze�Zy)rOz�
    Constants used in ProcessEndpoint to decide what to do with stderr.

    @cvar LOG: Indicates that stderr is to be logged.
    @cvar DROP: Indicates that stderr is to be dropped (and not logged).

    @since: 13.1
    N)rfr~rr�r
r��DROPr�rar_rOrO�s����/�C��?�DrarOc�B�eZdZdZdidddddej
fd�Zd�Zy)rMz�
    An endpoint for child processes

    @ivar _spawnProcess: A hook used for testing the spawning of child process.

    @since: 13.1
    r�Nrc���||_||_||_||_||_||_||_||_|	|_|
|_	|jj|_y)z�
        See L{IReactorProcess.spawnProcess}.

        @param errFlag: Determines if stderr should be logged.
        @type errFlag: L{endpoints.StandardErrorBehavior}
        N)r��_executable�_args�_env�_path�_uid�_gid�_usePTY�	_childFDs�_errFlag�spawnProcess�
_spawnProcess)r[r�r��args�env�path�uid�gid�usePTY�childFDsr�s           r_r`zProcessEndpoint.__init__�s]��& ��
�%�����
���	���
���	���	����!�����
�!�]�]�7�7��rac��|jt��}	|jt||j|j
�|j|j|j|j|j|j|j|j�	tj|�S#t$rtj �cYSwxYw)a3
        Implement L{IStreamClientEndpoint.connect} to launch a child process
        and connect it to a protocol created by C{protocolFactory}.

        @param protocolFactory: A factory for an L{IProtocol} provider which
            will be notified of all events related to the created process.
        )r�rr�r�r�r�r�r�r�r�r�r�r�r
�succeedr��fail)r[�protocolFactoryr�s   r_�connectzProcessEndpoint.connect�s��� �-�-�o�.?�@��	(�����u�d�&6�&6��
�
�F�� � ��
�
��	�	��
�
��	�	��	�	�������

��=�=��'�'���	 ��:�:�<��	 �s�BB8�8C�C)rfr~rr�rOr�r`r�r�rar_rMrM�s1�����
�����%�)�)�8�>(rarMc��eZdZdZd�Zd�Zy)�_TCPServerEndpointz)
    A TCP server endpoint interface
    c�<�||_||_||_||_y)a+
        @param reactor: An L{IReactorTCP} provider.

        @param port: The port number used for listening
        @type port: int

        @param backlog: Size of the listen queue
        @type backlog: int

        @param interface: The hostname to bind to
        @type interface: str
        N)r��_port�_backlog�
_interface�r[r��port�backlog�	interfaces     r_r`z_TCPServerEndpoint.__init__�s �� ��
���
���
�#��rac��tj|jj|j||j
|j��S)z]
        Implement L{IStreamServerEndpoint.listen} to listen on a TCP
        socket
        )r�r�)r
r�r��	listenTCPr�r�r��r[r�s  r_r�z_TCPServerEndpoint.listen�s:��
�}�}��M�M�#�#��J�J���M�M��o�o�
�	
raN�rfr~rr�r`r�r�rar_r�r��s���$�$
rar�c��eZdZdZdd�Zy)rCzC
    Implements TCP server endpoint with an IPv4 configuration
    c�6�tj|||||�y)aA
        @param reactor: An L{IReactorTCP} provider.

        @param port: The port number used for listening
        @type port: int

        @param backlog: Size of the listen queue
        @type backlog: int

        @param interface: The hostname to bind to, defaults to '' (all)
        @type interface: str
        N�r�r`r�s     r_r`zTCP4ServerEndpoint.__init__���	�#�#�D�'�4��)�LraN��2��rfr~rr�r`r�rar_rCrC
�
���
MrarCc��eZdZdZdd�Zy)rDzC
    Implements TCP server endpoint with an IPv6 configuration
    c�6�tj|||||�y)aD
        @param reactor: An L{IReactorTCP} provider.

        @param port: The port number used for listening
        @type port: int

        @param backlog: Size of the listen queue
        @type backlog: int

        @param interface: The hostname to bind to, defaults to C{::} (all)
        @type interface: str
        Nr�r�s     r_r`zTCP6ServerEndpoint.__init__$r�raN�r�z::r�r�rar_rDrDr�rarDc��eZdZdZdd�Zd�Zy)rEz9
    TCP client endpoint with an IPv4 configuration.
    Nc�J�||_||_||_||_||_y)a�
        @param reactor: An L{IReactorTCP} provider

        @param host: A hostname, used when connecting
        @type host: str

        @param port: The port number, used when connecting
        @type port: int

        @param timeout: The number of seconds to wait before assuming the
            connection has failed.
        @type timeout: L{float} or L{int}

        @param bindAddress: A (host, port) tuple of local address to bind to,
            or None.
        @type bindAddress: tuple
        N�r��_hostr��_timeout�_bindAddress�r[r��hostr��timeout�bindAddresss      r_r`zTCP4ClientEndpoint.__init__:s(��$ ��
���
���
���
�'��rac��	t|�}|jj|j|j||j
|j��|jS#t$rtj�cYSwxYw)zP
        Implement L{IStreamClientEndpoint.connect} to connect via TCP.
        �rr)r�r��
connectTCPrr�rrr�r�r
r��r[r��wfs   r_r�zTCP4ClientEndpoint.connectRsr��	 �!�/�2�B��M�M�$�$��
�
��
�
���
�
� �-�-�
%�
��#�#�#���	 ��:�:�<��	 �s�AA!�!B�B��N�rfr~rr�r`r�r�rar_rErE4s���(�0 rarEc�z�eZdZdZeej�Zeej�Z
dZdZd	d�Z
d�Zd�Zd�Zy)
rFa�
    TCP client endpoint with an IPv6 configuration.

    @ivar _getaddrinfo: A hook used for testing name resolution.

    @ivar _deferToThread: A hook used for testing deferToThread.

    @ivar _GAI_ADDRESS: Index of the address portion in result of
        getaddrinfo to be used.

    @ivar _GAI_ADDRESS_HOST: Index of the actual host-address in the
        5-tuple L{_GAI_ADDRESS}.
    �rNc�J�||_||_||_||_||_y)z�
        @param host: An IPv6 address literal or a hostname with an
            IPv6 address

        @see: L{twisted.internet.interfaces.IReactorTCP.connectTCP}
        Nr�rs      r_r`zTCP6ClientEndpoint.__init__ys(�� ��
���
���
���
�'��rac���t�j�r�j�j|�}|S�j�j�}|j	�fd��|j	�j|�|S)z~
        Implement L{IStreamClientEndpoint.connect} to connect via TCP,
        once the hostname resolution is done.
        c�B��|d�j�jS)Nr)�_GAI_ADDRESS�_GAI_ADDRESS_HOST)�resultr[s �r_�<lambda>z,TCP6ClientEndpoint.connect.<locals>.<lambda>�s!���v�a�y��):�):�;�D�<R�<R�S�ra)rr�_resolvedHostConnect�_nameResolution�addCallback)r[r��ds`  r_r�zTCP6ClientEndpoint.connect�sn���
����$��)�)�$�*�*�o�F�A����$�$�T�Z�Z�0�A�
�M�M�S�
�
�M�M�$�3�3�_�E��rac�Z�|j|j|dtj�S)zd
        Resolve the hostname string into a tuple containing the host
        IPv6 address.
        r)�_deferToThread�_getaddrinfo�socket�AF_INET6�r[rs  r_rz"TCP6ClientEndpoint._nameResolution�s%��
�"�"�4�#4�#4�d�A�v���O�Orac���	t|�}|jj||j||j|j
��|jS#t$rtj�cYSwxYw)zD
        Connect to the server using the resolved hostname.
        r)
r�r�r	r�rrr�r�r
r�)r[�resolvedHostr�rs    r_rz'TCP6ClientEndpoint._resolvedHostConnect�sn��	 �!�/�2�B��M�M�$�$���
�
���
�
� �-�-�
%�
��#�#�#���	 ��:�:�<��	 �s�AA�A7�6A7r)rfr~rr��staticmethodr�getaddrinforr�
deferToThreadrrrr`r�rrr�rar_rFrFdsI��� �� 2� 2�3�L�!�'�"7�"7�8�N��L���(�
�P� rarFc
�^�eZdZdZe�Zd�Z			ddedede	de
eee
ded	efd
�Zy)�_SimpleHostnameResolvera^
    An L{IHostnameResolver} provider that invokes a provided callable
    to resolve hostnames.

    @ivar _nameResolution: the callable L{resolveHostName} invokes to
        resolve hostnames.
    @type _nameResolution: A L{callable} that accepts two arguments:
        the host to resolve and the port number to include in the
        result.
    c��||_y)z?
        Create a L{_SimpleHostnameResolver} instance.
        N)r)r[�nameResolutions  r_r`z _SimpleHostnameResolver.__init__�s�� .��raN�resolutionReceiver�hostName�
portNumber�addressTypes�transportSemantics�returnc������t��}�j|��j�|�}�fd�}��fd�}	|j|�|j	|	�|j�fd��|S)a
        Initiate a hostname resolution.

        @param resolutionReceiver: an object that will receive each resolved
            address as it arrives.
        @type resolutionReceiver: L{IResolutionReceiver}

        @param hostName: see interface

        @param portNumber: see interface

        @param addressTypes: Ignored in this implementation.

        @param transportSemantics: Ignored in this implementation.

        @return: The resolution in progress.
        @rtype: L{IResolutionReceiver}
        c����|D]f\}}}}}|tjk(r�jtdg|�����8|tjk(s�L�jtdg|�����hy)N�TCP)rr �addressResolvedr�AF_INETr)�	gairesult�family�socktyper��	canonname�sockaddrr+s      �r_�	cbDeliverz:_SimpleHostnameResolver.resolveHostName.<locals>.cbDeliver�sg���@I�
V�<���%��H��V�_�_�,�&�6�6�{�5�7T�8�7T�U��v�~�~�-�&�6�6�{�5�7T�8�7T�U�	
Vrac�X���jjd|��j��y)Nz'while looking up {name} with {callable})�name�callable)�_log�failurer)rr,r[s ��r_�ebLogz6_SimpleHostnameResolver.resolveHostName.<locals>.ebLog�s,����I�I���9����-�-�	
�
rac�$���j�S�N)�resolutionComplete)�ignoredr+s �r_rz9_SimpleHostnameResolver.resolveHostName.<locals>.<lambda>�s���"4�"G�"G�"I�ra)r&�resolutionBeganrr�
addErrback�addBoth)
r[r+r,r-r.r/�
resolutionrr;rAs
```       r_�resolveHostNamez'_SimpleHostnameResolver.resolveHostName�sg���4$�H�-�
��*�*�:�6�� � ��:�6��	V�	�	
�
�
�i� �	���U��	�	�	�I�J��ra)rNr3)rfr~rr�r)r?r`r�str�intrrrrrrJr�rar_r(r(�sm��	��8�D�.��;?�"'�
0�/�0��0��	0�
�x��X��7�8�0� �
0�
�0rar(c��eZdZdZeej�Zeej�Z
dZ	dd�Zde
fd�Zd�Zed��Zd	�Zd
�Zy)rNaB
    A name-based endpoint that connects to the fastest amongst the resolved
    host addresses.

    @cvar _DEFAULT_ATTEMPT_DELAY: The default time to use between attempts, in
        seconds, when no C{attemptDelay} is given to
        L{HostnameEndpoint.__init__}.

    @ivar _hostText: the textual representation of the hostname passed to the
        constructor.  Used to pass to the reactor's hostname resolver.
    @type _hostText: L{unicode}

    @ivar _hostBytes: the encoded bytes-representation of the hostname passed
        to the constructor.  Used to construct the L{HostnameAddress}
        associated with this endpoint.
    @type _hostBytes: L{bytes}

    @ivar _hostStr: the native-string representation of the hostname passed to
        the constructor, used for exception construction
    @type _hostStr: native L{str}

    @ivar _badHostname: a flag - hopefully false!  - indicating that an invalid
        hostname was passed to the constructor.  This might be a textual
        hostname that isn't valid IDNA, or non-ASCII bytes.
    @type _badHostname: L{bool}
    g333333�?Nc�,�||_|j|�|_|j|�\|_|_|_ttur|j
n|j|_	||_
||_||_|�|j}||_y)a�
        Create a L{HostnameEndpoint}.

        @param reactor: The reactor to use for connections and delayed calls.
        @type reactor: provider of L{IReactorTCP}, L{IReactorTime} and either
            L{IReactorPluggableNameResolver} or L{IReactorPluggableResolver}.

        @param host: A hostname to connect to.
        @type host: L{bytes} or L{unicode}

        @param port: The port number to connect to.
        @type port: L{int}

        @param timeout: For each individual connection attempt, the number of
            seconds to wait before assuming the connection has failed.
        @type timeout: L{float} or L{int}

        @param bindAddress: the local address of the network interface to make
            the connections from.
        @type bindAddress: L{bytes}

        @param attemptDelay: The number of seconds to delay between connection
            attempts.
        @type attemptDelay: L{float}

        @see: L{twisted.internet.interfaces.IReactorTCP.connectTCP}
        N)r��_getNameResolverAndMaybeWarn�
_nameResolver�_hostAsBytesAndText�_badHostname�
_hostBytes�	_hostText�bytesrK�_hostStrr�rr�_DEFAULT_ATTEMPT_DELAY�
_attemptDelay)r[r�rr�rr�attemptDelays       r_r`zHostnameEndpoint.__init__s���> ��
�!�>�>�w�G���?C�?W�?W��@
�<��	�D�O�T�^�,1�C�<����T�^�^��
���
���
�'������6�6�L�)��rar0c��|jr
|j}n;t|j�rd|j�d�}nt|j�}djd|dt
|j�dg�S)zh
        Produce a string representation of the L{HostnameEndpoint}.

        @return: A L{str}
        �[�]r�z<HostnameEndpoint �:�>)rRrVrr0rS�joinrKr�r!s  r_�__repr__zHostnameEndpoint.__repr__Csi������=�=�D�
�4�=�=�
)��t�}�}�o�Q�'�D� ����0�D��w�w�,�d�C��T�Z�Z��#�N�O�Orac	��tj|�s`tj|jtdddd�dd��}t
j|td�	�t|j�S|jS)
a
        Retrieve a C{nameResolver} callable and warn the caller's
        caller that using a reactor which doesn't provide
        L{IReactorPluggableNameResolver} is deprecated.

        @param reactor: The reactor to check.

        @return: A L{IHostnameResolver} provider.
        �Twisted��rzPassing HostnameEndpoint a reactor that does not provide IReactorPluggableNameResolver (%(fqpn)s) was deprecated in %(version)sz5a reactor that provides IReactorPluggableNameResolver)r��replacement�)�
stacklevel)rrZr,�getDeprecationWarningStringrer�warnings�warn�DeprecationWarningr(�_fallbackNameResolution�nameResolver)r[r��
warningStrings   r_rOz-HostnameEndpoint._getNameResolverAndMaybeWarnWst��-�7�7��@�%�A�A��!�!��	�2�q�!�,�5�
O��M�
�M�M�-�);��J�*�4�+G�+G�H�H��#�#�#rac���t|t�r9t|�st|�rd||j	d�fS	d|t|�fStd|�}t|�st|�rd|jd�|fS	dt|�|fS#t$r|j	d�}YnwxYw#t$rYnwxYw|jdd�}d||j	d�fS)a�
        For various reasons (documented in the C{@ivar}'s in the class
        docstring) we need both a textual and a binary representation of the
        hostname given to the constructor.  For compatibility and convenience,
        we accept both textual and binary representations of the hostname, save
        the form that was passed, and convert into the other form.  This is
        mostly just because L{HostnameAddress} chose somewhat poorly to define
        its attribute as bytes; hopefully we can find a compatible way to clean
        this up in the future and just operate in terms of text internally.

        @param host: A hostname to convert.
        @type host: L{bytes} or C{str}

        @return: a 3-tuple of C{(invalid, bytes, text)} where C{invalid} is a
            boolean indicating the validity of the hostname, C{bytes} is a
            binary representation of C{host}, and C{text} is a textual
            representation of C{host}.
        F�ascii�charmap�NFC�backslashreplaceT)
�
isinstancerUrr�decoder7�UnicodeErrorr�encoder6)r�
asciibytess  r_rQz$HostnameEndpoint._hostAsBytesAndTextrs���(�d�E�"��4� �M�$�$7��d�D�K�K��$8�8�8�2� �$�	�$��7�7�
�U�D�)�D��4� �M�$�$7��d�k�k�'�2�D�8�8�� �*�T�"2�D�8�8��$�2��;�;�y�1�D�2��$������[�[��*<�=�
��Z��!2�!2�7�!;�;�;s#�
B�
B/�B,�+B,�/	B;�:B;c���������jr+tjtd�j����St��g�t
t�G��fd�d��}�jj|�j�j���j�fd���j�fd��}�jt��fd���j���fd��}�S)	a�
        Attempts a connection to each resolved address, and returns a
        connection which is established first.

        @param protocolFactory: The protocol factory whose protocol
            will be connected.
        @type protocolFactory:
            L{IProtocolFactory<twisted.internet.interfaces.IProtocolFactory>}

        @return: A L{Deferred} that fires with the connected protocol
            or fails a connection-related error.
        zinvalid hostname: c�H��eZdZed��Ze�fd��Ze��fd��Zy)�2HostnameEndpoint.connect.<locals>.EndpointReceiverc��yrCr�)�resolutionInProgresss r_rFzBHostnameEndpoint.connect.<locals>.EndpointReceiver.resolutionBegan�s��rac�(���j|�yrC��append)�address�	addressess �r_r4zBHostnameEndpoint.connect.<locals>.EndpointReceiver.addressResolved�s���� � ��)rac�(���j��yrC�rk�r�rs��r_rDzEHostnameEndpoint.connect.<locals>.EndpointReceiver.resolutionComplete�s����
�
�9�%raN)rfr~rr$rFr4rDr�s��r_�EndpointReceiverr{�s=���
�
��
��
*��
*��
&��
&rar�)r-c�p��tjtjd�j�d���S)NzCouldn't find the hostname '�')r
r�r�DNSLookupErrorrV)rEr[s �r_rz*HostnameEndpoint.connect.<locals>.<lambda>�s-���E�J�J��$�$�'C�D�M�M�?�RS�%T�U��rac3�j�K�|D]�}t|t�rCt�j|j|j
�j�j���t|t�s�gt�j|j|j
�j�j�����y�wrC)
rtrrFr�rr�rrrrE)r��eachAddressr[s  �r_�resolvedAddressesToEndpointsz>HostnameEndpoint.connect.<locals>.resolvedAddressesToEndpoints�s������ )�
���k�;�7�,��
�
�#�(�(�#�(�(��
�
��)�)����k�;�7�,��
�
�#�(�(�#�(�(��
�
��)�)���
�s
�A)B3�-AB3c���|jtjt�j�j
���yrC)r�rr�rrSr�)rr[s �r_r�z,HostnameEndpoint.connect.<locals>._canceller�s1���
�I�I��.�.�#�D�O�O�T�Z�Z�@��
rac�|��������|s"tjd�
j����t|��g�g�t	j
��������fd��d�_d�_t�����	�fd����
j�_
�j�
j��j���fd��}�S)aQ
            Given a sequence of endpoints obtained via name resolution, start
            connecting to a new one every C{self._attemptDelay} seconds until
            one of the connections succeeds, all of them fail, or the attempt
            is cancelled.

            @param endpoints: a list of all the endpoints we might try to
                connect to, as determined by name resolution.
            @type endpoints: L{list} of L{IStreamServerEndpoint}

            @return: a Deferred that fires with the result of the
                C{endpoint.connect} method that completes the fastest, or fails
                with the first connection error it encountered if none of them
                succeed.
            @rtype: L{Deferred} failing with L{error.ConnectingCancelledError}
                or firing with L{IProtocol}
            z no results for hostname lookup: r�c�z���s�js�jry�j�j��yrC)�	completed�
endpointsLeftr��pop)�	checkDone�failures�pending�winners����r_r�zLHostnameEndpoint.connect.<locals>.startConnectionAttempts.<locals>.checkDone	s+����i�1�1�Y�5L�5L�����x�|�|�~�.raFTc����t�d�}|�d�_��y|j�	���j���j��fd��}�j
�
fd��}�j��fd��}y)NFc�*���j��|SrC)�remove)r�eachAttemptr�s ��r_�noLongerPendingzkHostnameEndpoint.connect.<locals>.startConnectionAttempts.<locals>.iterateEndpoint.<locals>.noLongerPendings����N�N�;�/�!�Mrac�(���j|�yrCr�)rr�s �r_�	succeededzeHostnameEndpoint.connect.<locals>.startConnectionAttempts.<locals>.iterateEndpoint.<locals>.succeeded"s����O�O�F�+rac�6���j|���yrCr)rvr�r�s ��r_�failedzbHostnameEndpoint.connect.<locals>.startConnectionAttempts.<locals>.iterateEndpoint.<locals>.failed&s����O�O�F�+��Kra)�nextr�r�r�rHrrG)�endpointr�r�r�r�r�r��
iterEndpointsr�r�r�s    @������r_�iterateEndpointzRHostnameEndpoint.connect.<locals>.startConnectionAttempts.<locals>.iterateEndpoints�����
�t�4���#�.3�I�+��K��&�.�.��?�����{�+��$�$�"�%�"��(�(�,�)�,��'�'� �(� rac���d�_�ddD]}|j���jr�j�|S�NT)r��cancel�running�stop)r�	remainingr�r�r�s  ���r_�cancelRemainingPendingzYHostnameEndpoint.connect.<locals>.startConnectionAttempts.<locals>.cancelRemainingPending.sD���&*�	�#�!(���'�I��$�$�&�'�"�*�*�#�(�(�*��
ra)rr�rV�iterr
r'r�r�r(r��clock�startrXrH)�	endpointsr�r�r�r�r�r�r�r�r�r[s  @@@@@@���r_�startConnectionAttemptsz9HostnameEndpoint.connect.<locals>.startConnectionAttempts�s����&��*�*�6�t�}�}�o�F���!��O�M��G��H��^�^�j�9�F�
/�
#(�I��&*�I�#�
�
 �
 ��
 �2%)�M�M�O�!��!�!�$�"4�"4�5�
�^�^�
��
��Mra)rRr
r��
ValueErrorrVr'r	rrPrJrTr�rGr�list)r[r�r�r�r�r�r�rs``   @@@r_r�zHostnameEndpoint.connect�s��������:�:�j�+=�d�m�m�_�)M�N�O�O��J���	�	�%�	&�	&�	&�
'�	&�	
���*�*��d�n�n����	+�	
�	
���
�	
�
���	�
�	�(	
�
�
�d��
	�
���I	�
�I	�V�rac�\�|j|j||dtj�S)a�
        Resolve the hostname string into a tuple containing the host
        address.  This is method is only used when the reactor does
        not provide L{IReactorPluggableNameResolver}.

        @param host: A unicode hostname to resolve.

        @param port: The port to include in the resolution.

        @return: A L{Deferred} that fires with L{_getaddrinfo}'s
            return value.
        r)rrr�SOCK_STREAM)r[rr�s   r_rlz(HostnameEndpoint._fallbackNameResolution;s)���"�"�4�#4�#4�d�D�!�V�EW�EW�X�Xra)r
NN)rfr~rr�r$rr%rrr&rrWr`rKr`rOrQr�rlr�rar_rNrN�sq���6 �� 2� 2�3�L�!�'�"7�"7�8�N� ��OS�**�XP�#�P�($�6�*<��*<�XZ�x
YrarNc��eZdZdZdd�Zd�Zy)rIzE
    SSL secured TCP server endpoint with an IPv4 configuration.
    c�J�||_||_||_||_||_y)a�
        @param reactor: An L{IReactorSSL} provider.

        @param port: The port number used for listening
        @type port: int

        @param sslContextFactory: An instance of
            L{interfaces.IOpenSSLContextFactory}.

        @param backlog: Size of the listen queue
        @type backlog: int

        @param interface: The hostname to bind to, defaults to '' (all)
        @type interface: str
        N)r�r��_sslContextFactoryr�r�)r[r�r��sslContextFactoryr�r�s      r_r`zSSL4ServerEndpoint.__init__Qs(��  ��
���
�"3�����
�#��rac��tj|jj|j||j
|j|j��S)zf
        Implement L{IStreamServerEndpoint.listen} to listen for SSL on a
        TCP socket.
        )�contextFactoryr�r�)r
r�r��	listenSSLr�r�r�r�r�s  r_r�zSSL4ServerEndpoint.listengsC��
�}�}��M�M�#�#��J�J���2�2��M�M��o�o�

�	
raNr�r�r�rar_rIrIKs���$�,
rarIc� �eZdZdZ	dd�Zd�Zy)rJzD
    SSL secured TCP client endpoint with an IPv4 configuration
    Nc�X�||_||_||_||_||_||_y)ao
        @param reactor: An L{IReactorSSL} provider.

        @param host: A hostname, used when connecting
        @type host: str

        @param port: The port number, used when connecting
        @type port: int

        @param sslContextFactory: SSL Configuration information as an instance
            of L{interfaces.IOpenSSLContextFactory}.

        @param timeout: Number of seconds to wait before assuming the
            connection has failed.
        @type timeout: int

        @param bindAddress: A (host, port) tuple of local address to bind to,
            or None.
        @type bindAddress: tuple
        N)r�rr�r�rr)r[r�rr�r�rrs       r_r`zSSL4ClientEndpoint.__init__|s0��. ��
���
���
�"3�����
�'��rac��	t|�}|jj|j|j||j
|j|j��|jS#t$rtj�cYSwxYw)zb
        Implement L{IStreamClientEndpoint.connect} to connect with SSL over
        TCP.
        r)r�r��
connectSSLrr�r�rrr�r�r
r�r
s   r_r�zSSL4ClientEndpoint.connect�s{��
	 �!�/�2�B��M�M�$�$��
�
��
�
���'�'��
�
� �-�-�

%�
��#�#�#���	 ��:�:�<��	 �s�A)A,�,B�Brrr�rar_rJrJvs���
OS�(�< rarJc��eZdZdZdd�Zd�Zy)rGz%
    UnixSocket server endpoint.
    c�J�||_||_||_||_||_y)a�
        @param reactor: An L{IReactorUNIX} provider.
        @param address: The path to the Unix socket file, used when listening
        @param backlog: number of connections to allow in backlog.
        @param mode: mode to set on the unix socket.  This parameter is
            deprecated.  Permissions should be set on the directory which
            contains the UNIX socket.
        @param wantPID: If True, create a pidfile for the socket.
        N)r��_addressr��_mode�_wantPID)r[r�r�r��mode�wantPIDs      r_r`zUNIXServerEndpoint.__init__�s'�� ��
���
���
���
���
rac��tj|jj|j||j
|j|j��S)zW
        Implement L{IStreamServerEndpoint.listen} to listen on a UNIX socket.
        )r�r�r�)r
r�r��
listenUNIXr�r�r�r�r�s  r_r�zUNIXServerEndpoint.listen�sA���}�}��M�M�$�$��M�M���M�M�����M�M�

�	
raN)r�i�rr�r�rar_rGrG�s��� � 
rarGc��eZdZdZdd�Zd�Zy)rHz%
    UnixSocket client endpoint.
    c�<�||_||_||_||_y)a�
        @param reactor: An L{IReactorUNIX} provider.

        @param path: The path to the Unix socket file, used when connecting
        @type path: str

        @param timeout: Number of seconds to wait before assuming the
            connection has failed.
        @type timeout: int

        @param checkPID: If True, check for a pid file to verify that a server
            is listening.
        @type checkPID: bool
        N)r�r�r�	_checkPID)r[r�r�r�checkPIDs     r_r`zUNIXClientEndpoint.__init__�s �� ��
���
���
�!��rac���	t|�}|jj|j||j|j
��|jS#t$rtj�cYSwxYw)za
        Implement L{IStreamClientEndpoint.connect} to connect via a
        UNIX Socket
        )rr�)
r�r��connectUNIXr�rr�r�r�r
r�r
s   r_r�zUNIXClientEndpoint.connect�sf��
	 �!�/�2�B��M�M�%�%��
�
�B��
�
����
&�
��#�#�#���	 ��:�:�<��	 �s�AA�A6�5A6N)r
rrr�rar_rHrH�s���"�( rarHc�X�eZdZdZej
Zeej�Z
d�Zd�Zy)rKz�
    An endpoint for listening on a file descriptor initialized outside of
    Twisted.

    @ivar _used: A C{bool} indicating whether this endpoint has been used to
        listen with a factory yet.  C{True} if so.
    c�<�||_||_||_d|_y)a
        @param reactor: An L{IReactorSocket} provider.

        @param fileno: An integer file descriptor corresponding to a listening
            I{SOCK_STREAM} socket.

        @param addressFamily: The address family of the socket given by
            C{fileno}.
        FN)r��fileno�
addressFamily�_used)r[r�r�r�s    r_r`z$AdoptedStreamServerEndpoint.__init__s!��������*�����
rac��|jr'tjtj��Sd|_	|j|j�|jj|j|j|�}|j|j�tj|�S#t$rtj�cYSwxYw)z{
        Implement L{IStreamServerEndpoint.listen} to start listening on, and
        then close, C{self._fileno}.
        T)
r�r
r�r�AlreadyListened�_setNonBlockingr�r��adoptStreamPortr��_closer�r�)r[�factoryr�s   r_r�z"AdoptedStreamServerEndpoint.listens���
�:�:��:�:�e�3�3�5�6�6���
�	 �� � ����-��<�<�/�/����T�/�/���D�
�K�K����$��}�}�T�"�"���	 ��:�:�<��	 �s�A'B8�8C�CN)
rfr~rr��os�closer�r$r�setNonBlockingr�r`r�r�rar_rKrK�s,����X�X�F�"�5�#7�#7�8�O�
�#rarKc�8�t|�|f|t|�d�fS)a
    Internal parser function for L{_parseServer} to convert the string
    arguments for a TCP(IPv4) stream endpoint into the structured arguments.

    @param factory: the protocol factory being parsed, or L{None}.  (This was a
        leftover argument from when this code was in C{strports}, and is now
        mostly None and unused.)

    @type factory: L{IProtocolFactory} or L{None}

    @param port: the integer port number to bind
    @type port: C{str}

    @param interface: the interface IP to listen on
    @param backlog: the length of the listen queue
    @type backlog: C{str}

    @return: a 2-tuple of (args, kwargs), describing  the parameters to
        L{IReactorTCP.listenTCP} (or, modulo argument 2, the factory, arguments
        to L{TCP4ServerEndpoint}.
    �r�r�)rL)r�r�r�r�s    r_�	_parseTCPr�+s!��,
��I�w��y�S��\�!R�R�Rrac�`�||ft|d�t|�tt|��d�fS)a�
    Internal parser function for L{_parseServer} to convert the string
    arguments for a UNIX (AF_UNIX/SOCK_STREAM) stream endpoint into the
    structured arguments.

    @param factory: the protocol factory being parsed, or L{None}.  (This was a
        leftover argument from when this code was in C{strports}, and is now
        mostly None and unused.)

    @type factory: L{IProtocolFactory} or L{None}

    @param address: the pathname of the unix socket
    @type address: C{str}

    @param backlog: the length of the listen queue
    @type backlog: C{str}

    @param lockfile: A string '0' or '1', mapping to True and False
        respectively.  See the C{wantPID} argument to C{listenUNIX}

    @return: a 2-tuple of (args, kwargs), describing  the parameters to
        L{twisted.internet.interfaces.IReactorUNIX.listenUNIX} (or,
        modulo argument 2, the factory, arguments to L{UNIXServerEndpoint}.
    �)r�r�r�)rL�bool)r�r�r�r��lockfiles     r_�
_parseUNIXr�Ds3��4
�'���T�1��#�g�,�4��H�
�CV�W��rac	��ddlm}	|�|}i}
|�t|	j|�|
d<t	|�j�}t	|�j�}|	jj|dz|z�}
|��tjdtt	|�j��tj��}|D�cgc]'}|	jj|�j��)}}|std|�d	���d}|�$|	jj!t	|��}|	j"d|
j$j|
j||d
�|
��}t'|�||f|t'|�d�fScc}w)
aY
    Internal parser function for L{_parseServer} to convert the string
    arguments for an SSL (over TCP/IPv4) stream endpoint into the structured
    arguments.

    @param factory: the protocol factory being parsed, or L{None}.  (This was a
        leftover argument from when this code was in C{strports}, and is now
        mostly None and unused.)
    @type factory: L{IProtocolFactory} or L{None}

    @param port: the integer port number to bind
    @type port: C{str}

    @param interface: the interface IP to listen on
    @param backlog: the length of the listen queue
    @type backlog: C{str}

    @param privateKey: The file name of a PEM format private key file.
    @type privateKey: C{str}

    @param certKey: The file name of a PEM format certificate file.
    @type certKey: C{str}

    @param sslmethod: The string name of an SSL method, based on the name of a
        constant in C{OpenSSL.SSL}.
    @type sslmethod: C{str}

    @param extraCertChain: The path of a file containing one or more
        certificates in PEM format that establish the chain from a root CA to
        the CA that signed your C{certKey}.
    @type extraCertChain: L{str}

    @param dhParameters: The file name of a file containing parameters that are
        required for Diffie-Hellman key exchange.  If this is not specified,
        the forward secret C{DHE} ciphers aren't available for servers.
    @type dhParameters: L{str}

    @return: a 2-tuple of (args, kwargs), describing  the parameters to
        L{IReactorSSL.listenSSL} (or, modulo argument 2, the factory, arguments
        to L{SSL4ServerEndpoint}.
    r)�sslN�method�
z=(-----BEGIN CERTIFICATE-----\n.+?\n-----END CERTIFICATE-----))�flagszSpecified chain file 'z7' doesn't contain any valid certificates in PEM format.)�
privateKey�certificate�extraCertChain�dhParametersr�r�)�twisted.internetr��getattr�SSLr3�
getContentr<�loadPEM�re�findallr0�DOTALLr9�originalr��DiffieHellmanParameters�fromFiler:r�rL)r�r�r��certKey�	sslmethodr�r�r�r�r��kw�certPEM�keyPEM�privateCertificate�matches�chainCertPEM�chainCertificates�cfs                  r_�	_parseSSLrcs���h%�����	�B����s�w�w�	�2��8���w��*�*�,�G�
�j�
!�
,�
,�
.�F��/�/�7�7��%��&�8P�Q���!��*�*�L���.�1�<�<�>�?��)�)�
��PW�
�?K�C�O�O�#�#�L�1�:�:�
��
�!��1?�B��
�
!�����2�2�;�;��\�"�
��
 ��	�	�
�%�0�0�9�9�&�/�/�(�!�	
�

�
�B���Y���$�I�#�g�,�&W�X�X��-
s�,E?c� �eZdZdZdZd�Zd�Zy)�_StandardIOParserz�
    Stream server endpoint string parser for the Standard I/O type.

    @ivar prefix: See L{IStreamServerEndpointStringParser.prefix}.
    �stdioc��t|�S)z�
        Internal parser function for L{_parseServer} to convert the string
        arguments into structured arguments for the L{StandardIOEndpoint}

        @param reactor: Reactor for the endpoint
        )rLr�s  r_�_parseServerz_StandardIOParser._parseServer�s��"�'�*�*rac�$�|j|�SrC�r�r[r�r��kwargss    r_�parseStreamServerz#_StandardIOParser.parseStreamServer�s��� � ��)�)raN�rfr~rr��prefixrrr�rar_rr�s����F�+�*rarc�j�eZdZdZej
�ZdZ		ddede	de
e	de
e	def
d	�Zd
�Z
y)�_SystemdParsera
    Stream server endpoint string parser for the I{systemd} endpoint type.

    @ivar prefix: See L{IStreamServerEndpointStringParser.prefix}.

    @ivar _sddaemon: A L{ListenFDs} instance used to translate an index into an
        actual file descriptor.
    �systemdNr��domain�indexr=r0c��|du|duk(rtd��|�'|jj�t|�}n!|�J�|jj	�|}ttd|z�}t|||�S)aW
        Internal parser function for L{_parseServer} to convert the string
        arguments for a systemd server endpoint into structured arguments for
        L{AdoptedStreamServerEndpoint}.

        @param reactor: An L{IReactorSocket} provider.

        @param domain: The domain (or address family) of the socket inherited
            from systemd.  This is a string like C{"INET"} or C{"UNIX"}, ie
            the name of an address family from the L{socket} module, without
            the C{"AF_"} prefix.

        @param index: If given, the decimal representation of an integer
            giving the offset into the list of file descriptors inherited from
            systemd.  Since the order of descriptors received from systemd is
            hard to predict, this option should only be used if only one
            descriptor is being inherited.  Even in that case, C{name} is
            probably a better idea.  Either C{index} or C{name} must be given.

        @param name: If given, the name (as defined by C{FileDescriptorName}
            in the C{[Socket]} section of a systemd service definition) of an
            inherited file descriptor.  Either C{index} or C{name} must be
            given.

        @return: An L{AdoptedStreamServerEndpoint} which will adopt the
            inherited listening port when it is used to listen.
        Nz/Specify exactly one of descriptor index or name�AF_)r��	_sddaemon�inheritedDescriptorsrL�inheritedNamedDescriptorsr�rrK)r[r�rrr=r�r�s       r_rz_SystemdParser._parseServer�s���D
�T�M�t�t�|�,��N�O�O����^�^�8�8�:�3�u�:�F�F��#�#�#��^�^�=�=�?��E�F������7�
�*�7�F�M�J�Jrac�.�|j|g|��i|��SrCr	r
s    r_rz _SystemdParser.parseStreamServers!��!�t� � ��:�4�:�6�:�:ra)NN)rfr~rr�r4�fromEnvironmentrrrrKrrKrrr�rar_rr�so���*�	�)�)�+�I�
�F� $�"�,K��,K��,K���}�	,K�
�s�m�,K�
%�
,K�\;rarc�"�eZdZdZdZdd�Zd�Zy)�_TCP6ServerParserz�
    Stream server endpoint string parser for the TCP6ServerEndpoint type.

    @ivar prefix: See L{IStreamServerEndpointStringParser.prefix}.
    �tcp6c�J�t|�}t|�}t||||�S)a�
        Internal parser function for L{_parseServer} to convert the string
        arguments into structured arguments for the L{TCP6ServerEndpoint}

        @param reactor: An L{IReactorTCP} provider.

        @param port: The port number used for listening
        @type port: int

        @param backlog: Size of the listen queue
        @type backlog: int

        @param interface: The hostname to bind to
        @type interface: str
        )rLrDr�s     r_rz_TCP6ServerParser._parseServer)s'�� �4�y���g�,��!�'�4��)�D�Drac�.�|j|g|��i|��SrCr	r
s    r_rz#_TCP6ServerParser.parseStreamServer=s!��!�t� � ��:�4�:�6�:�:raNr�r
r�rar_rrs���	��E�(;rar)�tcp�unixr�r�c#�ZK�td|�}td|�}td|�}td|�}|}||z}|||z||i}tt|��}|D]D}	|	t|�vrt|f��t|	f��|}||	}�,|	|k(r|t|�z
}�@||	z
}�Ft|f��y�w)a�
    Tokenize a strports string and yield each token.

    @param description: a string as described by L{serverFromString} or
        L{clientFromString}.
    @type description: L{str} or L{bytes}

    @return: an iterable of 2-tuples of (C{_OP} or C{_STRING}, string).  Tuples
        starting with C{_OP} will contain a second element of either ':' (i.e.
        'next parameter') or '=' (i.e. 'assign parameter value').  For example,
        the string 'hello:greeting=world' would result in a generator yielding
        these values::

            _STRING, 'hello'
            _OP, ':'
            _STRING, 'greet=ing'
            _OP, '='
            _STRING, 'world'
    r�r]�=�\N)r.r�r/�_STRING�_OPr�)
�description�empty�colon�equals�	backslash�current�ops�nextOps�iterdesc�ns
          r_�	_tokenizer1Ls�����(
�B��,�E��C��-�E�
�S�+�
.�F����4�I��G�
�&�.�C��e�f�n�f�e�4�G��I�k�*�+�H�
�	���	�#����7�"�"��q�&�L��G��!�*�C�
�)�^��t�H�~�%�G��q�L�G�	��7�
��s�B)B+c����gic��td|�}��fd�}d}t|�D]$\}}|tur||fz
}�||k(s�||�d}�&||���fS)a
    Convert a description string into a list of positional and keyword
    parameters, using logic vaguely like what Python does.

    @param description: a string as described by L{serverFromString} or
        L{clientFromString}.

    @return: a 2-tuple of C{(args, kwargs)}, where 'args' is a list of all
        ':'-separated C{str}s not containing an '=' and 'kwargs' is a map of
        all C{str}s which do contain an '='.  For example, the result of
        C{_parse('a:b:d=1:c')} would be C{(['a', 'b', 'c'], {'d': '1'})}.
    r]c�t��t|�dk(r�j|d�y|d�t|d�<y)Nr5r)�lenr�r0)�sofarr�r�s ��r_�addz_parse.<locals>.add�s5����u�:��?��K�K��a��!�).�q��B�|�E�!�H�%�&rar�)r.r1r%)r'r)r6r5�typer�r�r�s      @@r_�_parser8vsx����2�H�D�"��C��-�E�2�
�E� ��-����e��7�?��e�X��E�
�e�^���J��E����J���8�Ora)r3r��UNIXc���t|�\}}|d}tj|�}|�!tt	t
�|�}||dd|fS|j
�f||g|dd��i|��zS)a�
    Parse a strports description into a 2-tuple of arguments and keyword
    values.

    @param description: A description in the format explained by
        L{serverFromString}.
    @type description: C{str}

    @param factory: A 'factory' argument; this is left-over from
        twisted.application.strports, it's not really used.
    @type factory: L{IProtocolFactory} or L{None}

    @return: a 3-tuple of (plugin or name, arguments, keyword arguments)
    rNr5)r8�_serverParsers�get�_matchPluginToPrefixr+r�upper)r'r�r�r��endpointType�parser�plugins       r_rr�s����k�"�H�D�"���7�L�
�
�
��
-�F�
�~�&��8�9�<�
����Q�R��"�%�%���� �"�V�G�%E�d�1�2�h�%E�"�%E�E�Erac��|j�}|D]-}t|jj�|�|k(s�+|cStd|�d���)z!
    Match plugin to prefix.
    zUnknown endpoint type: 'r�)�lowerr.rr�)�pluginsr?rAs   r_r=r=�sY�� �%�%�'�L�����6�=�=�.�.�0�,�?�<�O��M���/��~�Q�?�
@�@rac��t|d�\}}}t|�tur|}|j|g|��i|��S|}|dd|ddz}t	||g|��i|��S)a_	
    Construct a stream server endpoint from an endpoint description string.

    The format for server endpoint descriptions is a simple byte string.  It is
    a prefix naming the type of endpoint, then a colon, then the arguments for
    that endpoint.

    For example, you can call it like this to create an endpoint that will
    listen on TCP port 80::

        serverFromString(reactor, "tcp:80")

    Additional arguments may be specified as keywords, separated with colons.
    For example, you can specify the interface for a TCP server endpoint to
    bind to like this::

        serverFromString(reactor, "tcp:80:interface=127.0.0.1")

    SSL server endpoints may be specified with the 'ssl' prefix, and the
    private key and certificate files may be specified by the C{privateKey} and
    C{certKey} arguments::

        serverFromString(
            reactor, "ssl:443:privateKey=key.pem:certKey=crt.pem")

    If a private key file name (C{privateKey}) isn't provided, a "server.pem"
    file is assumed to exist which contains the private key. If the certificate
    file name (C{certKey}) isn't provided, the private key file is assumed to
    contain the certificate as well.

    You may escape colons in arguments with a backslash, which you will need to
    use if you want to specify a full pathname argument on Windows::

        serverFromString(reactor,
            "ssl:443:privateKey=C\:/key.pem:certKey=C\:/cert.pem")

    finally, the 'unix' prefix may be used to specify a filesystem UNIX socket,
    optionally with a 'mode' argument to specify the mode of the socket file
    created by C{listen}::

        serverFromString(reactor, "unix:/var/run/finger")
        serverFromString(reactor, "unix:/var/run/finger:mode=660")

    This function is also extensible; new endpoint types may be registered as
    L{IStreamServerEndpointStringParser} plugins.  See that interface for more
    information.

    @param reactor: The server endpoint will be constructed with this reactor.

    @param description: The strports description to parse.
    @type description: L{str}

    @return: A new endpoint which can be used to listen with the parameters
        given by C{description}.

    @rtype: L{IStreamServerEndpoint<twisted.internet.interfaces.IStreamServerEndpoint>}

    @raise ValueError: when the 'description' string cannot be parsed.

    @since: 10.2
    Nr5r�)rr7rKr�_endpointServerFactories)r�r'�nameOrPluginr�r�rAr=s       r_rBrB�s|��|*�+�t�<��L�$���L���$���'�v�'�'��=�$�=�"�=�=������8�d�1�2�h��D�#�D�)�'�?�D�?�B�?�?rac�L�d\}}||fD]}|j|||z�}�|S)a�
    Quote an argument to L{serverFromString} and L{clientFromString}.  Since
    arguments are separated with colons and colons are escaped with
    backslashes, some care is necessary if, for example, you have a pathname,
    you may be tempted to interpolate into a string like this::

        serverFromString(reactor, "ssl:443:privateKey=%s" % (myPathName,))

    This may appear to work, but will have portability issues (Windows
    pathnames, for example).  Usually you should just construct the appropriate
    endpoint type rather than interpolating strings, which in this case would
    be L{SSL4ServerEndpoint}.  There are some use-cases where you may need to
    generate such a string, though; for example, a tool to manipulate a
    configuration file which has strports descriptions in it.  To be correct in
    those cases, do this instead::

        serverFromString(reactor, "ssl:443:privateKey=%s" %
                         (quoteStringArgument(myPathName),))

    @param argument: The part of the endpoint description string you want to
        pass through.

    @type argument: C{str}

    @return: The quoted argument.

    @rtype: C{str}
    z\:)�replace)�argumentr+r)�cs    r_�quoteStringArgumentrLs=��:��I�u�
��
�6���#�#�A�y�1�}�5��6��Orac�h�t|�dk(rt|d�|d<|d|d<n,t|�dk(rd|vrt|d�|d<n|d|d<	t|d�|d<	t|d�|d<	|ddf|d<|S#t$rY�*wxYw#t$rY�'wxYw#t$rY|SwxYw)a$
    Perform any argument value coercion necessary for TCP client parameters.

    Valid positional arguments to this function are host and port.

    Valid keyword arguments to this function are all L{IReactorTCP.connectTCP}
    arguments.

    @return: The coerced values as a C{dict}.
    r�r5r�rrrr)r4rL�KeyError�r�rs  r_�_parseClientTCPrP8s����4�y�A�~��T�!�W���v���a���v��	�T��a���V�� ��a��\�F�6�N�!�!�W�F�6�N�
��V�F�^�,��v��
���y� 1�2��y��
�!'�
�!6�� :��}���M���
��
��
�
��
��
�
���M�
�s6�B�(B�:
B$�	B�B�	B!� B!�$	B1�0B1c��i}|j�D]~}|j�j�jd�dj	�dk(s�E	|j�}	tj|�}|||j�<��t|j��S#t$rY��wxYw#t$rY��wxYw)z�
    Load certificate-authority certificate objects in a given directory.

    @param directoryPath: a L{unicode} or L{bytes} pointing at a directory to
        load .pem files from, or L{None}.

    @return: an L{IOpenSSLTrustRoot} provider.
    �.����pem)
�children�
asTextMode�basename�splitrCr��OSErrorr9r��digest�SSLErrorr>�values)�
directoryPath�caCerts�childro�theCerts     r_�_loadCAsFromDirra_s����G��'�'�)�0�����!�*�*�,�2�2�3�7��;�A�A�C�u�L��	��#�#�%�D�	0�!�)�)�$�/�G�
)0�G�G�N�N�$�%�0�%�W�^�^�%5�6�6���	��	��
�	��	�s$�B-�*B<�-	B9�8B9�<	C�Cc�0�|�ytt|��S)z�
    Parse a string referring to a directory full of certificate authorities
    into a trust root.

    @param pathName: path name
    @type pathName: L{unicode} or L{bytes} or L{None}

    @return: L{None} or L{IOpenSSLTrustRoot}
    N)rar3)�pathNames r_�_parseTrustRootPathrd{s������8�H�-�.�.rac��|�yt|�j�}|�tj|�Stjtj|�t
jt|�j�d��S)ax
    Parse a certificate path and key path, either or both of which might be
    L{None}, into a certificate object.

    @param certificatePath: the certificate path
    @type certificatePath: L{bytes} or L{unicode} or L{None}

    @param keyPath: the private key path
    @type keyPath: L{bytes} or L{unicode} or L{None}

    @return: a L{PrivateCertificate} or L{None}
    Nr5)r3r�r<r��fromCertificateAndKeyPairr9r;�load)�certificatePath�keyPath�	certBytess   r_�_privateCertFromPathsrk�ss�������)�4�4�6�I���!�)�)�)�4�4�!�;�;����	�*��L�L��'�*�5�5�7��;�
�	
rac�d�|jdd�}t|jdd�|jdd��}t|jdd��}|�tt	|�||��}n7|�#|j
j}|j}nd}d}t|||��}||d<|S)	a�
    Parse common arguments for SSL endpoints, creating an L{CertificateOptions}
    instance.

    @param kwargs: A dict of keyword arguments to be parsed, potentially
        containing keys C{certKey}, C{privateKey}, C{caCertsDir}, and
        C{hostname}.  See L{_parseClientSSL}.
    @type kwargs: L{dict}

    @return: The remaining arguments, including a new key C{sslContextFactory}.
    �hostnameNr�r��
caCertsDir��	trustRoot�clientCertificate)rpr�r�r�)r�rkrdr=r7r�r�r:)rrmrqrp�
configuration�privateKeyOpenSSL�certificateOpenSSLs       r_�_parseClientSSLOptionsru�s����z�z�*�d�+�H�-��
�
�9�d�#�V�Z�Z��d�%C���$�F�J�J�|�T�$B�C�I���+��h���/�
�
��(� 1� <� <� E� E��!2�!;�!;�� $��!%��*��(�*�
�
�
#0�F����Mrac�.�t|i|��}t|�S)a
    Perform any argument value coercion necessary for SSL client parameters.

    Valid keyword arguments to this function are all L{IReactorSSL.connectSSL}
    arguments except for C{contextFactory}.  Instead, C{certKey} (the path name
    of the certificate file) C{privateKey} (the path name of the private key
    associated with the certificate) are accepted and used to construct a
    context factory.

    Valid positional arguments to this function are host and port.

    @keyword caCertsDir: The one parameter which is not part of
        L{IReactorSSL.connectSSL}'s signature, this is a path name used to
        construct a list of certificate authority certificates.  The directory
        will be scanned for files ending in C{.pem}, all of which will be
        considered valid certificate authorities for this connection.
    @type caCertsDir: L{str}

    @keyword hostname: The hostname to use for validating the server's
        certificate.
    @type hostname: L{unicode}

    @return: The coerced values as a L{dict}.
    )rPrurOs  r_�_parseClientSSLrw�s��2�d�
-�f�
-�F�!�&�)�)rac���t|�dk(r|d|d<	tt|jd���|d<	t|d�|d<|S#t$rY�wxYw#t$rY|SwxYw)a�
    Perform any argument value coercion necessary for UNIX client parameters.

    Valid keyword arguments to this function are all L{IReactorUNIX.connectUNIX}
    keyword arguments except for C{checkPID}.  Instead, C{lockfile} is accepted
    and has the same meaning.  Also C{path} is used instead of C{address}.

    Valid positional arguments to this function are C{path}.

    @return: The coerced values as a C{dict}.
    r5rr�r�r�r)r4r�rLr�rNrOs  r_�_parseClientUNIXry�s����4�y�A�~��a���v��
�!�#�f�j�j��&<�"=�>��z��
���y� 1�2��y���M��
�
��
���
���M�
�s"�&A�A!�	A�A�!	A.�-A.c��t|�\}}|jd�}|j�}|tvr/t	tt�|�}|j|g|��i|��St||i|��}t||fi|��S)a�

    Construct a client endpoint from a description string.

    Client description strings are much like server description strings,
    although they take all of their arguments as keywords, aside from host and
    port.

    You can create a TCP client endpoint with the 'host' and 'port' arguments,
    like so::

        clientFromString(reactor, "tcp:host=www.example.com:port=80")

    or, without specifying host and port keywords::

        clientFromString(reactor, "tcp:www.example.com:80")

    Or you can specify only one or the other, as in the following 2 examples::

        clientFromString(reactor, "tcp:host=www.example.com:80")
        clientFromString(reactor, "tcp:www.example.com:port=80")

    or an SSL client endpoint with those arguments, plus the arguments used by
    the server SSL, for a client certificate::

        clientFromString(reactor, "ssl:web.example.com:443:"
                                  "privateKey=foo.pem:certKey=foo.pem")

    to specify your certificate trust roots, you can identify a directory with
    PEM files in it with the C{caCertsDir} argument::

        clientFromString(reactor, "ssl:host=web.example.com:port=443:"
                                  "caCertsDir=/etc/ssl/certs")

    Both TCP and SSL client endpoint description strings can include a
    'bindAddress' keyword argument, whose value should be a local IPv4
    address. This fixes the client socket to that IP address::

        clientFromString(reactor, "tcp:www.example.com:80:"
                                  "bindAddress=192.0.2.100")

    NB: Fixed client ports are not currently supported in TCP or SSL
    client endpoints. The client socket will always use an ephemeral
    port assigned by the operating system

    You can create a UNIX client endpoint with the 'path' argument and optional
    'lockfile' and 'timeout' arguments::

        clientFromString(
            reactor, b"unix:path=/var/foo/bar:lockfile=1:timeout=9")

    or, with the path as a positional argument with or without optional
    arguments as in the following 2 examples::

        clientFromString(reactor, "unix:/var/foo/bar")
        clientFromString(reactor, "unix:/var/foo/bar:lockfile=1:timeout=9")

    This function is also extensible; new endpoint types may be registered as
    L{IStreamClientEndpointStringParserWithReactor} plugins.  See that
    interface for more information.

    @param reactor: The client endpoint will be constructed with this reactor.

    @param description: The strports description to parse.
    @type description: L{str}

    @return: A new endpoint which can be used to connect with the parameters
        given by C{description}.
    @rtype: L{IStreamClientEndpoint<twisted.internet.interfaces.IStreamClientEndpoint>}

    @since: 10.2
    r)	r8r�r>�_clientParsersr=r+r�parseStreamClient�_endpointClientFactories)r�r'r�r�anamer=rAs       r_rArA	s���P�+�&�L�D�&��H�H�Q�K�E��;�;�=�D��>�!�%��C�D�d�
��(�v�'�'��A�$�A�&�A�A�
�D�
!�4�
2�6�
2�F�#�D�)�'�<�V�<�<rac�R��G�fd�dt�}|j|��S)a�
    Connect a protocol instance to an endpoint.

    This allows using a client endpoint without having to create a factory.

    @param endpoint: A client endpoint to connect to.

    @param protocol: A protocol instance.

    @return: The result of calling C{connect} on the endpoint, i.e. a
        L{Deferred} that will fire with the protocol when connected, or an
        appropriate error.

    @since: 13.1
    c���eZdZ�fd�Zy)�'connectProtocol.<locals>.OneShotFactoryc����SrCr�)r[r�r�s  �r_r�z5connectProtocol.<locals>.OneShotFactory.buildProtocolos����OraN)rfr~rr��r�s�r_�OneShotFactoryr�ns���	rar�)r!r�)r�r�r�s ` r_rPrP]s%���"������N�,�-�-rac��eZdZdZd�Zd�Zy)�_WrapperEndpointz2
    An endpoint that wraps another endpoint.
    c� �||_||_y)z2
        Construct a L{_WrapperEndpoint}.
        N��_wrappedEndpoint�_wrapperFactory�r[�wrappedEndpoint�wrapperFactorys   r_r`z_WrapperEndpoint.__init__{���!0���-��rac�v�|jj|j|��jd��S)�K
        Connect the given protocol factory and unwrap its result.
        c��|jSrC)r]r�s r_rz*_WrapperEndpoint.connect.<locals>.<lambda>�s��x�'?�'?�ra)r�r�r�rr�s  r_r�z_WrapperEndpoint.connect�s7���$�$�,�,�� � ��1�
�
�+�?�
@�	AraNrr�rar_r�r�us���.�Arar�c��eZdZdZd�Zd�Zy)�_WrapperServerEndpointz?
    A server endpoint that wraps another server endpoint.
    c� �||_||_y)z8
        Construct a L{_WrapperServerEndpoint}.
        Nr�r�s   r_r`z_WrapperServerEndpoint.__init__�r�rac�V�|jj|j|��S)r�)r�r�r�r�s  r_r�z_WrapperServerEndpoint.listen�s&���$�$�+�+�D�,@�,@��,Q�R�RraNr�r�rar_r�r��s���.�Srar�c�D��t�td��t|�fd��S)a�
    Wrap an endpoint which upgrades to TLS as soon as the connection is
    established.

    @since: 16.0

    @param connectionCreator: The TLS options to use when connecting; see
        L{twisted.internet.ssl.optionsForClientTLS} for how to construct this.
    @type connectionCreator:
        L{twisted.internet.interfaces.IOpenSSLClientConnectionCreator}

    @param wrappedEndpoint: The endpoint to wrap.
    @type wrappedEndpoint: An L{IStreamClientEndpoint} provider.

    @return: an endpoint that provides transport level encryption layered on
        top of C{wrappedEndpoint}
    @rtype: L{twisted.internet.interfaces.IStreamClientEndpoint}
    z6OpenSSL not available. Try `pip install twisted[tls]`.c���t�d|�Sr�r?)r��connectionCreators �r_rzwrapClientTLS.<locals>.<lambda>�s��� 3��t�_�!
�ra)r@�NotImplementedErrorr�)r�r�s` r_rQrQ�s2���&�"�!�D�
�	
���	
��rac	
��|	r#tdt|	j����t|t�r|n|jd�}t|t�s|�|n|jd�}t
|�}t
|�}tt|t|�t||���|�t||��St|t|�|||��S)a�
    Internal method to construct an endpoint from string parameters.

    @param reactor: The reactor passed to L{clientFromString}.

    @param host: The hostname to connect to.
    @type host: L{bytes} or L{unicode}

    @param port: The port to connect to.
    @type port: L{bytes} or L{unicode}

    @param timeout: For each individual connection attempt, the number of
        seconds to wait before assuming the connection has failed.
    @type timeout: L{bytes} or L{unicode}

    @param bindAddress: The address to which to bind outgoing connections.
    @type bindAddress: L{bytes} or L{unicode}

    @param certificate: a string representing a filesystem path to a
        PEM-encoded certificate.
    @type certificate: L{bytes} or L{unicode}

    @param privateKey: a string representing a filesystem path to a PEM-encoded
        certificate.
    @type privateKey: L{bytes} or L{unicode}

    @param endpoint: an optional string endpoint description of an endpoint to
        wrap; if this is passed then C{host} is used only for certificate
        verification.
    @type endpoint: L{bytes} or L{unicode}

    @return: a client TLS endpoint
    @rtype: L{IStreamClientEndpoint}
    z&unrecognized keyword arguments presentzutf-8ro)�	TypeErrorr��keysrtrKrurLrQr=rdrkrArNr6)
r�rr�rrr�r��
trustRootsr�rs
          r_�_parseClientTLSr��s���\��@�$�v�{�{�}�BU�V�V��d�C�(�4�d�k�k�'�.B�D��k�3�'�;�+>�	�
�
�
��
(��
�t�9�D��'�l�G����)�*�5�3�K��L�	
���	��(�+�
	�	��g�z�$�'7��w��
T�	�	rac�$�eZdZdZdZed��Zy)�_TLSClientEndpointParserz�
    Stream client endpoint string parser for L{wrapClientTLS} with
    L{HostnameEndpoint}.

    @ivar prefix: See
        L{IStreamClientEndpointStringParserWithReactor.prefix}.
    �tlsc� �t|g|��i|��S)a�
        Redirects to another function L{_parseClientTLS}; tricks zope.interface
        into believing the interface is correctly implemented, since the
        signature is (C{reactor}, C{*args}, C{**kwargs}).  See
        L{_parseClientTLS} for the specific signature description for this
        endpoint parser.

        @param reactor: The reactor passed to L{clientFromString}.

        @param args: The positional arguments in the endpoint description.
        @type args: L{tuple}

        @param kwargs: The named arguments in the endpoint description.
        @type kwargs: L{dict}

        @return: a client TLS endpoint
        @rtype: L{IStreamClientEndpoint}
        )r�)r�r�rs   r_r|z*_TLSClientEndpointParser.parseStreamClient	s��(�w�8��8��8�8raN)rfr~rr�rr$r|r�rar_r�r�	s ����F��9��9rar�)r�r�)�666r�T)z
server.pemNNr�r�NN)s30NNNNN)�r�r�r�rri�typingrrr�unicodedatar�zope.interfacerrr	�
constantlyr
r�incrementalrr�r
rrrr�twisted.internet.abstractrr�twisted.internet.addressrrrr�twisted.internet.interfacesrrrrrrrr�twisted.internet.protocolr r!r"r#�twisted.internet.stdior$r%�ImportError�twisted.internet._resolverr&�twisted.internet.deferr'�twisted.internet.taskr(�twisted.loggerr)�twisted.pluginr*r+�twisted.pythonr,r-�twisted.python.compatr.r/r0�twisted.python.componentsr1�twisted.python.failurer2�twisted.python.filepathr3�twisted.python.systemdr4�_idnar6r7�OpenSSL.SSLr8r[�twisted.internet.sslr9r:r;r<r=r>�twisted.protocols.tlsr@�_TLSMemoryBIOFactory�__all__rSr��IStreamServerEndpointrL�IProcessTransport�	IConsumer�
IPushProducerr�r�r�rO�IStreamClientEndpointrMr�rCrDrErFr(rNrIrJrGrHrKr�r�rrrrr;�ranger&r%r1r8rFr}rr=rBrLrPrardrkrurwryr{rArPr�r�rQr�r�r�rar_�<module>r�s��
�
�	�
��+�+�!�B�B�+��E�E�@���	�	�	�X�W��>�6�+�-�!�.�)�J�J�7�*�,�,�(�/�-���R�/����*N3��N3�b\/�}�\/�~
�Z�
-�
-�.�
�
�/�
�8�� � �*�"6�"6�
�8P�8P��
��1���
� =8�_�=8�@�E��
�Z�
-�
-�.�@(�@(�/�@(�F
�Z�
-�
-�.�"
�"
�/�"
�JM�+�M�*M�+�M�*
�Z�
-�
-�.�, �, �/�, �^
�Z�
-�
-�.�F �F �/�F �R
�
��D�D� �D�N
�Z�
-�
-�.�QY�QY�/�QY�h

�Z�
-�
-�.�'
�'
�/�'
�T
�Z�
-�
-�.�4 �4 �/�4 �n
�Z�
-�
-�.� 
� 
�/� 
�F
�Z�
-�
-�.�% �% �/�% �P
�Z�
-�
-�.�,#�,#�/�,#�^S�2�D�������ZY�z
�W�7�8�*�*�9�*�0
�W�7�8�@;�@;�9�@;�F
�W�7�8�";�";�9�";�L������Q�x���W�'�T�F����������F�8A�F@�R �F$�N7�8/�
�2%�P*�:�6�����Q=�h.�0
�Z�
-�
-�.�A�A�/�A�*
�Z�
-�
-�.�S�S�/�S�&�F
�����
�A�H
�W�B�C�9�9�D�9��cF���J��K���<�����s$�>O+�O;�+	O8�7O8�;P�P

Zerion Mini Shell 1.0