Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/plugins/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyc

�
���_c@s�dZddlZddlZddlZddlmZddlZddlZddlZ	ddl
mZddl
mZ
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZeje�Zer@ee
jeejfZnde
fd��YZ!e	j"j#ej$�e	j"j%ej&�dej'fd��Y��Z(d�Z)dS(sStandalone
Authenticator.i����N(terrno(t
challenges(t
standalone(tDefaultDict(tDict(tSet(tTuple(t
TYPE_CHECKING(tachallenges(terrors(t
interfaces(tcommont
ServerManagercBs5eZdZd�Zdd�Zd�Zd�ZRS(s�Standalone
servers manager.

    Manager for `ACMEServer` and `ACMETLSServer` instances.

    `certs` and `http_01_resources` correspond to
    `acme.crypto_util.SSLSocket.certs` and
    `acme.crypto_util.SSLSocket.http_01_resources` respectively. All
    created servers share the same certificates and resources, so if
    you're running both TLS and non-TLS instances, HTTP01 handlers
    will serve the same URLs!

    cCsi|_||_||_dS(N(t
_instancestcertsthttp_01_resources(tselfRR((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyt__init__-s		tcCs�|tjkst�||jkr/|j|S||f}ytj||j�}Wn(tjk
r~}t	j
||��nX|j�|j�dd}||j|<|S(sRun ACME server on
specified ``port``.

        This method is idempotent, i.e. all calls with the same pair of
        ``(port, challenge_type)`` will reuse the same server.

        :param int port: Port to run the server on.
        :param challenge_type: Subclass of `acme.challenges.Challenge`,
            currently only `acme.challenge.HTTP01`.
        :param str listenaddr: (optional) The address to listen on.
Defaults to all addrs.

        :returns: DualNetworkedServers instance.
        :rtype: ACMEServerMixin

       
ii(
RtHTTP01tAssertionErrorR
tacme_standalonetHTTP01DualNetworkedServersRtsocketterrorR	tStandaloneBindErrort
serve_forevertgetsocknames(Rtporttchallenge_typet
listenaddrtaddresstserversRt	real_port((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytrun2s

cCsP|j|}x(|j�D]}tjd|d
�qW|j�|j|=dS(sWStop ACME server running on the specified
``port``.

        :param int port:

        sStopping server at
%s:%d...iN(R
Rtloggertdebugtshutdown_and_server_close(RRtinstancetsockname((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytstopTs
	
cCs
|jj�S(s�Return all running instances.

        Once the server is stopped using `stop`, it will not be
        returned.

        :returns: Mapping from ``port`` to ``servers``.
        :rtype: tuple

       
(R
tcopy(R((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytrunningas
(t__name__t
__module__t__doc__RR"R(R*(((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyR
s
	"	
t
AuthenticatorcBsteZdZdZd�Zed��Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�ZRS(sStandalone Authenticator.

    This authenticator creates its own ephemeral TCP listener on the
    necessary port in order to respond to incoming http-01
    challenges from the certificate authority. Therefore, it does not
    rely on any existing server program.
    sSpin up a temporary
webservercOs\tt|�j||�tjt�|_i|_t�|_t	|j|j�|_
dS(N(tsuperR.RtcollectionstdefaultdicttsettservedRRRR
(Rtargstkwargs((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyR{s
	cCsdS(N((tclstadd((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytadd_parser_arguments�scCsdS(Ns�This
authenticator creates its own ephemeral TCP listener on the necessary port
in order to respond to incoming http-01 challenges from the certificate
authority. Therefore, it does not rely on any existing server
program.((R((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyt	more_info�scCsdS(N((R((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytprepare�scCs
tjgS(N(RR(Rtdomain((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytget_chall_pref�scCs
g|D]}|j|�^qS(N(t_try_perform_single(Rtachallstachall((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytperform�scCsEx>tr@y|j|�SWqtjk
r<}t|�qXqWdS(N(tTruet_perform_singleR	Rt_handle_perform_error(RR?R((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyR=�s
	cCs-|j|�\}}|j|j|�|S(N(t_perform_http_01R3R7(RR?R
tresponse((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyRB�scCs�|jj}|jj}|jj|tjd|�}|j�\}}tj	j
d|jd|d|�}|jj
|�||fS(NRtchallREt
validation(tconfigthttp01_portthttp01_addressR
R"RRtresponse_and_validationRtHTTP01RequestHandlertHTTP01ResourceRFRR7(RR?RtaddrR
RERGtresource((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyRD�scCs�xJ|jj�D]9\}}x*|D]"}||kr#|j|�q#q#WqWxFtj|jj��D],\}}|j|sf|jj|�qfqfWdS(N(R3titemstremovetsixt	iteritemsR
R*R((RR>tunused_serverstserver_achallsR?RR
((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pytcleanup�s
%
(R+R,R-tdescriptionRtclassmethodR8R9R:R<R@R=RBRDRV(((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyR.ns									
cCs�|jjtjkr3tjdj|j���n|jjtjkr�t	j
jtj
�}dj|j�}|j|dddt�}|s�tj|��q�n|�dS(Ns�Could
not bind TCP port {0} because you don't have the appropriate
permissions (for example, you aren't running this program as
root).s�Could not bind TCP port {0} because it is already in use by
another process on this system (such as a web server). Please stop the
program in question and then try
again.tRetrytCanceltdefault(tsocket_errorRt
socket_errorstEACCESR	tPluginErrortformatRt
EADDRINUSEtzopet	componentt
getUtilityR
tIDisplaytyesnotFalse(Rtdisplaytmsgtshould_retry((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyRC�s(*R-R0tloggingRRR]tOpenSSLRRtzope.interfaceRbtacmeRRRtacme.magic_typingRRRRRtcertbotRR	R
tcertbot.pluginsRt	getLoggerR+R#tBaseDualNetworkedServerst"KeyAuthorizationAnnotatedChallenget
ServedTypetobjectRt	interfacetimplementertIAuthenticatortprovidertIPluginFactorytPluginR.RC(((sH/usr/lib/python2.7/site-packages/certbot/_internal/plugins/standalone.pyt<module>s8NO