diff --git a/dns_unbound_cache_reader/dns_unbound_cache_reader.py b/dns_unbound_cache_reader/dns_unbound_cache_reader.py index 3d7056ad8bd43c5ee59d3855a3386166de693584..ae973377b96027825904a07083568094cfa4f107 100644 --- a/dns_unbound_cache_reader/dns_unbound_cache_reader.py +++ b/dns_unbound_cache_reader/dns_unbound_cache_reader.py @@ -87,13 +87,13 @@ def update_dns_table( ## Unbound runs on a remote host # SSH connection with remote host ssh_config = Config(overrides={"run": {"hide": True}}) - remote = Connection(host, config=ssh_config) - # Get the DNS cache - result = remote.run(cmd) - dns_cache = result.stdout.strip().split("\n") - # Free resources - del remote - del result + with Connection(host, config=ssh_config) as remote: + # Get the DNS cache + result = remote.run(cmd, warn=True) + if not result.failed: + dns_cache = result.stdout.strip().split("\n") + # Free resources + del result else: # Read DNS cache from file diff --git a/pyproject.toml b/pyproject.toml index b4e13ea753a9c38dfa578a10420cf7cd98f89936..8930789636ead6a062d1d20b9b6c58eedda91ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "dns-unbound-cache-reader" -version = "0.3.0" +version = "0.4.0" description = "Read DNS cache from unbound" readme = "README.md" requires-python = ">=3.8"