Add _comment_spaced_block

This commit is contained in:
Brad Warren 2016-07-15 09:25:12 -07:00
parent 9c915b0ae4
commit dbb2398270
2 changed files with 14 additions and 1 deletions

View file

@ -4,5 +4,4 @@ ssl_session_timeout 1440m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# Using list of ciphers from "Bulletproof SSL and TLS"
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-SHA ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA256 ECDHE-ECDSA-AES256-SHA384 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES128-SHA ECDHE-RSA-AES128-SHA256 ECDHE-RSA-AES256-SHA384 DHE-RSA-AES128-GCM-SHA256 DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES128-SHA DHE-RSA-AES256-SHA DHE-RSA-AES128-SHA256 DHE-RSA-AES256-SHA256 EDH-RSA-DES-CBC3-SHA";

View file

@ -566,3 +566,17 @@ def _add_directive(block, directive, replace):
directive, block[location]))
else:
block.append(directive)
def _comment_spaced_block(block):
"""Adds a "managed by Certbot" comment to every directive."""
comment = " # managed by Certbot"
indent = 80 - len(comment)
for i, entry in enumerate(block):
if isinstance(entry, list):
line = "".join(entry)
line = "".join(c for c in line if c != "\n")
linelength = len(line)
extra = indent - linelength
if extra < 0:
extra = 0
block[i][-1] += extra * " " + comment