From 2a235fb0e24d31bcd0e09be5518c67dcb41ecd2f Mon Sep 17 00:00:00 2001 From: Curtis Castrapel Date: Fri, 30 Nov 2018 12:44:52 -0800 Subject: [PATCH] Prefer DNS provider with longest matching zone --- lemur/plugins/lemur_acme/plugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lemur/plugins/lemur_acme/plugin.py b/lemur/plugins/lemur_acme/plugin.py index 26ca8ffc..66295ed2 100644 --- a/lemur/plugins/lemur_acme/plugin.py +++ b/lemur/plugins/lemur_acme/plugin.py @@ -215,12 +215,18 @@ class AcmeHandler(object): :return: dns_providers: List of DNS providers that have the correct zone. """ self.dns_providers_for_domain[domain] = [] + match_length = 0 for dns_provider in self.all_dns_providers: if not dns_provider.domains: continue for name in dns_provider.domains: if domain.endswith("." + name): - self.dns_providers_for_domain[domain].append(dns_provider) + if len(name) > match_length: + self.dns_providers_for_domain[domain] = [dns_provider] + match_length = len(name) + elif len(name) == match_length: + self.dns_providers_for_domain[domain].append(dns_provider) + return self.dns_providers_for_domain def finalize_authorizations(self, acme_client, authorizations):