mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 03:02:15 +02:00
New _get_names approach for nginx test
This commit is contained in:
+7
-20
@@ -125,25 +125,12 @@ def _get_server_root(config):
|
|||||||
|
|
||||||
def _get_names(config):
|
def _get_names(config):
|
||||||
"""Returns all and testable domain names in config"""
|
"""Returns all and testable domain names in config"""
|
||||||
# XXX: This is still Apache-specific
|
|
||||||
all_names = set()
|
all_names = set()
|
||||||
non_ip_names = set()
|
for root, _dirs, files in os.walk(config):
|
||||||
with open(os.path.join(config, "vhosts")) as f:
|
for this_file in files:
|
||||||
for line in f:
|
for line in open(os.path.join(root, this_file)):
|
||||||
# If parsing a specific vhost
|
if line.strip().starts_with("server_name"):
|
||||||
if line[0].isspace():
|
names = line.partition("server_name")[2].rstrip(";")
|
||||||
words = line.split()
|
[all_names.add(n) for n in names.split()]
|
||||||
if words[0] == "alias":
|
non_ip_names = set(n for n in all_names if not util.IP_REGEX.match(n))
|
||||||
all_names.add(words[1])
|
|
||||||
non_ip_names.add(words[1])
|
|
||||||
# If for port 80 and not IP vhost
|
|
||||||
elif words[1] == "80" and not util.IP_REGEX.match(words[3]):
|
|
||||||
all_names.add(words[3])
|
|
||||||
non_ip_names.add(words[3])
|
|
||||||
elif "NameVirtualHost" not in line:
|
|
||||||
words = line.split()
|
|
||||||
if (words[0].endswith("*") or words[0].endswith("80") and
|
|
||||||
not util.IP_REGEX.match(words[1]) and
|
|
||||||
words[1].find(".") != -1):
|
|
||||||
all_names.add(words[1])
|
|
||||||
return all_names, non_ip_names
|
return all_names, non_ip_names
|
||||||
|
|||||||
Reference in New Issue
Block a user