From: Ralf Jung Date: Thu, 1 Jan 2015 22:00:42 +0000 (+0100) Subject: add DKIM helper X-Git-Url: https://git.ralfj.de/zonemaker.git/commitdiff_plain/bd2d964743d9bb0593d737de9630cbcc858b0ccf?ds=sidebyside;hp=6eba900abc6dc54d9ef740090d4522ee80b62ef6 add DKIM helper --- diff --git a/zone.py b/zone.py index 68a82b3..dce8b43 100644 --- a/zone.py +++ b/zone.py @@ -135,7 +135,7 @@ class MX: class TXT: - def __init__(self, name: str, text: str) -> None: + def __init__(self, text: str) -> None: # test for bad characters for c in ('\n', '\r', '\t'): if c in text: @@ -149,6 +149,24 @@ class TXT: return zone.RR(owner, 'TXT', '"{0}"'.format(self._text)) +class DKIM(TXT): # helper class to treat DKIM more antively + class Version: + DKIM1 = "DKIM1" + + class Algorithm: + RSA = "rsa" + + def __init__(self, selector, version, alg, key): + self._selector = check_label(selector) + version = check_label(version) + alg = check_label(alg) + key = check_key(key) + super(self).__init__("v={0}; k={1}; p={2}".format(version, alg, key)) + + def generate_rr(self, owner, zone): + return super(self).generate_rr('{0}._domainkey.{1}'.format(self._selector, owner), zone) + + class SRV: def __init__(self, protocol: str, service: str, name: str, port: int, prio: int, weight: int) -> None: self._service = check_label(service)