Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.10.4: small fixes #2

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions acme-dns-client-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""


__version__ = "0.10.3"
__version__ = "0.10.4"
__author__ = "Matthias \"Maddes\" Bücher"
__license__ = "GPLv2"
__copyright__ = "Copyright (C) 2024 Matthias \"Maddes\" Bücher"
Expand All @@ -36,7 +36,7 @@

### fix script name for argparse output
try:
sys.argv[0] = os.environ["SCRIPT_PATH"]
sys.argv[0] = os.environ["ADC2_PATH"]
except KeyError as e:
pass
### allow local imports from script directory
Expand Down Expand Up @@ -101,8 +101,8 @@ def createArgParser() -> argparse.ArgumentParser:
Client for acme-dns servers. Client can be used with certbot and acme.sh.".format(version=__version__, version2=acmednsclient2.__version__, copyright=__copyright__, homepage=__homepage__)
epilog = "\
First register the domain on the acme-dns server via the `register` command. \
Existing registrations can also be imported into the config via the `add` command.\n\
Then setup the DNS records and verify the setup with the `check` command.\n\
Existing registrations can also be imported via the `add` command.\n\
Then set the DNS records up and verify the setup with the `check` command.\n\
Finally use this script as a certbot plugin via `--manual --preferred-challenges dns --manual-auth-hook '/path/to/{script:s} certbot'` to retrieve a certificate with certbot's `certonly` command.\n\
For acme.sh copy the wrapper script 'dns_acmednsclient2.sh' to '/path/to/acme.sh/dnsapi/' and use it via `--dns dns_acmednsclient2`.".format(script=os.path.basename(sys.argv[0]).replace(".py", ".sh"))

Expand Down
4 changes: 2 additions & 2 deletions acme-dns-client-2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ ! -d "${VENV_PATH}" ]; then
printf -- '%s\n' "--- Initializing Python Virtual Environment at ${VENV_PATH}" 1>&2
RC=0 ; "python${PYTHON_VERSION}" -m venv "${VENV_PATH}" || RC="${?}"
if [ "${RC}" -ne 0 ]; then
printf -- '%s\n' "Failed to setup virtual environment in ${VENV_PATH}." 1>&2
printf -- '%s\n' "Failed to set virtual environment up in ${VENV_PATH}." 1>&2
return "${RC}" 2>/dev/null || exit "${RC}"
fi
fi
Expand Down Expand Up @@ -84,4 +84,4 @@ unset -v PYTHON_VERSION RC SCRIPT_NAME SCRIPT_DIR SCRIPT_PY_NAME VENV_PATH

unset -v CREATE

SCRIPT_PATH="${0}" "${SCRIPT_PY_PATH}" "${@}"
ADC2_PATH="${0}" "${SCRIPT_PY_PATH}" "${@}"
10 changes: 5 additions & 5 deletions acmednsclient2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""


__version__ = "0.10.3"
__version__ = "0.10.4"
__author__ = "Matthias \"Maddes\" Bücher"
__license__ = "GPLv2"
__copyright__ = "Copyright (C) 2024 Matthias \"Maddes\" Bücher"
Expand Down Expand Up @@ -165,7 +165,7 @@ def _loadFromFile(self) -> None:
self._resetWithDefaults()

filedata = None
with open(self._jsonpath, mode="rt") as file:
with open(self._jsonpath, mode="rt", encoding="UTF-8", newline=None) as file:
filedata = json.load(file)

for key, fileconfigdata in filedata.items():
Expand Down Expand Up @@ -257,7 +257,7 @@ def _loadFromFile(self, config:Configuration) -> None:
self.domains.clear()

filedata = None
with open(self._jsonpath, mode="rt") as file:
with open(self._jsonpath, mode="rt", encoding="UTF-8", newline=None) as file:
filedata = json.load(file)

default_server = config.settings[config.ATTR_URL_DEFAULT_SERVER]
Expand Down Expand Up @@ -397,7 +397,7 @@ def save(self) -> None:
filedata = json.dumps(filedata, indent=4, **JSON5_DUMP_KWARGS)

### write JSON string
with open(self._jsonpath, mode="wt") as file:
with open(self._jsonpath, mode="wt", encoding="UTF-8", newline="\n") as file:
file.write(filedata)
# --- /DomainAccounts.save()

Expand Down Expand Up @@ -866,7 +866,7 @@ def _check_txt(cls, accdata:dict, resolve_func:typing.Callable[...,dns.resolver.
### https://dnspython.readthedocs.io/en/stable/resolver-class.html#dns.resolver.Resolver.resolve
dns_answers = resolve_func(qname=accdata[cls.ATTR_DOMAIN_CHALLENGE], rdtype=dns.rdatatype.TXT)
except dns.exception.DNSException as e:
return False, "TXT missing (acme-dns: either DNS (NS, A/AAAA or glue record) or setup (domain not updated once yet? deregistered?)"
return False, "TXT missing (acme-dns: either DNS issue (NS, A/AAAA or glue record) or no token record (domain not updated once yet? deregistered?))"

return True, "TXT available (acme-dns)"
# --- /DomainAccounts._check_txt()
Expand Down