Refactor load_pk_from_dns to reduce code duplication between async and non-async.
This commit is contained in:
+7
-2
@@ -425,8 +425,7 @@ def fold(header, namelen=0, linesep=b'\r\n'):
|
||||
return pre + header
|
||||
|
||||
|
||||
def load_pk_from_dns(name, dnsfunc, timeout=5):
|
||||
s = dnsfunc(name, timeout=timeout)
|
||||
def evaluate_pk(name, s):
|
||||
if not s:
|
||||
raise KeyFormatError("missing public key: %s"%name)
|
||||
try:
|
||||
@@ -475,6 +474,12 @@ def load_pk_from_dns(name, dnsfunc, timeout=5):
|
||||
return pk, keysize, ktag, seqtlsrpt
|
||||
|
||||
|
||||
def load_pk_from_dns(name, dnsfunc=get_txt, timeout=5):
|
||||
s = dnsfunc(name, timeout=timeout)
|
||||
pk, keysize, ktag, seqtlsrpt = evaluate_pk(name, s)
|
||||
return pk, keysize, ktag, seqtlsrpt
|
||||
|
||||
|
||||
#: Abstract base class for holding messages and options during DKIM/ARC signing and verification.
|
||||
class DomainSigner(object):
|
||||
# NOTE - the first 2 indentation levels are 2 instead of 4
|
||||
|
||||
Reference in New Issue
Block a user