From bd2d964743d9bb0593d737de9630cbcc858b0ccf Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 1 Jan 2015 23:00:42 +0100 Subject: [PATCH 1/1] add DKIM helper --- zone.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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) -- 2.30.2