From 474e851faa5a89800dfbf7b6a839cff697ae3a87 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 1 Jan 2015 22:49:10 +0100 Subject: [PATCH] add support for TXT records --- zone.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zone.py b/zone.py index d7c23ff..473b79f 100644 --- a/zone.py +++ b/zone.py @@ -134,6 +134,21 @@ class MX: return zone.RR(owner, 'MX', '{0} {1}'.format(self._priority, zone.abs_hostname(self._name))) +class TXT: + def __init__(self, name: str, text: str) -> None: + # test for bad characters + for c in ('\n', '\r', '\t'): + if c in text: + raise Exception("TXT record {0} containts invalid character") + # escape text + for c in ('\\', '\"'): + text = text.replace(c, '\\'+c) + self._text = text + + def generate_rr(self, owner:str, zone: 'Zone') -> 'Any': + return zone.RR(owner, 'TXT', '"{0}"'.format(self._text)) + + class SRV: def __init__(self, protocol: str, service: str, name: str, port: int, prio: int, weight: int) -> None: self._service = check_label(service) -- 2.30.2