letsdns package¶
Submodules¶
letsdns.action module¶
- class letsdns.action.Action¶
Bases:
ABC
Abstract base class for LetsDNS actions.
- abstract execute(conf: Config, *args, **kwargs) int ¶
Action classes MUST implement this method. Unknown positional and keyword arguments MUST be ignored.
- Args:
conf: Configuration data. args: Positional arguments. kwargs: Keyword arguments.
- classmethod lifecycle(conf: Config, action) int ¶
Invoke the lifecycle methods of a dynamically imported action. The first non-zero method return code will abort execution and will be returned to the caller.
- Args:
conf: Configuration data. action: Action object. Ignored in the default implementation.
- letsdns.action.import_action(class_name: str) Type[Action] ¶
Dynamically import an action class. Raises a TypeError exception if the imported class is not a subclass of ‘Action’.
- Args:
class_name: Fully qualified class name, e.g. “mymodule.actions.SomeAction”.
- letsdns.action.import_class(class_name: str)¶
Dynamically import a Python class. The containing module must be available in PYTHONPATH.
- Args:
class_name: Fully qualified class name, e.g. “mymodule.submodule.MyClass”.
letsdns.configuration module¶
- class letsdns.configuration.Config¶
Bases:
object
Provide access to configuration data.
- dump(destination=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) None ¶
Dump configuration state into a file.
- Args:
destination: File pointer.
- get(name: str, fallback=None) str ¶
Return an optional configuration value or the specified fallback value.
- Args:
name: Option name. fallback: Returned if option is undefined.
- get_domain() str ¶
Return the mandatory ‘domain’ configuration value.
Raise an exception if ‘domain’ is undefined.
- get_mandatory(name: str) str ¶
Return a mandatory configuration value. Raise an exception if option value is undefined.
- Args:
name: Option name.
- get_tcp_ports() List[str] ¶
Return the optional ‘tcp_ports’ configuration value.
- get_ttl() int ¶
Return the ‘ttl’ configuration value (seconds, integer).
- init(filenames=None) None ¶
Initialise object by loading configuration files from disk. Nonexisting or unreadable files are silently ignored.
- Args:
filenames: Either a single string or a list of strings.
- options() List[str] ¶
Return all options in the active section.
- letsdns.configuration.init_logger() None ¶
Initialise logger.
- letsdns.configuration.log_level(default: str = 'ERROR') int ¶
Return logging level, using the LOG_LEVEL environment variable if available.
- Args:
default: The default log level.
letsdns.core module¶
letsdns.crypto module¶
- letsdns.crypto.dane_tlsa_records(cert: Certificate) List[str] ¶
Return list of TLSA record data for the certificate.
- Args:
cert: x509 certificate.
- letsdns.crypto.read_x509_cert(filename: str) Certificate ¶
Read x509 certificate from file.
- letsdns.crypto.sha_digests(something)¶
Generate hexadecimal SHA256 and SHA512 hashes for some data.
letsdns.hetznerapi module¶
- class letsdns.hetznerapi.HetznerApiUpdate¶
Bases:
Action
- cleanup_records(zone_id: str, name: str) bool ¶
Delete existing TLSA records. Returns True to indicate success.
- Args:
zone_id: Parent zone ID. name: DNS record name.
- execute(conf: Config, *args, **kwargs) int ¶
Update DNS record using the Hetzner DNS API. Return 0 to indicate success.
- find_records(zone_id: str, name: str) List[str] | None ¶
Returns matching record ID list for the given zone ID and name, or None in case of errors.
- Args:
zone_id: Parent zone ID. name: DNS record name.
- zone_id(domain: str) str | None ¶
Returns zone ID for the given domain name, or None in case of errors.
- Args:
domain: Domain name, e.g. “example.com”.
letsdns.liveupdate module¶
- class letsdns.liveupdate.DnsLiveUpdate¶
Bases:
Action
- execute(conf: Config, *args, **kwargs) int ¶
Update DNS record using the dnspython library. Return 0 to indicate success.
- classmethod lifecycle(conf: Config, action: Action) int ¶
Invoke the lifecycle methods of a dynamically imported action. The first non-zero method return code will abort execution and will be returned to the caller.
- Args:
conf: Configuration data. action: Action object. Ignored in the default implementation.
letsdns.nsupdate module¶
- class letsdns.nsupdate.NsupdateStdout¶
Bases:
Action
- classmethod lifecycle(conf: Config, action) int ¶
Invoke the lifecycle methods of a dynamically imported action. The first non-zero method return code will abort execution and will be returned to the caller.
- Args:
conf: Configuration data. action: Action object. Ignored in the default implementation.
letsdns.tlsa module¶
- letsdns.tlsa.rdata_action_lifecycle(conf: Config, action: Action) int ¶
Lifecycle method for Rdata-based actions.
letsdns.util module¶
- letsdns.util.getenv(name: str, default=None, debug_env=True)¶
Return environment variable value if available, otherwise return the default value.
- Args:
name: Environment variable name. default: Default value. debug_env: Debug variable name/value.
- letsdns.util.is_sensitive(name: str) bool ¶
Return True if the specified name is considered sensitive.
- letsdns.util.is_truthy(something) bool ¶
Test if ‘something’ represents boolean True.
An object represents True if it is (or can be converted to) a string and said string’s first character, converted to lowercase, is one of: 1, t, y.
- Args:
something: The object to examine.
- letsdns.util.split(source: str) List[str] ¶
Split a string where whitespace or comma occurs. Return empty list for invalid input.
- Args:
source: The string to be split.
Module contents¶
Copyright © 2022-2024 Ralph Seichter
This file is part of LetsDNS.
LetsDNS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
LetsDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with LetsDNS. If not, see <https://www.gnu.org/licenses/>.