client: allow callers to add information to the user agent (#4690)

This change introduces a new flag to allow callers to add information to
the user agent without replacing it entirely.

This allows people re-packaging or wrapping Certbot to influence its user
agent string. They may which to do this so that stats/metrics related to
their distribution are available to boulder.

This is beneficial for both the Certbot team and the party re-packaging
Certbot as it allows the custom user agent to match the Certbot user
agent as closely as possible, allowing data about use of the re-packaged
version to be collected along side or separately from vanilla certbot.
This commit is contained in:
Zach Shepherd
2017-08-01 11:34:35 -07:00
committed by Brad Warren
parent 7461bdbffd
commit 314f4bbe22
2 changed files with 12 additions and 2 deletions
+3 -2
View File
@@ -58,11 +58,12 @@ def determine_user_agent(config):
# policy, talk to a core Certbot team member before making any
# changes here.
if config.user_agent is None:
ua = ("CertbotACMEClient/{0} ({1}; {2}) Authenticator/{3} Installer/{4} "
ua = ("CertbotACMEClient/{0} ({1}; {2}{8}) Authenticator/{3} Installer/{4} "
"({5}; flags: {6}) Py/{7}")
ua = ua.format(certbot.__version__, cli.cli_command, util.get_os_info_ua(),
config.authenticator, config.installer, config.verb,
ua_flags(config), platform.python_version())
ua_flags(config), platform.python_version(),
"; " + config.user_agent_comment if config.user_agent_comment else "")
else:
ua = config.user_agent
return ua