
-Rc           @`  s  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 m	 Z	 d d l
 Z
 d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z m Z m Z 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  d d l! m" Z" d d l# m$ Z$ d d l% m& Z& m' Z' d d l( m) Z) d d l m* Z* m+ Z+ d d l, m- Z- e sd d l. m/ Z/ m0 Z0 d d l m1 Z1 d d l2 m3 Z3 d d l4 m5 Z5 m6 Z6 n2 d d l m7 Z7 d e7 f d     YZ/ e8 Z5 e8 Z6 d d d d d d d  d! d" d# d$ d% d& d' d( d) g Z9 d d d d d" d# d) d' g Z: d* e f d+     YZ; d, e f d-     YZ< e e j=  d% e8 f d.     Y Z> e e j?  d/ e) e j@ d0  f d1     Y ZA d2 e f d3     YZB d( e6 f d4     YZC e e jD  d& e8 f d5     Y ZE e e j=  d6 e8 f d7     Y ZF d eF f d8     YZG d eF f d9     YZH e e jD  d e8 f d:     Y ZI e e jD  d e8 f d;     Y ZJ e e jD  d' e8 f d<     Y ZK e e j=  d" e8 f d=     Y ZL e e jD  d# e8 f d>     Y ZM e e j=  d  e8 f d?     Y ZN e e jD  d! e8 f d@     Y ZO e e j=  d$ e8 f dA     Y ZP dB dC dD  ZQ dE dC eR dF  ZS dG d d dB dC d dH  ZU e e/ e  dI e8 f dJ     Y ZV e e/ e  dK e8 f dL     Y ZW e e/ e  dM e8 f dN     Y ZX i eQ dO 6eS dP 6eU dQ 6ZY eZ dR  \ Z[ Z\ dS   Z] dT   Z^ i eG dU 6eL dV 6eN dW 6Z_ i eI dU 6eM dV 6eO dW 6Z` e8   Za d dX  Zb dY   Zc dZ   Zd d[   Ze d\   Zf d]   Zg d^   Zh d_   Zi i ef dU 6eh dV 6ei dW 6Zj d`   Zk da   Zl e rx5 e9 D], Zm em e: k rNe9 jn em  eo   em =qNqNW[m [: n  d S(b   s7  
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
i    (   t   divisiont   absolute_importN(   t   implementert   directlyProvides(   t   _PY3(   t
   interfacest   defert   errort   fdesct   threads(   t   ClientFactoryt   Protocolt   ProcessProtocolt   Factory(   t!   IStreamServerEndpointStringParser(   t!   IStreamClientEndpointStringParser(   t   FilePath(   t	   ListenFDs(   t   isIPv6Address(   t   Failure(   t   log(   t   _ProcessAddresst   HostnameAddress(   t   proxyForInterface(   t   AF_INET6t   AF_INET(   t   LoopingCall(   t   IPlugint
   getPlugins(   t   stdio(   t   PipeAddress(   t   NamedConstantt   Names(   t	   InterfaceR   c           B`  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR   /   s   t   clientFromStringt   serverFromStringt   TCP4ServerEndpointt   TCP6ServerEndpointt   TCP4ClientEndpointt   TCP6ClientEndpointt   UNIXServerEndpointt   UNIXClientEndpointt   SSL4ServerEndpointt   SSL4ClientEndpointt   AdoptedStreamServerEndpointt   StandardIOEndpointt   ProcessEndpointt   HostnameEndpointt   StandardErrorBehaviort   connectProtocolt   _WrappingProtocolc           B`  sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s_   
    Wrap another protocol in order to notify my user when a connection has
    been made.
    c         C`  sU   | |  _  | |  _ x< t j t j g D]( } | j |  j  r% t |  |  q% q% Wd S(   s   
        @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(   t   _connectedDeferredt   _wrappedProtocolR   t   IHalfCloseableProtocolt   IFileDescriptorReceivert
   providedByR   (   t   selft   connectedDeferredt   wrappedProtocolt   iface(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   __init__I   s    			c         C`  s/   t  j j |  j  r" |  j j   S|  j j j S(   sO   
        Transparently pass through the wrapped protocol's log prefix.
        (   R   t   ILoggingContextR9   R6   t	   logPrefixt	   __class__R"   (   R:   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR@   Z   s    c         C`  s*   |  j  j |  j  |  j j |  j   d S(   s   
        Connect the C{self._wrappedProtocol} to our C{self.transport} and
        callback C{self._connectedDeferred} with the C{self._wrappedProtocol}
        N(   R6   t   makeConnectiont	   transportR5   t   callback(   R:   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   connectionMadec   s    c         C`  s   |  j  j |  S(   sM   
        Proxy C{dataReceived} calls to our C{self._wrappedProtocol}
        (   R6   t   dataReceived(   R:   t   data(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRF   l   s    c         C`  s   |  j  j |  S(   sW   
        Proxy C{fileDescriptorReceived} calls to our C{self._wrappedProtocol}
        (   R6   t   fileDescriptorReceived(   R:   t
   descriptor(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRH   s   s    c         C`  s   |  j  j |  S(   sO   
        Proxy C{connectionLost} calls to our C{self._wrappedProtocol}
        (   R6   t   connectionLost(   R:   t   reason(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRJ   z   s    c         C`  s   |  j  j   d S(   sl   
        Proxy L{IHalfCloseableProtocol.readConnectionLost} to our
        C{self._wrappedProtocol}
        N(   R6   t   readConnectionLost(   R:   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRL      s    c         C`  s   |  j  j   d S(   sm   
        Proxy L{IHalfCloseableProtocol.writeConnectionLost} to our
        C{self._wrappedProtocol}
        N(   R6   t   writeConnectionLost(   R:   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRM      s    (   R"   R#   t   __doc__R>   R@   RE   RF   RH   RJ   RL   RM   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR4   C   s   									t   _WrappingFactoryc           B`  sS   e  Z d  Z e Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   s  
    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         C`  s%   | |  _  t j d |  j  |  _ d S(   s   
        @param wrappedFactory: A provider of I{IProtocolFactory} whose
            buildProtocol method will be called and whose resulting protocol
            will be wrapped.
        t	   cancellerN(   t   _wrappedFactoryR   t   Deferredt
   _cancellert   _onConnection(   R:   t   wrappedFactory(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>      s    	c         C`  s   | |  _  d S(   s~   
        A connection attempt was started.  Remember the connector which started
        said attempt, for use later.
        N(   t
   _connector(   R:   t	   connector(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   startedConnecting   s    c         C`  s0   | j  t j |  j j     |  j j   d S(   s;  
        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: C{None}
        N(   t   errbackR   t   ConnectingCancelledErrorRV   t   getDestinationt   stopConnecting(   R:   t   deferred(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRS      s    c         C`  s   |  j  j   d S(   sY   
        Start notifications are passed straight through to the wrapped factory.
        N(   RQ   t   doStart(   R:   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR^      s    c         C`  s   |  j  j   d S(   sX   
        Stop notifications are passed straight through to the wrapped factory.
        N(   RQ   t   doStop(   R:   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR_      s    c         C`  sD   y |  j  j |  } Wn |  j j   n X|  j |  j |  Sd S(   s   
        Proxy C{buildProtocol} to our C{self._wrappedFactory} or errback
        the C{self._onConnection} L{Deferred}.

        @return: An instance of L{_WrappingProtocol} or C{None}
        N(   RQ   t   buildProtocolRT   RY   t   protocol(   R:   t   addrt   proto(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR`      s
    c         C`  s#   |  j  j s |  j  j |  n  d S(   si   
        Errback the C{self._onConnection} L{Deferred} when the
        client connection fails.
        N(   RT   t   calledRY   (   R:   RW   RK   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   clientConnectionFailed   s    (   R"   R#   RN   R4   Ra   R>   RX   RS   R^   R_   R`   Re   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRO      s   	
					c           B`  s    e  Z d  Z d   Z d   Z RS(   s*   
    A Standard Input/Output endpoint
    c         C`  s   | |  _  d S(   s>   
        @param reactor: The reactor for the endpoint
        N(   t   _reactor(   R:   t   reactor(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>      s    c         C`  s   t  j t j | j t     S(   sU   
        Implement L{IStreamServerEndpoint.listen} to listen on stdin/stdout
        (   R   t   executeR   t
   StandardIOR`   R   (   R:   t   stdioProtocolFactory(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   listen   s    (   R"   R#   RN   R>   Rk   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR/      s   	t   _ProcessEndpointTransportt   _processc           B`  s    e  Z d  Z d   Z d   Z RS(   s0  
    An L{ITransport} 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
    c         C`  s   |  j  j d |  d S(   sp   
        Write to the child process's standard input.

        @param data: The data to write on stdin.
        i    N(   Rm   t   writeToChild(   R:   RG   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   write  s    c         C`  s(   x! | D] } |  j  j d |  q Wd S(   s   
        Write a list of strings to child process's stdin.

        @param data: The list of chunks to write on stdin.
        i    N(   Rm   Rn   (   R:   RG   t   chunk(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   writeSequence  s    (   R"   R#   RN   Ro   Rq   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRl   	  s   
		t   _WrapIProtocolc           B`  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   
    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         C`  s   | |  _  | |  _ | |  _ d S(   s   
        @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(   Ra   t   errFlagt
   executable(   R:   Rc   Rt   Rs   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>   3  s    		c         C`  s"   t  |  |  _ |  j j |  j  S(   s   
        Call L{IProtocol} provider's makeConnection method with an
        L{ITransport} provider.

        @param process: An L{IProcessTransport} provider.
        (   Rl   RC   Ra   RB   (   R:   t   process(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRB   ?  s    c      
   C`  si   | d k r |  j  j |  S| d k re |  j t j k re t j d d d |  j d |  j  d |  n  d S(	   s   
        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.
        i   i   t   formatsG   Process %(executable)r wrote stderr unhandled by %(protocol)s: %(data)sRt   Ra   RG   N(   Ra   RF   Rs   R2   t   LOGR   t   msgRt   (   R:   t   childFDRG   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   childDataReceivedJ  s    	c         C`  s]   | j  t j  t j k rI | j j d k rI |  j j t t j     S|  j j |  Sd S(   s   
        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}
        i    N(	   t   checkR   t   ProcessDonet   valuet   statusRa   RJ   R   t   ConnectionDone(   R:   RK   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   processEndedZ  s
    	(   R"   R#   RN   R>   RB   Rz   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRr   )  s
   			c           B`  s    e  Z d  Z e   Z e   Z RS(   s   
    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
    (   R"   R#   RN   R   Rw   t   DROP(    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR2   k  s   	c        	   B`  s;   e  Z d  Z d i  d d d d d e j d  Z d   Z RS(   s   
    An endpoint for child processes

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

    @since: 13.1
    i    c         C`  sm   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ |
 |  _	 |  j  j
 |  _ d S(   s   
        See L{IReactorProcess.spawnProcess}.

        @param errFlag: Determines if stderr should be logged.
        @type errFlag: L{endpoints.StandardErrorBehavior}
        N(   Rf   t   _executablet   _argst   _envt   _patht   _uidt   _gidt   _usePTYt	   _childFDst   _errFlagt   spawnProcesst   _spawnProcess(   R:   Rg   Rt   t   argst   envt   patht   uidt   gidt   usePTYt   childFDsRs   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s    											c      
   C`  s   | j  t    } yS |  j t | |  j |  j  |  j |  j |  j |  j |  j	 |  j
 |  j |  j 	 Wn t j   SXt j |  Sd S(   s3  
        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.
        N(   R`   R   R   Rr   R   R   R   R   R   R   R   R   R   R   t   failt   succeed(   R:   t   protocolFactoryRc   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   connect  s    (    N(   R"   R#   RN   t   NoneR2   Rw   R>   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR0   y  s
   	t   _TCPServerEndpointc           B`  s    e  Z d  Z d   Z d   Z RS(   s)   
    A TCP server endpoint interface
    c         C`  s(   | |  _  | |  _ | |  _ | |  _ d S(   s+  
        @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(   Rf   t   _portt   _backlogt
   _interface(   R:   Rg   t   portt   backlogt	   interface(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s    			c         C`  s.   t  j |  j j |  j | d |  j d |  j S(   s]   
        Implement L{IStreamServerEndpoint.listen} to listen on a TCP
        socket
        R   R   (   R   Rh   Rf   t	   listenTCPR   R   R   (   R:   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRk     s
    	(   R"   R#   RN   R>   Rk   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR     s   	c           B`  s   e  Z d  Z d d d  Z RS(   sC   
    Implements TCP server endpoint with an IPv4 configuration
    i2   t    c         C`  s   t  j |  | | | |  d S(   sA  
        @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:   Rg   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s    (   R"   R#   RN   R>   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR&     s   c           B`  s   e  Z d  Z d d d  Z RS(   sC   
    Implements TCP server endpoint with an IPv6 configuration
    i2   s   ::c         C`  s   t  j |  | | | |  d S(   sA  
        @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:   Rg   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s    (   R"   R#   RN   R>   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR'     s   c           B`  s&   e  Z d  Z d d d  Z d   Z RS(   s9   
    TCP client endpoint with an IPv4 configuration.
    i   c         C`  s1   | |  _  | |  _ | |  _ | |  _ | |  _ d S(   s  
        @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: int

        @param bindAddress: A (host, port) tuple of local address to bind to,
            or None.
        @type bindAddress: tuple
        N(   Rf   t   _hostR   t   _timeoutt   _bindAddress(   R:   Rg   t   hostR   t   timeoutt   bindAddress(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s
    				c         C`  sZ   yE t  |  } |  j j |  j |  j | d |  j d |  j | j SWn t j	   SXd S(   sP   
        Implement L{IStreamClientEndpoint.connect} to connect via TCP.
        R   R   N(
   RO   Rf   t
   connectTCPR   R   R   R   RT   R   R   (   R:   R   t   wf(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR     s    	N(   R"   R#   RN   R   R>   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR(     s   c           B`  s\   e  Z d  Z e j Z e e j  Z	 d Z
 d Z d d d  Z d   Z d   Z d   Z RS(	   s  
    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}.
    i   i    i   c         C`  s1   | |  _  | |  _ | |  _ | |  _ | |  _ d S(   s   
        @param host: An IPv6 address literal or a hostname with an
            IPv6 address

        @see: L{twisted.internet.interfaces.IReactorTCP.connectTCP}
        N(   Rf   R   R   R   R   (   R:   Rg   R   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>   @  s
    				c         `  sf   t    j  r'   j   j |  } n;   j   j  } | j   f d    | j   j |  | S(   s~   
        Implement L{IStreamClientEndpoint.connect} to connect via TCP,
        once the hostname resolution is done.
        c         `  s   |  d   j    j S(   Ni    (   t   _GAI_ADDRESSt   _GAI_ADDRESS_HOST(   t   result(   R:   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   <lambda>W  s   (   R   R   t   _resolvedHostConnectt   _nameResolutiont   addCallback(   R:   R   t   d(    (   R:   sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR   N  s    c         C`  s   |  j  |  j | d t j  S(   sd   
        Resolve the hostname string into a tuple containing the host
        IPv6 address.
        i    (   t   _deferToThreadt   _getaddrinfot   socketR   (   R:   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR   ]  s    c         C`  sW   yB t  |  } |  j j | |  j | d |  j d |  j | j SWn t j   SXd S(   sD   
        Connect to the server using the resolved hostname.
        R   R   N(	   RO   Rf   R   R   R   R   RT   R   R   (   R:   t   resolvedHostR   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR   f  s    N(   R"   R#   RN   R   t   getaddrinfoR   t   staticmethodR	   t   deferToThreadR   R   R   R   R>   R   R   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR)   +  s   				c           B`  sG   e  Z d  Z e j Z e e j  Z	 d d d  Z d   Z d   Z RS(   s   
    A name-based endpoint that connects to the fastest amongst the
    resolved host addresses.

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

    @ivar _deferToThread: A hook used for testing deferToThread.
    i   c         C`  s1   | |  _  | |  _ | |  _ | |  _ | |  _ d S(   sN  
        @param host: A hostname to connect to.
        @type host: L{bytes}

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

        @see: L{twisted.internet.interfaces.IReactorTCP.connectTCP}
        N(   Rf   R   R   R   R   (   R:   Rg   R   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s
    				c         `  s   |  g     f d      f d   }  f d   }      f d   }  j   j  j  } | j |  | j |  | j |  | S(   s   
        Attempts a connection to each address returned by gai, and returns a
        connection which is established first.
        c         `  sE   |  j  t j t  j  j    x   D] } | j   q- Wd S(   s1  
            The outgoing connection attempt was cancelled.  Fail that L{Deferred}
            with an L{error.ConnectingCancelledError}.

            @param d: The L{Deferred <defer.Deferred>} that was cancelled
            @type d: L{Deferred <defer.Deferred>}

            @return: C{None}
            N(   RY   R   RZ   R   R   R   t   cancel(   R   t   p(   t   pendingR:   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRS     s    
c         `  s    t  j t j d   j f   S(   su   
            Errback for when L{_nameResolution} returns a Deferred that fires
            with failure.
            s   Couldn't find the hostname '%s'(   R   R   R   t   DNSLookupErrorR   (   t   failure(   R:   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   errbackForGai  s    c         3`  s   x |  D] \ } } } } } | t  g k rV t   j | d | d   j   j  Vq | t g k r t   j | d | d   j   j  Vq q Wd S(   s   
            This method matches the host address family with an endpoint for
            every address returned by GAI.

            @param gaiResult: A list of 5-tuples as returned by GAI.
            @type gaiResult: list
            i    i   N(   R   R)   Rf   R   R   R   R(   (   t	   gaiResultt   familyt   socktypeRc   t	   canonnamet   sockaddr(   R:   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt
   _endpoints  s    c      	   `  s   g   g   g   t  j d 
  	  f d       	 f d         	 f d      f d              f	 d   } t |    j  _  j d  	 S(   sc   
            When L{endpoints} yields an endpoint, this method attempts to connect it.
            RP   c         `  s     j  |  |  S(   N(   t   remove(   t
   connResultt   connAttempt(   R   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   usedEndpointRemoval  s    c         `  sP     j  r   j   n   j t  x  D] } | j   q+ W j |   d  S(   N(   t   runningt   stopt   appendt   TrueR   RD   R   (   R   R   (   t   lcR   t
   successfult   winner(    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   afterConnectionAttempt  s    	c           `  s.     r*  r*  r*  j   j    n  d  S(   N(   RY   t   pop(    (   t   endpointsListExhaustedt   failuresR   R   R   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt	   checkDone  s    c         `  s    j  |       d  S(   N(   R   R   (   RK   (   R   R   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   connectFailed  s    c          `  s   y t    }  Wn/ t k
 rA  j t   j      nG X|  j   }  j |  | j  |  | j    | j   d  S(   N(	   t   nextt   StopIterationR   R   R   R   t   addBothR   t
   addErrback(   t   endpointt   dconn(	   R   R   R   t	   endpointsR   R   R   R   R   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   iterateEndpoint  s    
g333333?(   R   RR   R   Rf   t   clockt   start(   R   R   (   RS   R   R:   R   (
   R   R   R   R   R   R   R   R   R   R   sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   attemptConnection  s    

'(   R   R   R   R   R   (   R:   R   R   R   R   R   (    (   RS   R   R:   R   sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR     s    :c         C`  s   |  j  |  j | | d t j  S(   s^   
        Resolve the hostname string into a tuple containig the host
        address.
        i    (   R   R   R   t   SOCK_STREAM(   R:   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR     s    N(   R"   R#   RN   R   R   R   R   R	   R   R   R   R>   R   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR1   t  s   			pc           B`  s&   e  Z d  Z d d d  Z d   Z RS(   sE   
    SSL secured TCP server endpoint with an IPv4 configuration.
    i2   R   c         C`  s1   | |  _  | |  _ | |  _ | |  _ | |  _ d S(   s  
        @param reactor: An L{IReactorSSL} provider.

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

        @param sslContextFactory: An instance of
            L{twisted.internet.ssl.ContextFactory}.

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

        @param interface: The hostname to bind to, defaults to '' (all)
        @type interface: str
        N(   Rf   R   t   _sslContextFactoryR   R   (   R:   Rg   R   t   sslContextFactoryR   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s
    				c      
   C`  s7   t  j |  j j |  j | d |  j d |  j d |  j S(   sf   
        Implement L{IStreamServerEndpoint.listen} to listen for SSL on a
        TCP socket.
        t   contextFactoryR   R   (   R   Rh   Rf   t	   listenSSLR   R   R   R   (   R:   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRk   +  s
    		(   R"   R#   RN   R>   Rk   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR,     s   c           B`  s&   e  Z d  Z d d d  Z d   Z RS(   sD   
    SSL secured TCP client endpoint with an IPv4 configuration
    i   c         C`  s:   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ d S(   sq  
        @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{twisted.internet.ssl.ContextFactory}.

        @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(   Rf   R   R   R   R   R   (   R:   Rg   R   R   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>   >  s    					c      	   C`  s`   yK t  |  } |  j j |  j |  j | |  j d |  j d |  j | j SWn t	 j
   SXd S(   sb   
        Implement L{IStreamClientEndpoint.connect} to connect with SSL over
        TCP.
        R   R   N(   RO   Rf   t
   connectSSLR   R   R   R   R   RT   R   R   (   R:   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR   \  s    	N(   R"   R#   RN   R   R>   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR-   8  s   c           B`  s)   e  Z d  Z d d d d  Z d   Z RS(   s%   
    UnixSocket server endpoint.
    i2   i  i    c         C`  s1   | |  _  | |  _ | |  _ | |  _ | |  _ d S(   s  
        @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(   Rf   t   _addressR   t   _modet   _wantPID(   R:   Rg   t   addressR   t   modet   wantPID(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>   q  s
    
				c      
   C`  s7   t  j |  j j |  j | d |  j d |  j d |  j S(   sW   
        Implement L{IStreamServerEndpoint.listen} to listen on a UNIX socket.
        R   R   R   (   R   Rh   Rf   t
   listenUNIXR   R   R   R   (   R:   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRk     s
    		(   R"   R#   RN   R>   Rk   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR*   l  s   c           B`  s&   e  Z d  Z d d d  Z d   Z RS(   s%   
    UnixSocket client endpoint.
    i   i    c         C`  s(   | |  _  | |  _ | |  _ | |  _ d S(   s  
        @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(   Rf   R   R   t	   _checkPID(   R:   Rg   R   R   t   checkPID(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s    			c         C`  sT   y? t  |  } |  j j |  j | d |  j d |  j | j SWn t j   SXd S(   sa   
        Implement L{IStreamClientEndpoint.connect} to connect via a
        UNIX Socket
        R   R   N(	   RO   Rf   t   connectUNIXR   R   R   RT   R   R   (   R:   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR     s    		
(   R"   R#   RN   R>   R   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR+     s   c           B`  s8   e  Z d  Z e j Z e e j  Z	 d   Z
 d   Z RS(   s   
    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         C`  s(   | |  _  | |  _ | |  _ t |  _ d S(   s  
        @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}.
        N(   Rg   t   filenot   addressFamilyt   Falset   _used(   R:   Rg   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR>     s    
			c         C`  s   |  j  r t j t j    St |  _  yB |  j |  j  |  j j	 |  j |  j
 |  } |  j |  j  Wn t j   SXt j |  S(   s{   
        Implement L{IStreamServerEndpoint.listen} to start listening on, and
        then close, C{self._fileno}.
        (   R   R   R   R   t   AlreadyListenedR   t   _setNonBlockingR   Rg   t   adoptStreamPortR   t   _closeR   (   R:   t   factoryR   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRk     s    			(   R"   R#   RN   t   ost   closeR   R   R   t   setNonBlockingR   R>   Rk   (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR.     s
   		R   i2   c         C`  s*   t  |  |  f i | d 6t  |  d 6f S(   s  
    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 C{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 C{NoneType}

    @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   (   t   int(   R   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt	   _parseTCP  s    t   666c         C`  s@   | |  f i t  | d  d 6t  |  d 6t t  |   d 6f S(   s  
    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 C{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 C{NoneType}

    @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{IReactorTCP.listenUNIX} (or, modulo argument 2, the factory,
        arguments to L{UNIXServerEndpoint}.
    i   R   R   R   (   R   t   bool(   R   R   R   R   t   lockfile(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt
   _parseUNIX  s    	 s
   server.pemc         C`  sq  d d l  m } | d k r% | } n  i  }	 | d k	 rP t | j |  |	 d <n | j j |	 d <t |  j   }
 t |  j   } | j j	 |
 |  } | d k	 rt
 j d t |  j   d t
 j } g  | D] } | j j	 |  j ^ q } | st d | f   qn d } | j d | j j d | j d	 | |	  } t |  |  | f i | d
 6t |  d 6f S(   s  
    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 C{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 C{NoneType}

    @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}.  Must be one of: "SSLv23_METHOD",
        "SSLv2_METHOD", "SSLv3_METHOD", "TLSv1_METHOD".
    @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{bytes}

    @return: a 2-tuple of (args, kwargs), describing  the parameters to
        L{IReactorSSL.listenSSL} (or, modulo argument 2, the factory, arguments
        to L{SSL4ServerEndpoint}.
    i    (   t   sslt   methods=   (-----BEGIN CERTIFICATE-----\n.+?\n-----END CERTIFICATE-----)t   flagssO   Specified chain file '%s' doesn't contain any valid certificates in PEM format.t
   privateKeyt   certificatet   extraCertChainR   R   N(   t   twisted.internetR  R   t   getattrt   SSLt   SSLv23_METHODR   t
   getContentt   PrivateCertificatet   loadPEMt   ret   findallt   DOTALLt   Certificatet   originalt
   ValueErrort   CertificateOptionsR  R   (   R   R   R  t   certKeyt	   sslmethodR   R   R  R  t   kwt   certPEMt   keyPEMt   privateCertificatet   matchest   chainCertPEMt   chainCertificatest   cf(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt	   _parseSSL$  s:    '	%			t   _StandardIOParserc           B`  s&   e  Z d  Z d Z d   Z d   Z RS(   s   
    Stream server endpoint string parser for the Standard I/O type.

    @ivar prefix: See L{IStreamClientEndpointStringParser.prefix}.
    R   c         C`  s
   t  |  S(   s   
        Internal parser function for L{_parseServer} to convert the string
        arguments into structured arguments for the L{StandardIOEndpoint}

        @param reactor: Reactor for the endpoint
        (   R/   (   R:   Rg   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _parseServerz  s    c         O`  s   |  j  |  S(   N(   R#  (   R:   Rg   R   t   kwargs(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   parseStreamServer  s    (   R"   R#   RN   t   prefixR#  R%  (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR"  q  s   	
t   _SystemdParserc           B`  s2   e  Z d  Z e j   Z d Z d   Z d   Z RS(   s  
    Stream server endpoint string parser for the I{systemd} endpoint type.

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

    @ivar _sddaemon: A L{ListenFDs} instance used to translate an index into an
        actual file descriptor.
    t   systemdc         C`  sB   t  |  } |  j j   | } t t d |  } t | | |  S(   s|  
        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.
        @type domain: C{str}

        @param index: An offset into the list of file descriptors inherited from
            systemd.
        @type index: C{str}

        @return: A two-tuple of parsed positional arguments and parsed keyword
            arguments (a tuple and a dictionary).  These can be used to
            construct an L{AdoptedStreamServerEndpoint}.
        t   AF_(   R   t	   _sddaemont   inheritedDescriptorsR
  R   R.   (   R:   Rg   t   domaint   indexR   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR#    s    c         O`  s   |  j  | | |  S(   N(   R#  (   R:   Rg   R   R$  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR%    s    (	   R"   R#   RN   R   t   fromEnvironmentR*  R&  R#  R%  (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR'    s
   		t   _TCP6ServerParserc           B`  s,   e  Z d  Z d Z d d d  Z d   Z RS(   s   
    Stream server endpoint string parser for the TCP6ServerEndpoint type.

    @ivar prefix: See L{IStreamClientEndpointStringParser.prefix}.
    t   tcp6i2   s   ::c         C`  s+   t  |  } t  |  } t | | | |  S(   s  
        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
        (   R   R'   (   R:   Rg   R   R   R   (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR#    s    c         O`  s   |  j  | | |  S(   N(   R#  (   R:   Rg   R   R$  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR%    s    (   R"   R#   RN   R&  R#  R%  (    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR/    s   t   tcpt   unixR  i   c         c`  s   d } d } i d d 6d d 6} t  |   }  xl |  D]d } | | k rn t | f Vt | f Vd } | | } q3 | d k r | |  j   7} q3 | | 7} q3 Wt | f Vd S(   s~  
    Tokenize a strports string and yield each token.

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

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

            _STRING, 'hello'
            _OP, ':'
            _STRING, 'greet=ing'
            _OP, '='
            _STRING, 'world'
    R   s   :=t   :t   =s   \N(   t   itert   _STRINGt   _OPR   (   t   descriptiont   currentt   opst   nextOpst   n(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt	   _tokenize  s    c         `  s   g  i        f d   } d } xU t  |   D]G \ } } | t k rZ | | f 7} q2 | d k r2 | |  d } q2 q2 W| |     f S(   s  
    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'})}.
    c         `  s<   t  |   d k r&   j |  d  n |  d  |  d <d  S(   Ni   i    (   t   lenR   (   t   sofar(   R   R  (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   add  s    R3  (    (    (   R=  R6  (   R8  R@  R?  t   typeR}   (    (   R   R  sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _parse  s    

t   TCPR  t   UNIXc   	      C`  s.  t  |   \ } } | s2 t |  d k r | r d |  f } | d	 k rm d } t j | d t d d n | t k r t |   n  | g | d d +n  | d } t j	 |  } | d	 k rx4 t
 t  D]& } | j | k r | | d | f Sq Wt d | f   n  | j   f | | | d |  S(
   s  
    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}

    @param default: Deprecated argument, specifying the default parser mode to
        use for unqualified description strings (those which do not have a ':'
        and prefix).
    @type default: C{str} or C{NoneType}

    @return: a 3-tuple of (plugin or name, arguments, keyword arguments)
    i   so   Unqualified strport description passed to 'service'.Use qualified endpoint descriptions; for example, 'tcp:%s'.R1  t   categoryt
   stackleveli   i    s   Unknown endpoint type: '%s'N(   RB  R>  R   t   warningst   warnt   DeprecationWarningt   _NO_DEFAULTR  t   _serverParserst   getR   R   R&  t   upper(	   R8  R   t   defaultR   R  t   deprecationMessaget   endpointTypet   parsert   plugin(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR#  <  s&     

c         C`  sr   t  | d |  \ } } } t |  t k	 rF | } | j |  | |  S| } | d  | d } t | |  | |  S(   s   
    Underlying implementation of L{serverFromString} which avoids exposing the
    deprecated 'default' argument to anything but L{strports.service}.
    i   i   N(   R#  R   RA  t   strR%  t   _endpointServerFactories(   Rg   R8  RN  t   nameOrPluginR   R  RR  t   name(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _serverFromStringLegacyl  s    c         C`  s   t  |  | t  S(   s2	  
    Construct a stream server endpoint from an endpoint description string.

    The format for server endpoint descriptions is a simple 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.

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

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

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

    @since: 10.2
    (   RW  RJ  (   Rg   R8  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR%   }  s    <c         C`  s   |  j  d d  j  d d  S(   s~  
    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("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("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}
    s   \s   \\R3  s   \:(   t   replace(   t   argument(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   quoteStringArgument  s    c          O`  s  t  |   d k r7 t |  d  | d <|  d | d <nF t  |   d k r} d | k rl t |  d  | d <q} |  d | d <n  y t | d  | d <Wn t k
 r n Xy t | d  | d <Wn t k
 r n Xy | d d f | d <Wn t k
 r n X| S(   s$  
    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}.
    i   i   R   i    R   R   R   (   R>  R   t   KeyError(   R   R$  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _parseClientTCP  s(    c         C`  s   d d l  m } i  } x |  j   D] } | j   j d  d j   d k sT q# n  y | j   } Wn t k
 rz q# n Xy | j j	 |  } Wn | j
 j k
 r q# X| j | | j   <q# W| j   S(   s   
    Load certificate-authority certificate objects in a given directory.

    @param directoryPath: a L{FilePath} pointing at a directory to load .pem
        files from.

    @return: a C{list} of L{OpenSSL.crypto.X509} objects.
    i    (   R  t   .it   pem(   R	  R  t   childrent   basenamet   splitt   lowerR  t   IOErrorR  R  R  t   ErrorR  t   digestt   values(   t   directoryPathR  t   caCertst   childRG   t   theCert(    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _loadCAsFromDir  s    	%c    	      O`  s/  d d l  m } t |  |   } | j d d  } | j d d  } | j d d  } | d k	 r | j j t |  j    j	 } n d } | d k	 r | j
 j t |  j    j j	 } n d } | d k	 r t } t t |   } n t } d } | j d | j j d | d | d | d	 |  | d
 <| S(   s  
    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.

    @param 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: C{str}

    @return: The coerced values as a C{dict}.
    i    (   R  R  R  t
   caCertsDirR  R  t   verifyRh  R   N(   R	  R  R\  R   R   R  R  R   R  R  R  R  R   Rk  R   R  R  R  (	   R   R$  R  R  R  Rl  t   certx509Rm  Rh  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _parseClientSSL%  s2    			c          O`  s   t  |   d k r# |  d | d <n  y# t t | j d    | d <Wn t k
 rY n Xy t | d  | d <Wn t k
 r n X| S(   s  
    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}.
    i   i    R   R  R   R   (   R>  R   R   R   R[  (   R   R$  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   _parseClientUNIX[  s    #c         C`  s   t  |  \ } } | j d  } | j   } x9 t t  D]+ } | j j   | k r: | j | |   Sq: W| t k r t d | f   n  t | | |   } t	 | |  |  S(   s
  
    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, "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{IStreamClientEndpointStringParser} 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.

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

    @since: 10.2
    i    s   Unknown endpoint type: %r(
   RB  R   RM  R   R   R&  t   parseStreamClientt   _clientParsersR  t   _endpointClientFactories(   Rg   R8  R   R$  t   anameRV  RR  (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR$   |  s    Fc         `  s,   d t  f   f d     Y} |  j |    S(   s  
    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
    t   OneShotFactoryc           `  s   e  Z   f d    Z RS(   c         `  s     S(   N(    (   R:   Rb   (   Ra   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR`     s    (   R"   R#   R`   (    (   Ra   (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyRu    s   (   R   R   (   R   Ra   Ru  (    (   Ra   sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyR3     s    (p   RN   t
   __future__R    R   R   R   R  t   zope.interfaceR   R   RG  t   twisted.python.compatR   R	  R   R   R   R   R	   t   twisted.internet.protocolR
   R   R   R   t   twisted.internet.interfacesR   R   t   twisted.python.filepathR   t   twisted.python.systemdR   t   twisted.internet.abstractR   t   twisted.python.failureR   t   twisted.pythonR   t   twisted.internet.addressR   R   t   twisted.python.componentsR   R   R   t   twisted.internet.taskR   t   twisted.pluginR   R   R   t   twisted.internet.stdioR   t   twisted.python.constantsR   R    R!   t   objectt   __all__t   __all3__R4   RO   t   IStreamServerEndpointR/   t
   ITransportt   IProcessTransportRl   Rr   R2   t   IStreamClientEndpointR0   R   R&   R'   R(   R)   R1   R,   R-   R*   R+   R.   R   R   R  R   R!  R"  R'  R/  RK  t   rangeR7  R6  R=  RB  RT  Rs  RJ  R#  RW  R%   RZ  R\  Rk  Ro  Rp  Rr  R$   R3   RV  R   t   globals(    (    (    sL   /var/www/html/hlstest/hls-proxy/Twisted-13.2.0/twisted/internet/endpoints.pyt   <module>   s   ("OaB3%-H*3!*/ L1$

	%	

	0		@	!	(		6	
	S	