ok

Mini Shell

Direktori : /lib/python3.6/site-packages/acme/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/acme/__pycache__/standalone.cpython-36.pyc

3

گaV3�@srdZddlZddlZddljZddljZddl	Z	ddl
Z
ddlZddlZddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
lmZddlmZddlmZdd
lmZe	je�ZGdd�dej�ZGdd�d�Z Gdd�d�Z!Gdd�dee �Z"Gdd�dej#�Z#Gdd�de#e �Z$Gdd�de!�Z%Gdd�dej&�Z'Gdd�dej(�Z)dS) z1Support for standalone client challenge solvers. �N)�Any)�List)�Mapping)�Optional)�Set)�Tuple)�Type)�crypto)�SSL)�
challenges)�crypto_utilc@s\eZdZdZeedd�dd�Zdd�dd�Zeje	e
je
jfd	�d
d�Z
dd�dd
�ZdS)�	TLSServerzGeneric TLS Server.N)�args�kwargs�returncOsj|jdd�|_|jrtj|_ntj|_|jdi�|_|jdtj�|_	|jdd�|_
tjj
|f|�|�dS)N�ipv6F�certs�method�allow_reuse_addressT)�popr�socket�AF_INET6�address_family�AF_INETrrZ_DEFAULT_SSL_METHODrr�socketserver�	TCPServer�__init__)�selfrr�r� /usr/lib/python3.6/standalone.pyrs
zTLSServer.__init__)rcCs&tj|j|jt|dd�|jd�|_dS)N�_alpn_selection)Zcert_selectionZalpn_selectionr)rZ	SSLSocketr�_cert_selection�getattrr)rrrr�
_wrap_sock*s
zTLSServer._wrap_sock)�
connectionrcCs|j�}|jj|d�S)z.Callback selecting certificate for connection.N)�get_servernamer�get)rr$�server_namerrrr!0szTLSServer._cert_selectioncCs|j�tjj|�S)N)r#rr�server_bind)rrrrr(6szTLSServer.server_bind)�__name__�
__module__�__qualname__�__doc__rrr#r
�
Connectionrr	�PKey�X509r!r(rrrrr
sr
c@seZdZdZdZdZdS)�ACMEServerMixinz"ACME server common settings mixin.z'ACME client standalone challenge solverTN)r)r*r+r,�server_versionrrrrrr0;sr0c@sjeZdZdZeejeee	fe
e
dd�dd�Zdd�dd�Ze
eee	fd�d	d
�Zdd�dd�ZdS)
�BaseDualNetworkedServersaBase class for a pair of IPv6 and IPv4 servers that tries to do everything
       it's asked for both servers, but where failures in one server don't
       affect the other.

       If two servers are instantiated, they will serve on the same port.
       N)�ServerClass�server_address�remaining_argsrrcOs0|d}g|_g|_d}x�d
D]�}y\||d<|df|f|dd�}|f|}	||	|�}
tjd|d|d|rvdnd	�Wnptjk
r�}zR|}|jr�tjd
|d|d|r�dnd	�n tjd|d|d|r�dnd	�WYdd}~XqX|jj|
�|
jj�d}qW|j�s,|�r"|�n
tjd��dS)N�TFrr�z$Successfully bound to %s:%s using %sZIPv6ZIPv4z�Certbot wasn't able to bind to %s:%s using %s, this is often expected due to the dual stack nature of IPv6 socket implementations.z Failed to bind to %s:%s using %szCould not bind to IPv4 or IPv6.)TF)�threads�servers�logger�debugr�error�append�getsockname)rr3r4r5rZportZlast_socket_errZ
ip_versionZnew_addressZnew_args�server�errrrJs:	


&z!BaseDualNetworkedServers.__init__)rcCs6x0|jD]&}tj|jd�}|j�|jj|�qWdS)z*Wraps socketserver.TCPServer.serve_forever)�targetN)r9�	threadingZThread�
serve_forever�startr8r=)rr?�threadrrrrC|s

z&BaseDualNetworkedServers.serve_forevercCsdd�|jD�S)z/Wraps socketserver.TCPServer.socket.getsocknamecSsg|]}|jj��qSr)rr>)�.0r?rrr�
<listcomp>�sz9BaseDualNetworkedServers.getsocknames.<locals>.<listcomp>)r9)rrrr�getsocknames�sz%BaseDualNetworkedServers.getsocknamescCsBx|jD]}|j�|j�qWx|jD]}|j�q(Wg|_dS)zpWraps socketserver.TCPServer.shutdown, socketserver.TCPServer.server_close, and
           threading.Thread.joinN)r9ZshutdownZserver_closer8�join)rr?rErrr�shutdown_and_server_close�sz2BaseDualNetworkedServers.shutdown_and_server_close)r)r*r+r,rrrr�str�intrrrCrrHrJrrrrr2Bs1r2c@s�eZdZdZdZdeeefeee	j
e	jfeeee	j
e	jffe
dd�dd�Zejee	j
e	jfd�d	d
�Zejeeed�dd
�ZdS)�TLSALPN01ServerzTLSALPN01 Server.s
acme-tls/1FN)r4r�challenge_certsrrcCstj||t||d�||_dS)N)rr)r
r�_BaseRequestHandlerWithLoggingrN)rr4rrNrrrrr�szTLSALPN01Server.__init__)r$rcCs|j�}tjd|�|j|S)Nz)Serving challenge cert for server name %s)r%r:r;rN)rr$r'rrrr!�szTLSALPN01Server._cert_selection)�_connection�alpn_protosrcCsBt|�dkr.|d|jkr.tjd|j�|jStjdt|��dS)z!Callback to select alpn protocol.r6rzAgreed on %s ALPNz#Cannot agree on ALPN proto. Got: %s�)�len�ACME_TLS_1_PROTOCOLr:r;rK)rrPrQrrrr �s
zTLSALPN01Server._alpn_selection)F)r)r*r+r,rTrrKrLrr	r.r/r�boolrr
r-r!�bytesr rrrrrM�s
DrMc@s"eZdZdZeedd�dd�ZdS)�
HTTPServerzGeneric HTTP Server.N)rrrcOs>|jdd�|_|jrtj|_ntj|_tjj|f|�|�dS)NrF)	rrrrrr�BaseHTTPServerrWr)rrrrrrr�s

zHTTPServer.__init__)r)r*r+r,rrrrrrrW�srWc@s6eZdZdZdeeefeej	e
edd�dd�ZdS)	�HTTP01ServerzHTTP01 Server.F�N)r4�	resourcesr�timeoutrcCs tj||tj||d�|d�dS)N)�simple_http_resourcesr\)r)rWr�HTTP01RequestHandler�partial_init)rr4r[rr\rrrr�szHTTP01Server.__init__)FrZ)r)r*r+r,rrKrLrr�HTTP01rUrrrrrrY�srYc@s"eZdZdZeedd�dd�ZdS)�HTTP01DualNetworkedServersz`HTTP01Server Wrapper. Tries everything for both. Failures for one don't
       affect the other.N)rrrcOstj|tf|�|�dS)N)r2rrY)rrrrrrr�sz#HTTP01DualNetworkedServers.__init__)r)r*r+r,rrrrrrra�srac@s�eZdZdZejdd�Zeedd�dd�Ze	e
d�d	d
��Zeedd�dd
�Z
dd�dd�Zdd�dd�Zdd�dd�Zdd�dd�Zdd�dd�Zeeeje
dd�dd��ZdS)r^z�HTTP01 challenge handler.

    Adheres to the stdlib's `socketserver.BaseRequestHandler` interface.

    :ivar set simple_http_resources: A set of `HTTP01Resource`
        objects. TODO: better name?

    �HTTP01Resourcezchall response validationN)rrrcOs:|jdt��|_|jdd�|_tjj|f|�|�|dS)Nr]r\rZ)r�setr]�_timeoutrX�BaseHTTPRequestHandlerr)rrrrrrr�szHTTP01RequestHandler.__init__)rcCs|jS)z�
        The default timeout this server should apply to requests.
        :return: timeout to apply
        :rtype: int
        )rd)rrrrr\�szHTTP01RequestHandler.timeout)�formatrrcGstjd|jd||�dS)zLog arbitrary message.z	%s - - %srN)r:r;�client_address)rrfrrrr�log_message�sz HTTP01RequestHandler.log_messagecCs|jd�tjj|�dS)zHandle request.zIncoming requestN)rhrXre�handle)rrrrri�s
zHTTP01RequestHandler.handlecCs>|jdkr|j�n&|jjdtjj�r2|j�n|j�dS)N�/)�path�handle_index�
startswithrr`Z
URI_ROOT_PATH�handle_simple_http_resource�
handle_404)rrrr�do_GETs



zHTTP01RequestHandler.do_GETcCs6|jd�|jdd�|j�|jj|jjj��dS)zHandle index page.��zContent-Typez	text/htmlN)�
send_response�send_header�end_headers�wfile�writer?r1�encode)rrrrrls
z!HTTP01RequestHandler.handle_indexcCs4|jtjdd�|jdd�|j�|jjd�dS)zHandler 404 Not Found errors.z	Not Found)�messagezContent-typez	text/htmls404N)rr�http_clientZ	NOT_FOUNDrsrtrurv)rrrrroszHTTP01RequestHandler.handle_404cCsxxd|jD]P}|jj|jkr|jd|jjd��|jtj�|j�|j	j
|jj��dSqW|jd�|jd|j�dS)z$Handle HTTP01 provisioned resources.zServing HTTP01 with token %r�tokenNzNo resources to servez0%s does not correspond to any resource. ignoring)r]ZchallrkrhrwrrryZOKrtrurvZ
validation)rZresourcerrrrns
z0HTTP01RequestHandler.handle_simple_http_resourcez'functools.partial[HTTP01RequestHandler])r]r\rcCstj|||d�S)z�Partially initialize this handler.

        This is useful because `socketserver.BaseServer` takes
        uninitialized handler and initializes it with the current
        request.

        )r]r\)�	functools�partial)�clsr]r\rrrr_%s
z!HTTP01RequestHandler.partial_init)r)r*r+r,�collections�
namedtuplerbrr�propertyrLr\rKrhrirprlrorn�classmethodrrr`r_rrrrr^�sr^c@s0eZdZdZeedd�dd�Zdd�dd�ZdS)	rOz BaseRequestHandler with logging.N)rfrrcGstjd|jd||�dS)zLog arbitrary message.z	%s - - %srN)r:r;rg)rrfrrrrrh7sz*_BaseRequestHandlerWithLogging.log_message)rcCs|jd�tjj|�dS)zHandle request.zIncoming requestN)rhr�BaseRequestHandlerri)rrrrri;s
z%_BaseRequestHandlerWithLogging.handle)r)r*r+r,rKrrhrirrrrrO4srO)*r,r~r{Zhttp.clientZclientryZhttp.serverr?rXZloggingrrrBZtypingrrrrrrrZOpenSSLr	r
ZacmerrZ	getLoggerr)r:rr
r0r2rMrWrYrarer^r�rOrrrr�<module>s:


 Q%
^

Zerion Mini Shell 1.0