From 5519c4868e0e20b1954402d58693b4f13ae83f37 Mon Sep 17 00:00:00 2001
From: Lars Beckers <lars.beckers@rwth-aachen.de>
Date: Tue, 22 Sep 2020 18:05:39 +0200
Subject: [PATCH] add new exclusion mechanism

Using option named "unmerged" one can now ignore host names before they
are merged as being the same host. This concerns especially hosts with
multiple A records, e.g. for load balancing. This resolves situations
where a shared entry would merge different hosts, but other exclusion
mechanisms would only be able to ignore the whole set of hosts.
---
 generate.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/generate.py b/generate.py
index 4cbab19..b06bdce 100755
--- a/generate.py
+++ b/generate.py
@@ -74,6 +74,8 @@ def retrieve_hosts():
             # TODO AAAA records (and others)
             for (name, ttl, rdata) in z.iterate_rdatas('A'):
                 host = h.get(name)
+                if name in [s.strip() for s in config['excludes']['unmerged'].split(',')]:
+                    continue
                 if host is None:
                     host = []
                     h[name] = host
@@ -83,6 +85,8 @@ def retrieve_hosts():
                     i[rdata.address] = addr
                 addr.append(name)
             for (name, ttl, rdata) in z.iterate_rdatas('CNAME'):
+                if name in [s.strip() for s in config['excludes']['unmerged'].split(',')]:
+                    continue
                 target = h.get(rdata.target)
                 if target is None:
                     target = []
@@ -93,6 +97,8 @@ def retrieve_hosts():
                 if line.startswith('#') or len(line.strip()) < 3:
                     continue
                 parts = line.split()
+                if parts[1] in [s.strip() for s in config['excludes']['unmerged'].split(',')]:
+                    continue
                 addr = i.get(parts[0])
                 if addr is None:
                     addr = []
-- 
GitLab