Merge remote-tracking branch 'alex/user-agent-python-version' into more-ua

This commit is contained in:
Peter Eckersley
2017-03-15 17:51:34 -07:00
2 changed files with 9 additions and 5 deletions
+3 -2
View File
@@ -1082,8 +1082,9 @@ def _create_subparsers(helpful):
helpful.add( helpful.add(
None, "--user-agent", default=None, None, "--user-agent", default=None,
help="Set a custom user agent string for the client. User agent strings allow " help="Set a custom user agent string for the client. User agent strings allow "
"the CA to collect high level statistics about success rates by OS and " "the CA to collect high level statistics about success rates by OS, "
"plugin. If you wish to hide your server OS version from the Let's " "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 "". ' 'Encrypt server, set this to "". '
'(default: {0})'.format(sample_user_agent())) '(default: {0})'.format(sample_user_agent()))
helpful.add("certonly", helpful.add("certonly",
+6 -3
View File
@@ -1,6 +1,7 @@
"""Certbot client API.""" """Certbot client API."""
import logging import logging
import os import os
import platform
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric import rsa
@@ -52,10 +53,11 @@ def determine_user_agent(config):
""" """
if config.user_agent is None: if config.user_agent is None:
auto = "" if cli.cli_command == "certbot" else "auto" auto = "no" if cli.cli_command == "certbot" else "yes"
ua = "CertbotACMEClient{4}/{0} ({1}) Authenticator/{2} Installer/{3}" ua = "CertbotACMEClient/{0} ({1}) Authenticator/{2} Installer/{3} Verb/{4} Auto/{5} Py/{6}"
ua = ua.format(certbot.__version__, util.get_os_info_ua(), ua = ua.format(certbot.__version__, util.get_os_info_ua(),
config.authenticator, config.installer, auto) config.authenticator, config.installer, config.verb, auto,
platform.python_version())
else: else:
ua = config.user_agent ua = config.user_agent
return ua return ua
@@ -68,6 +70,7 @@ def sample_user_agent():
self.authenticator = "XXX" self.authenticator = "XXX"
self.installer = "YYY" self.installer = "YYY"
self.user_agent = None self.user_agent = None
self.verb = "SUBCOMMAND"
return determine_user_agent(DummyConfig()) return determine_user_agent(DummyConfig())