3 گay;@sjdZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z dd l m Z dd l m Z dd lmZddlmZddlmZejeZdEe jeeejeee jdddZdFe jeeejeee jdddZdGe jeeejeee jdddZ e jejee jdddZ!e de jdZ"e jeeejeeeee"dd d!Z#eej$eeej$d"d#d$Z%d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5gZ&e jejee jee jdd6d7d8Z'e jejeeee jee jfd9d:d;Z(eeeeeed<d=d>Z)e jeeeeefd?d@dAZ*eeeejddBdCdDZ+dS)Hz=Decide which plugins to use for authentication & installationN)cast)Iterable)List)Optional)Tuple)Type)TypeVar) configuration)errors) interfaces)disco)os)utilBsz*get_unprepared_installer..zfFound multiple installers with the name %s, Certbot is unable to determine which one to use. Skipping.rzSelecting plugin: %sz:Could not select or initialize the requested installer %s.) cli_plugin_requestsfilterinitverifyr rlenr PluginSelectionErrorlistvaluesloggerdebug)rr_Z installersinstr)r!rget_unprepared_installer2s     r0P)Zbound)rrrrifacesrc sdk r|jfdd}n|jr,tjd|jj|}|j||j|}|j|j }t |dkrt j d|t t|j|}|dkrdStt|jSt |dkrt|jd} t j d| | jrdS| jSt j d dSdS) aPick plugin. :param certbot.configuration.NamespaceConfig config: Configuration :param str default: Plugin name supplied by user or ``None``. :param certbot._internal.plugins.disco.PluginsRegistry plugins: All plugins registered as entry points. :param str question: Question to be presented to the user in case multiple candidates are found. :param list ifaces: Interfaces that plugins must provide. :returns: Initialized plugin. :rtype: Plugin Ncs |jS)N)r)r )rrrr"gszpick_plugin..aMissing command line flags. For non-interactive execution, you will need to specify a plugin on the command line. Run with '--help plugins' to see a list of options, and see https://eff.org/letsencrypt-plugins for more detail on what the plugins do and how to use them.r#zMultiple candidate plugins: %srzSingle candidate plugin: %szNo candidate plugin)r%Znoninteractive_moder MissingCommandlineFlagZvisibler2r&r'prepareZ availabler(r,r- choose_pluginr*r+rr1 misconfigured) rrrrr2ZfilteredZverifiedpreparedZ plugin_ep1Z plugin_ep2r)rrrTs0       r)r7rrcCshdd|D}xTtj||dd\}}|tjkr\||}|jrVtjdj|jddq`|SqdSqWdS) zAllow the user to choose their plugin. :param list prepared: List of `~.PluginEntryPoint`. :param str question: Question to be presented to the user. :returns: Plugin entry point chosen by the user. :rtype: `~.PluginEntryPoint` cSs g|]}|j|jrdndqS)z [Misconfigured])Zdescription_with_namer6).0 plugin_eprrr sz!choose_plugin..T)Zforce_interactivezxThe selected plugin encountered an error while parsing your server configuration and cannot be used. The error was: {0}F)pauseN) display_utilZmenuZOKr6Z notificationformatr4)r7rZoptscodeindexr:rrrr5s  r5webrootmanual standalonezdns-cloudflarez dns-cloudxnszdns-digitaloceanz dns-dnsimplezdns-dnsmadeeasyz dns-gehirnz dns-googlez dns-linodez dns-luadnsz dns-nsonezdns-ovhz dns-rfc2136z dns-route53zdns-sakuracloud)rrauthr/rcCsVd|_|r |j|}|r |j|_d|_|r@|j|}|r@|j|_tjd|j|jdS)zFUpdate the config entries to reflect the plugins we actually selected.Nz0Plugins selected: Authenticator %s, Installer %s) authenticatorZ find_initname installerr,info)rrrDr/Zauth_epZinst_eprrrrecord_chosen_pluginss  rI)rrverbrc Cs\t|\}}d}|dkrd}|dkrbd}}ddlm}|tkrj| rjdj|tj|} tj| nd }}|d krxd}n|dkrd}|j rt j d |d } d } |dkr||krt |||} t ttj| } t ttj| } n(|s|rt||||} |rt|||} t jd| | |r,| r,td|||rF| rFtd||t||| | | | fS)a< Figure out which configurator we're going to use, modifies config.authenticator and config.installer strings to reflect that choice if necessary. :raises errors.PluginSelectionError if there was a problem :returns: tuple of (`Installer` or None, `Authenticator` or None) :rtype: tuple r8enhancezMWhich installer would you like to use to configure the selected enhancements?ZrunTr) cli_commandzWith the {0} plugin, you probably want to use the "certonly" command, eg:{1}{1} {2} certonly --{0}{1}{1}(Alternatively, add a --installer flag. See https://eff.org/letsencrypt-plugins{1} and "--help plugins" for more information.)FZcertonlyinstallzRSpecifying an authenticator doesn't make sense when running Certbot with verb "%s"Nz*Selected authenticator %s and installer %srGrE)rMrK)r$certbot._internal.clirLnoninstaller_pluginsr>r linesepr r3rEr,Zwarningrrrr rrrrr-diagnose_configurator_problemrI) rrrJreq_authr!Zinstaller_questionZ need_instZ need_authrLmsgrErG configuratorrrrchoose_configurator_pluginssH        rU) previouslynowrcCs6|s|S|r2||kr2d}tj|jt|t||S)z Setting configurators multiple ways is okay, as long as they all agree :param str previously: previously identified request for the installer/authenticator :param str now: the request currently being processed zIToo many flags setting configurators/installers/authenticators {0} -> {1})r r)r>repr)rVrWrSrrrset_configuratorsrY)rrcCs|j}}t||j}t||j}|jrt|d}|jrPt|d}|jrbt|d}|jrtt|d}tjd||||fS)z Figure out which plugins the user requested with CLI and config options :returns: (requested authenticator string or None, requested installer string or None) :rtype: tuple nginxapacherCrArBzdns-cloudflarez dns-cloudxnszdns-digitaloceanz dns-dnsimplezdns-dnsmadeeasyz dns-gehirnz dns-googlez dns-linodez dns-luadnsz dns-nsonezdns-ovhz dns-rfc2136z dns-route53zdns-sakuracloudz+Requested authenticator %s and installer %s)rTrYrGrErZr[rCrArBZdns_cloudflareZ dns_cloudxnsZdns_digitaloceanZ dns_dnsimpleZdns_dnsmadeeasyZ dns_gehirnZ dns_googleZ dns_linodeZ dns_luadnsZ dns_nsoneZdns_ovhZ dns_rfc2136Z dns_route53Zdns_sakuracloudr,r-)rr!rRrrrr$sZ                        r$)cfg_type requestedrrcCsd|r,||krdj|}qVdj|||j}n*|dkrLddlm}dj|}n dj|}tj|dS) a> Raise the most helpful error message about a plugin being unavailable :param str cfg_type: either "installer" or "authenticator" :param str requested: the plugin that was requested :param .PluginsRegistry plugins: available plugins :raises error.PluginSelectionError: if there was a problem z8The requested {0} plugin does not appear to be installedzkThe {0} plugin is not working; there may be problems with your existing configuration. The error was: {1!r}rGr)rLzCertbot doesn't know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run "{0} certonly" to do so. You'll need to manually configure your web server to use the resulting certificate.z/{0} could not be determined or is not installedN)r>ZproblemrNrLr r))r\r]rrSrLrrrrQPs    rQ)r)r)r),__doc__ZloggingZtypingrrrrrrrZcertbotr r r Zcertbot._internal.pluginsr Zcertbot.compatr Zcertbot.displayrr=Z getLogger__name__r,ZNamespaceConfigstrZPluginsRegistryZPluginrrrrrr0r1rZPluginEntryPointr5rOrIrUrYr$rQrrrrsZ                6    B7