fix DKIM record type
authorRalf Jung <post@ralfj.de>
Thu, 1 Jan 2015 22:04:47 +0000 (23:04 +0100)
committerRalf Jung <post@ralfj.de>
Thu, 1 Jan 2015 22:04:47 +0000 (23:04 +0100)
zone.py

diff --git a/zone.py b/zone.py
index dce8b43b1dcde9115de827de1d9afef8651a093b..36dae78df4102c18e987e56059cbcd5910d11df7 100644 (file)
--- a/zone.py
+++ b/zone.py
@@ -56,6 +56,13 @@ def check_hex(data: str) -> str:
         return data
     raise Exception(data+" is not valid hex data")
 
+def check_base64(data: str) -> str:
+    data = str(data)
+    if re.match('^[a-zA-Z0-9+/=]+$', data):
+        return data
+    raise Exception(data+" is not valid hex data")
+
+
 def check_ipv4(address: str) -> str:
     address = str(address)
     if re.match(REGEX_ipv4, address):
@@ -160,11 +167,11 @@ class DKIM(TXT): # helper class to treat DKIM more antively
         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))
+        key = check_base64(key)
+        super().__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)
+        return super().generate_rr('{0}._domainkey.{1}'.format(self._selector, owner), zone)
 
 
 class SRV: