From 82dacb72c2496a3ea9fda7a2dcb9df6c49e528d9 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Tue, 7 Mar 2023 12:13:21 +0100 Subject: [PATCH] Add suport for _acm-challenge --- src/hostinfo/named.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/hostinfo/named.py b/src/hostinfo/named.py index 46b4eb7..89ad26c 100755 --- a/src/hostinfo/named.py +++ b/src/hostinfo/named.py @@ -360,6 +360,12 @@ def generate_forward(tree, hosts, domains): for c in tree._subnet_._cname_: result[c.domain[1]].add_host(c.alias[0], c.ttl[0], 'CNAME', c.name[0]) pass + + # Add _acme-challenge cname's + for domain, name, ttl, cname in acme_challenge_cname(tree): + result[domain].add_host('_acme-challenge.%s' % name, ttl, 'CNAME', cname) + pass + # Add mx hosts for m in tree._host_._interface_._mailhost_: # Force generation of domain file even if only mailhost present @@ -505,4 +511,16 @@ def get_hosts(tree, with_alias=True): pass return result - +def acme_challenge_cname(tree): + for acme in tree._host_._interface_._acme_: + for ip in util.chain(acme._parent._ip_, acme._parent._ipv6_): + address = util.address(ip) + subnet = util.subnet(tree, address) + for name, ttl in util.chain([ (ip.name[0:], ip.ttl[0:]) ], + [ (a.name[0:], a.ttl[0:]) for a in ip._alias_ ]): + yield subnet.domain[0:], name, ttl, acme.challenge[0] + pass + pass + pass + pass + -- GitLab