--- a/bin/process-zone Mon Mar 19 10:50:34 2012 +0200
+++ b/bin/process-zone Mon Mar 19 10:58:50 2012 +0200
@@ -286,6 +286,17 @@
def __str__ (self) :
return ' '.join((self.name, self.type, ' '.join(self.data)))
+class TXTRecord (ZoneRecord) :
+ """
+ TXT record.
+ """
+
+ def __init__ (self, name, text, **opts) :
+ return super(TXTRecord, self).__init__(name, 'TXT',
+ [u'"{0}"'.format(text.replace('"', '\\"'))],
+ **opts
+ )
+
def parse_record (path, lineno, line, **opts) :
"""
Parse (name, ttl, type, data, comment) from bind zonefile.
@@ -357,12 +368,24 @@
Process zone data -> forward zone data.
"""
+ TIMESTAMP_FORMAT='%Y/%m/%d'
+
for r in zone :
yield r
if r.type == 'A' :
- if txt and r.line.comment :
- yield ZoneRecord(None, 'TXT', [u'"{0}"'.format(r.line.comment)], ttl=r.ttl)
+ if txt :
+ # comment?
+ comment = r.line.comment
+
+ if comment :
+ yield TXTRecord(None, comment, ttl=r.ttl)
+
+ # timestamp?
+ timestamp = r.line.timestamp
+
+ if timestamp :
+ yield TXTRecord(None, timestamp.strftime(TIMESTAMP_FORMAT), ttl=r.ttl)
# XXX: RP, do we need it?