From 693c3f8555f619c0e86e54dfed53d4549d3b2830 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 7 Mar 2026 07:25:14 +0100 Subject: [PATCH] address link2xt comments (zone parsing and turn v0.4 release --- cmdeploy/src/cmdeploy/deployers.py | 8 ++++---- cmdeploy/src/cmdeploy/dns.py | 14 +++++++------- cmdeploy/src/cmdeploy/tests/test_dns.py | 21 +++++++++++++++++++++ cmdeploy/src/cmdeploy/tests/test_lxc.py | 3 --- cmdeploy/src/cmdeploy/tests/test_util.py | 1 - doc/source/lxc.rst | 7 ------- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/cmdeploy/src/cmdeploy/deployers.py b/cmdeploy/src/cmdeploy/deployers.py index c298d803..2bee1784 100644 --- a/cmdeploy/src/cmdeploy/deployers.py +++ b/cmdeploy/src/cmdeploy/deployers.py @@ -343,12 +343,12 @@ class TurnDeployer(Deployer): def install(self): (url, sha256sum) = { "x86_64": ( - "https://github.com/chatmail/chatmail-turn/releases/download/v0.3/chatmail-turn-x86_64-linux", - "841e527c15fdc2940b0469e206188ea8f0af48533be12ecb8098520f813d41e4", + "https://github.com/chatmail/chatmail-turn/releases/download/v0.4/chatmail-turn-x86_64-linux", + "1ec1f5c50122165e858a5a91bcba9037a28aa8cb8b64b8db570aa457c6141a8a", ), "aarch64": ( - "https://github.com/chatmail/chatmail-turn/releases/download/v0.3/chatmail-turn-aarch64-linux", - "a5fc2d06d937b56a34e098d2cd72a82d3e89967518d159bf246dc69b65e81b42", + "https://github.com/chatmail/chatmail-turn/releases/download/v0.4/chatmail-turn-aarch64-linux", + "0fb3e792419494e21ecad536464929dba706bb2c88884ed8f1788141d26fc756", ), }[host.get_fact(facts.server.Arch)] diff --git a/cmdeploy/src/cmdeploy/dns.py b/cmdeploy/src/cmdeploy/dns.py index 2370ef7d..b519e71c 100644 --- a/cmdeploy/src/cmdeploy/dns.py +++ b/cmdeploy/src/cmdeploy/dns.py @@ -9,16 +9,16 @@ def parse_zone_records(text): Skips comment lines (starting with ``;``) and blank lines. Each record line must have the format ``name TTL IN type rdata``. """ - for raw_line in text.strip().splitlines(): + for raw_line in text.splitlines(): line = raw_line.strip() if not line or line.startswith(";"): continue - parts = line.split(None, 4) - if len(parts) < 5: - raise ValueError(f"Bad zone record line: {line}") - name = parts[0].rstrip(".") - # parts[2] is the IN class — ignored - yield name, parts[1], parts[3].upper(), parts[4] + try: + name, ttl, _in, rtype, rdata = line.split(None, 4) + except ValueError: + raise ValueError(f"Bad zone record line: {line!r}") from None + name = name.rstrip(".") + yield name, ttl, rtype.upper(), rdata def get_initial_remote_data(sshexec, mail_domain): diff --git a/cmdeploy/src/cmdeploy/tests/test_dns.py b/cmdeploy/src/cmdeploy/tests/test_dns.py index 8db498af..fc9cd299 100644 --- a/cmdeploy/src/cmdeploy/tests/test_dns.py +++ b/cmdeploy/src/cmdeploy/tests/test_dns.py @@ -125,6 +125,27 @@ class TestPerformInitialChecks: assert not l +def test_parse_zone_records(): + text = """ + ; This is a comment + some.domain. 3600 IN A 1.1.1.1 + + ; Another comment + www.some.domain. 3600 IN CNAME some.domain. + """ + records = list(parse_zone_records(text)) + assert records == [ + ("some.domain", "3600", "A", "1.1.1.1"), + ("www.some.domain", "3600", "CNAME", "some.domain."), + ] + + +def test_parse_zone_records_invalid_line(): + text = "invalid line" + with pytest.raises(ValueError, match="Bad zone record line"): + list(parse_zone_records(text)) + + def parse_zonefile_into_dict(zonefile, mockdns_base, only_required=False): if only_required: # Only take records before the "; Recommended" section diff --git a/cmdeploy/src/cmdeploy/tests/test_lxc.py b/cmdeploy/src/cmdeploy/tests/test_lxc.py index ffc8d3ee..504e1f4a 100644 --- a/cmdeploy/src/cmdeploy/tests/test_lxc.py +++ b/cmdeploy/src/cmdeploy/tests/test_lxc.py @@ -43,7 +43,6 @@ def relay_container(lxc_setup): @pytest.fixture def cmdeploy(): - def run(*args): return subprocess.run( [sys.executable, "-m", "cmdeploy.cmdeploy", *args], @@ -127,7 +126,6 @@ class TestLxcStatus: assert "status" in result.stdout.lower() def test_shows_containers(self, lxc_setup, capsys): - class QuietOut: def red(self, msg, **kw): pass @@ -142,7 +140,6 @@ class TestLxcStatus: assert "running" in captured def test_deploy_freshness(self, ix, monkeypatch): - ct = ix.get_container("x") monkeypatch.setattr( diff --git a/cmdeploy/src/cmdeploy/tests/test_util.py b/cmdeploy/src/cmdeploy/tests/test_util.py index 486186c7..e2fa45d9 100644 --- a/cmdeploy/src/cmdeploy/tests/test_util.py +++ b/cmdeploy/src/cmdeploy/tests/test_util.py @@ -1,4 +1,3 @@ - from cmdeploy.util import collapse, get_git_hash, get_version_string, shell diff --git a/doc/source/lxc.rst b/doc/source/lxc.rst index ce4535d1..54621223 100644 --- a/doc/source/lxc.rst +++ b/doc/source/lxc.rst @@ -279,10 +279,3 @@ deployment in several ways: These are not globally routable, but are sufficient for testing IPv6 service binding (Postfix, Dovecot, Nginx) and DNS AAAA records inside the local environment. test1 runs with ``disable_ipv6 = True`` to exercise the IPv4-only deployment path. - -**TURN server does not start**: - ``chatmail-turn`` discovers its listen addresses by enumerating globally routable IPs but - LXC containers only have private RFC 1918 addresses (``10.x.x.x``), - so the address list is empty and the server exits immediately. - `PR #11 on chatmail-turn `_ - is meant to fix this.