pvl.hosts-dns: support wildcard --forward-zone
authorTero Marttila <terom@paivola.fi>
Mon, 16 Dec 2013 21:15:42 +0200
changeset 289 b316deddf746
parent 288 2f2f92e4c58e
child 290 9e626c1e935d
pvl.hosts-dns: support wildcard --forward-zone
bin/pvl.hosts-dns
--- a/bin/pvl.hosts-dns	Mon Dec 16 21:15:25 2013 +0200
+++ b/bin/pvl.hosts-dns	Mon Dec 16 21:15:42 2013 +0200
@@ -4,6 +4,7 @@
 import pvl.hosts
 import pvl.dns.zone
 
+import fnmatch
 import ipaddr
 import logging; log = logging.getLogger('pvl.hosts-dns')
 import optparse
@@ -14,7 +15,15 @@
     """
 
     for host in hosts :
-        if options.forward_zone and host.domain != domain :
+        if not options.forward_zone :
+            pass
+        elif host.domain == domain :
+            pass
+        elif pvl.dns.zone.join('*', host.domain) == domain :
+            pass
+        elif fnmatch.fnmatch(host.domain, domain) :
+            pass
+        else :
             continue
         
         if host.ip :