diff options
| author | Petr Spacek <pspacek@redhat.com> | 2016-03-07 14:10:54 +0100 |
|---|---|---|
| committer | Petr Vobornik <pvoborni@redhat.com> | 2016-04-28 18:46:06 +0200 |
| commit | c7ee765c4de086ac92922519d7065fc6b6796f10 (patch) | |
| tree | 6b6e4846c8973998545c087b9d1c1e9f00f90921 /ipapython | |
| parent | 1df30b4646d0738c5d218acf9f65b6617a970c98 (diff) | |
| download | freeipa-c7ee765c4de086ac92922519d7065fc6b6796f10.tar.gz freeipa-c7ee765c4de086ac92922519d7065fc6b6796f10.tar.xz freeipa-c7ee765c4de086ac92922519d7065fc6b6796f10.zip | |
Add function ipapython.dnsutil.inside_auto_empty_zone()
It allows to test if given DNS name belongs to an automatic empty zone.
https://fedorahosted.org/freeipa/ticket/5710
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipapython')
| -rw-r--r-- | ipapython/dnsutil.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py index e8d2f6ff6..240b7c9cd 100644 --- a/ipapython/dnsutil.py +++ b/ipapython/dnsutil.py @@ -203,3 +203,28 @@ def is_auto_empty_zone(zone): """ assert_absolute_dnsname(zone) return zone in EMPTY_ZONES + + +def inside_auto_empty_zone(name): + """True if specified absolute name is a subdomain of an automatic empty + zone. + + DNS domain is a subdomain of itself so this function + returns True for zone apexes, too. + + >>> inside_auto_empty_zone(DNSName('in-addr.arpa.')) + False + >>> inside_auto_empty_zone(DNSName('10.in-addr.arpa.')) + True + >>> inside_auto_empty_zone(DNSName('1.10.in-addr.arpa.')) + True + >>> inside_auto_empty_zone(DNSName('1.10.in-addr.arpa')) + Traceback (most recent call last): + ... + AssertionError: ... + """ + assert_absolute_dnsname(name) + for aez in EMPTY_ZONES: + if name.is_subdomain(aez): + return True + return False |
