mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Bump dnspython from 2.2.1 to 2.3.0 (#1975)
* Bump dnspython from 2.2.1 to 2.3.0 Bumps [dnspython](https://github.com/rthalley/dnspython) from 2.2.1 to 2.3.0. - [Release notes](https://github.com/rthalley/dnspython/releases) - [Changelog](https://github.com/rthalley/dnspython/blob/master/doc/whatsnew.rst) - [Commits](https://github.com/rthalley/dnspython/compare/v2.2.1...v2.3.0) --- updated-dependencies: - dependency-name: dnspython dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update dnspython==2.3.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
6910079330
commit
32c06a8b72
137 changed files with 7699 additions and 4277 deletions
|
@ -17,13 +17,15 @@
|
|||
|
||||
"""A place to store TSIG keys."""
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
import base64
|
||||
|
||||
import dns.name
|
||||
import dns.tsig
|
||||
|
||||
|
||||
def from_text(textring):
|
||||
def from_text(textring: Dict[str, Any]) -> Dict[dns.name.Name, dns.tsig.Key]:
|
||||
"""Convert a dictionary containing (textual DNS name, base64 secret)
|
||||
pairs into a binary keyring which has (dns.name.Name, bytes) pairs, or
|
||||
a dictionary containing (textual DNS name, (algorithm, base64 secret))
|
||||
|
@ -32,16 +34,16 @@ def from_text(textring):
|
|||
|
||||
keyring = {}
|
||||
for (name, value) in textring.items():
|
||||
name = dns.name.from_text(name)
|
||||
kname = dns.name.from_text(name)
|
||||
if isinstance(value, str):
|
||||
keyring[name] = dns.tsig.Key(name, value).secret
|
||||
keyring[kname] = dns.tsig.Key(kname, value).secret
|
||||
else:
|
||||
(algorithm, secret) = value
|
||||
keyring[name] = dns.tsig.Key(name, secret, algorithm)
|
||||
keyring[kname] = dns.tsig.Key(kname, secret, algorithm)
|
||||
return keyring
|
||||
|
||||
|
||||
def to_text(keyring):
|
||||
def to_text(keyring: Dict[dns.name.Name, Any]) -> Dict[str, Any]:
|
||||
"""Convert a dictionary containing (dns.name.Name, dns.tsig.Key) pairs
|
||||
into a text keyring which has (textual DNS name, (textual algorithm,
|
||||
base64 secret)) pairs, or a dictionary containing (dns.name.Name, bytes)
|
||||
|
@ -49,17 +51,19 @@ def to_text(keyring):
|
|||
@rtype: dict"""
|
||||
|
||||
textring = {}
|
||||
|
||||
def b64encode(secret):
|
||||
return base64.encodebytes(secret).decode().rstrip()
|
||||
|
||||
for (name, key) in keyring.items():
|
||||
name = name.to_text()
|
||||
tname = name.to_text()
|
||||
if isinstance(key, bytes):
|
||||
textring[name] = b64encode(key)
|
||||
textring[tname] = b64encode(key)
|
||||
else:
|
||||
if isinstance(key.secret, bytes):
|
||||
text_secret = b64encode(key.secret)
|
||||
else:
|
||||
text_secret = str(key.secret)
|
||||
|
||||
textring[name] = (key.algorithm.to_text(), text_secret)
|
||||
textring[tname] = (key.algorithm.to_text(), text_secret)
|
||||
return textring
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue