mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 08:03:10 +02:00
Fix UA flag setting (and set more of them)
This commit is contained in:
+3
-1
@@ -1108,7 +1108,9 @@ def _create_subparsers(helpful):
|
||||
"plugin and use case, and to know when to deprecate support for past Python "
|
||||
"versions. If you wish to hide this information from the Let's "
|
||||
'Encrypt server, set this to "". '
|
||||
'(default: {0})'.format(sample_user_agent()))
|
||||
'(default: {0}). The flags encoded in the user agent are: '
|
||||
'--duplicate, --force-renew, --allow-subset-of-names, -n, and '
|
||||
'whether any hooks are set.'.format(sample_user_agent()))
|
||||
helpful.add("certonly",
|
||||
"--csr", type=read_file,
|
||||
help="Path to a Certificate Signing Request (CSR) in DER or PEM format."
|
||||
|
||||
+34
-11
@@ -58,27 +58,50 @@ def determine_user_agent(config):
|
||||
auto = cli.cli_command
|
||||
else:
|
||||
auto = "other"
|
||||
flags = "dup" if config.duplicate else ""
|
||||
flags += "force" if config.renew_by_default else ""
|
||||
|
||||
ua = ("CertbotACMEClient/{0} ({1}; {2}) Authenticator/{3} Installer/{4} "
|
||||
"({5}; flags: {6}) Py/{7}")
|
||||
ua = ua.format(certbot.__version__, auto, util.get_os_info_ua(),
|
||||
config.authenticator, config.installer, config.verb, flags,
|
||||
platform.python_version())
|
||||
config.authenticator, config.installer, config.verb,
|
||||
ua_flags(config), platform.python_version())
|
||||
else:
|
||||
ua = config.user_agent
|
||||
return ua
|
||||
|
||||
def ua_flags(config):
|
||||
"Turn some very important CLI flags into clues in the user agent."
|
||||
if isinstance(config, DummyConfig):
|
||||
return "FLAGS"
|
||||
flags = []
|
||||
if config.duplicate:
|
||||
flags.append("dup")
|
||||
if config.renew_by_default:
|
||||
flags.append("frn")
|
||||
if config.allow_subset_of_names:
|
||||
flags.append("asn")
|
||||
if config.noninteractive_mode:
|
||||
flags.append("n")
|
||||
hook_names = ("pre", "post", "renew", "manual_auth", "manual_cleanup")
|
||||
hooks = [getattr(config, h + "_hook") for h in hook_names]
|
||||
if any(hooks):
|
||||
flags.append("hook")
|
||||
return " ".join(flags)
|
||||
|
||||
class DummyConfig(object):
|
||||
"Shim for computing a sample user agent."
|
||||
def __init__(self):
|
||||
self.authenticator = "XXX"
|
||||
self.installer = "YYY"
|
||||
self.user_agent = None
|
||||
self.verb = "SUBCOMMAND"
|
||||
|
||||
def __getattr__(self, name):
|
||||
"Any config properties we might have are None."
|
||||
return None
|
||||
|
||||
def sample_user_agent():
|
||||
"Document what this Certbot's user agent string will be like."
|
||||
class DummyConfig(object):
|
||||
"Shim for computing a sample user agent."
|
||||
def __init__(self):
|
||||
self.authenticator = "XXX"
|
||||
self.installer = "YYY"
|
||||
self.user_agent = None
|
||||
self.verb = "SUBCOMMAND"
|
||||
|
||||
return determine_user_agent(DummyConfig())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user