%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/tornado/netutil.pyo

�
��L]c	@�sdZddlmZmZmZmZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
ddlmZddlmZddlmZmZmZyddlZWnek
r�dZnXyddlZWn8ek
r*edkseed�r$dZq+�nXyeWnek
rLeZnXeed	�r�eed
�r�ejZej Z!n=edkr�dZZ!n$ddl"Z#e#jjZe#jj Z!eed�r�eed�rej$ej%j&�Z'ej$ej%j(�Z)q�ej*ej+�Z'ej,e'_-e'j.ej/��ej*ej+�Z)eed�r�e'j0ej1O_0e)j0ej1O_0q�nHer�e2d
ej,dej/��Z'iZ)ne2d
ddd�Z'iZ)ed�j3d�ej4ej5fZ6eed�re6ej7f7Z6ndZ8de	j9e8dd�Z:ee	d�rRde8d�Z;ndd�Z<d�Z=defd��YZ>de>fd��YZ?de?fd��YZ@de?fd ��YZAd!e>fd"��YZBeCd#d$d%d
dd&g�ZDd'�ZEdd(�ZFdS()s#Miscellaneous network utility code.i(tabsolute_importtdivisiontprint_functiontwith_statementN(tdummy_executortrun_on_executor(tIOLoop(tset_close_exec(tutConfigurableterrno_from_exceptiontcreate_default_contexttmatch_hostnametCertificateErrort
SSLContexttOP_NO_COMPRESSIONt	cert_reqstca_certstfootidnatWSAEWOULDBLOCKi�cC�s@g}|dkrd
}ntjr@|tjkr@tj}n|d
krXtj}nd
}x�ttj|||tjd|��D]�}|\}}	}
}}t	j
dkr�|dkr�|tjkr�|ddkr�q�nytj||	|
�}
Wn4tjk
r0}t
|�tjkr*q�n�nXt|
j��tjdkrl|
jtjtjd�n|tjkr�ttd�r�|
jtjtjd�q�n|d	 \}}|dkr�|d
k	r�t||gt|d	��}n|
jd�|
j|�|
j�d}|
j|�|j |
�q�W|S(sbCreates listening sockets bound to the given port and address.

    Returns a list of socket objects (multiple sockets are returned if
    the given address maps to multiple IP addresses, which is most common
    for mixed IPv4 and IPv6 use).

    Address may be either an IP address or hostname.  If it's a hostname,
    the server will listen on all IP addresses associated with the
    name.  Address may be an empty string or None to listen on all
    available interfaces.  Family may be set to either `socket.AF_INET`
    or `socket.AF_INET6` to restrict to IPv4 or IPv6 addresses, otherwise
    both will be used if available.

    The ``backlog`` argument has the same meaning as for
    `socket.listen() <socket.socket.listen>`.

    ``flags`` is a bitmask of AI_* flags to `~socket.getaddrinfo`, like
    ``socket.AI_PASSIVE | socket.AI_NUMERICHOST``.
    titdarwint	localhostitntitIPPROTO_IPV6iN(!tNonetsocketthas_ipv6t	AF_UNSPECtAF_INETt
AI_PASSIVEtsettgetaddrinfotSOCK_STREAMtsystplatformtAF_INET6terrorR
terrnotEAFNOSUPPORTRtfilenotostnamet
setsockoptt
SOL_SOCKETtSO_REUSEADDRthasattrRtIPV6_V6ONLYttupletlisttsetblockingtbindtgetsocknametlistentappend(tporttaddresstfamilytbacklogtflagstsocketst
bound_porttrestaftsocktypetprotot	canonnametsockaddrtsocktethosttrequested_port((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytbind_socketspsF		#


tAF_UNIXi�cC�s�tjtjtj�}t|j��|jtjtjd�|jd�yt	j
|�}Wn.tk
r�}t|�t
jkr��q�n2Xt
j|j�r�t	j|�ntd|��|j|�t	j||�|j|�|S(s(Creates a listening unix socket.

        If a socket with the given name already exists, it will be deleted.
        If any other file with that name exists, an exception will be
        raised.

        Returns a socket object (not a list of socket objects like
        `bind_sockets`)
        iis"File %s exists and is not a socket(RRJR"RR)R,R-R.R3R*tstattOSErrorR
R'tENOENTtS_ISSOCKtst_modetremovet
ValueErrorR4tchmodR6(tfiletmodeR;REtstterr((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytbind_unix_socket�s 




c�sG|dkrtj�}n��fd�}|j�|tj�dS(s�Adds an `.IOLoop` event handler to accept new connections on ``sock``.

    When a connection is accepted, ``callback(connection, address)`` will
    be run (``connection`` is a socket object, and ``address`` is the
    address of the other end of the connection).  Note that this signature
    is different from the ``callback(fd, events)`` signature used for
    `.IOLoop` handlers.

    .. versionchanged:: 4.1
       The ``io_loop`` argument is deprecated.
    c�s�x�tt�D]v}y�j�\}}WnJtjk
ru}t|�tkrTdSt|�tjkroq
n�nX�||�q
WdS(N(	txranget_DEFAULT_BACKLOGtacceptRR&R
t_ERRNO_WOULDBLOCKR'tECONNABORTED(tfdteventstit
connectionR9RF(tcallbackRE(s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytaccept_handler�sN(RRtcurrenttadd_handlertREAD(RERatio_loopRb((RaREs5/usr/lib64/python2.7/site-packages/tornado/netutil.pytadd_accept_handler�scC�s�|sd|krtSy5tj|dtjtjdtj�}t|�SWn3tjk
r�}|jdtj	kr{tS�nXt
S(s_Returns true if the given string is a well-formed IP address.

    Supports IPv4 and IPv6.
    ti(tFalseRR!RR"tAI_NUMERICHOSTtbooltgaierrortargst
EAI_NONAMEtTrue(tipR?RF((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytis_valid_ipstResolvercB�sGeZdZed��Zed��Zejdd�Z	d�Z
RS(s{Configurable asynchronous DNS resolver interface.

    By default, a blocking implementation is used (which simply calls
    `socket.getaddrinfo`).  An alternative implementation can be
    chosen with the `Resolver.configure <.Configurable.configure>`
    class method::

        Resolver.configure('tornado.netutil.ThreadedResolver')

    The implementations of this interface included with Tornado are

    * `tornado.netutil.BlockingResolver`
    * `tornado.netutil.ThreadedResolver`
    * `tornado.netutil.OverrideResolver`
    * `tornado.platform.twisted.TwistedResolver`
    * `tornado.platform.caresresolver.CaresResolver`
    cC�stS(N(Rr(tcls((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytconfigurable_base3scC�stS(N(tBlockingResolver(Rs((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytconfigurable_default7scC�s
t��dS(sResolves an address.

        The ``host`` argument is a string which may be a hostname or a
        literal IP address.

        Returns a `.Future` whose result is a list of (family,
        address) pairs, where address is a tuple suitable to pass to
        `socket.connect <socket.socket.connect>` (i.e. a ``(host,
        port)`` pair for IPv4; additional fields may be present for
        IPv6). If a ``callback`` is passed, it will be run with the
        result as an argument when it is complete.
        N(tNotImplementedError(tselfRGR8R:Ra((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytresolve;s
cC�sdS(s[Closes the `Resolver`, freeing any resources used.

        .. versionadded:: 3.1

        N((Rx((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytcloseJsN(t__name__t
__module__t__doc__tclassmethodRtRvRRRRyRz(((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRr!s
tExecutorResolvercB�s>eZdZdded�Zd�Zeej	d��Z
RS(s�Resolver implementation using a `concurrent.futures.Executor`.

    Use this instead of `ThreadedResolver` when you require additional
    control over the executor being used.

    The executor will be shut down when the resolver is closed unless
    ``close_resolver=False``; use this if you want to reuse the same
    executor elsewhere.

    .. versionchanged:: 4.1
       The ``io_loop`` argument is deprecated.
    cC�sL|ptj�|_|dk	r6||_||_nt|_t|_dS(N(RRcRfRtexecutortclose_executorRRi(RxRfR�R�((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyt
initialize`s		cC�s&|jr|jj�nd|_dS(N(R�R�tshutdownR(Rx((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRzis	c
C�sXtj|||tj�}g}x0|D](\}}}}}	|j||	f�q(W|S(N(RR!R"R7(
RxRGR8R:taddrinfotresultsRARBRCR9((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRyns
N(R{R|R}RRoR�RzRRRRy(((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRSs
		RucB�seZdZdd�ZRS(s�Default `Resolver` implementation, using `socket.getaddrinfo`.

    The `.IOLoop` will be blocked during the resolution, although the
    callback will not be run until the next `.IOLoop` iteration.
    cC�stt|�jd|�dS(NRf(tsuperRuR�(RxRf((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyR��sN(R{R|R}RR�(((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRu|stThreadedResolvercB�s8eZdZdZdZddd�Zed��ZRS(s$Multithreaded non-blocking `Resolver` implementation.

    Requires the `concurrent.futures` package to be installed
    (available in the standard library since Python 3.2,
    installable with ``pip install futures`` in older versions).

    The thread pool size can be configured with::

        Resolver.configure('tornado.netutil.ThreadedResolver',
                           num_threads=10)

    .. versionchanged:: 3.1
       All ``ThreadedResolvers`` share a single thread pool, whose
       size is set by the first one to be created.
    i
cC�s8tj|�}tt|�jd|d|dt�dS(NRfR�R�(R�t_create_threadpoolR�R�Ri(RxRftnum_threadst
threadpool((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyR��scC�shtj�}|j|kr'd|_n|jdkraddlm}||�|_||_n|jS(Ni(tThreadPoolExecutor(R*tgetpidt_threadpool_pidRt_threadpooltconcurrent.futuresR�(RsR�tpidR�((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyR��sN(	R{R|R}RR�R�R�R~R�(((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyR��s
tOverrideResolvercB�s)eZdZd�Zd�Zd�ZRS(s�Wraps a resolver with a mapping of overrides.

    This can be used to make local DNS changes (e.g. for testing)
    without modifying system-wide settings.

    The mapping can contain either host strings or host-port pairs.
    cC�s||_||_dS(N(tresolvertmapping(RxR�R�((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyR��s	cC�s|jj�dS(N(R�Rz(Rx((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRz�scO�si||f|jkr1|j||f\}}n||jkrP|j|}n|jj||||�S(N(R�R�Ry(RxRGR8Rmtkwargs((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyRy�s
(R{R|R}R�RzRy(((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyR��s		tssl_versiontcertfiletkeyfiletcipherscC�s	t|t�rnttd�s4t|tj�r8|Stj|jdtj��}d|kr�|j|d|jdd	��nd|kr�|d|_	nd|kr�|j
|d�nd|kr�|j|d�nttd�r|jtj
O_n|S(
s�Try to convert an ``ssl_options`` dictionary to an
    `~ssl.SSLContext` object.

    The ``ssl_options`` dictionary contains keywords to be passed to
    `ssl.wrap_socket`.  In Python 2.7.9+, `ssl.SSLContext` objects can
    be used instead.  This function converts the dict form to its
    `~ssl.SSLContext` equivalent, and may be used when a component which
    accepts both forms needs to upgrade to the `~ssl.SSLContext` version
    to use features like SNI or NPN.
    RR�R�R�RRR�RN(t
isinstancetdictR/tsslRtgettPROTOCOL_SSLv23tload_cert_chainRtverify_modetload_verify_locationstset_cipherstoptionsR(tssl_optionstcontext((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytssl_options_to_context�s$#cK�s�t|�}ttd�rqt|tj�rq|dk	r^ttd�r^|j|d||�S|j||�Sntj|t||��SdS(sTReturns an ``ssl.SSLSocket`` wrapping the given socket.

    ``ssl_options`` may be either an `ssl.SSLContext` object or a
    dictionary (as accepted by `ssl_options_to_context`).  Additional
    keyword arguments are passed to ``wrap_socket`` (either the
    `~ssl.SSLContext` method or the `ssl` module function as
    appropriate).
    RtHAS_SNItserver_hostnameN(	R�R/R�R�RRtgetattrtwrap_socketR�(RR�R�R�R�((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pytssl_wrap_socket�s	!(GR}t
__future__RRRRR'R*R#RRKttornado.concurrentRRttornado.ioloopRttornado.platform.autoRttornado.utilRR	R
R�tImportErrorRtcertifiR/RXt	NameErrortrangeRtssl_match_hostnameR
tSSLCertificateErrortbackports.ssl_match_hostnamet	backportsRtPurposetSERVER_AUTHt_client_ssl_defaultstCLIENT_AUTHt_server_ssl_defaultsRR�t
CERT_REQUIREDR�R�twhereR�RR�tencodetEWOULDBLOCKtEAGAINR[RRYRRIRWRgRqRrRRuR�R�t	frozensett_SSL_CONTEXT_KEYWORDSR�R�(((s5/usr/lib64/python2.7/site-packages/tornado/netutil.pyt<module>s�"


	

	
			O-	2)
&	!

Zerion Mini Shell 1.0