From 85223245e4d9baa51a04fd5fec5d5acf31335c45 Mon Sep 17 00:00:00 2001 From: missytake Date: Thu, 12 Mar 2026 17:47:44 +0100 Subject: [PATCH] cmdeploy: deploy IPv4 relays with brackets --- chatmaild/src/chatmaild/config.py | 7 +++++-- cmdeploy/src/cmdeploy/cmdeploy.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chatmaild/src/chatmaild/config.py b/chatmaild/src/chatmaild/config.py index e0da5559..b31490e0 100644 --- a/chatmaild/src/chatmaild/config.py +++ b/chatmaild/src/chatmaild/config.py @@ -21,7 +21,10 @@ def read_config(inipath): class Config: def __init__(self, inipath, params): self._inipath = inipath - self.mail_domain = params["mail_domain"] + if is_valid_ipv4(params["mail_domain"]): + self.mail_domain = f"[{params.get('mail_domain')}]" + else: + self.mail_domain = params["mail_domain"] self.max_user_send_per_minute = int(params.get("max_user_send_per_minute", 60)) self.max_user_send_burst_size = int(params.get("max_user_send_burst_size", 10)) self.max_mailbox_size = params["max_mailbox_size"] @@ -77,7 +80,7 @@ class Config: ) self.tls_cert_mode = "external" self.tls_cert_path, self.tls_key_path = parts - elif self.mail_domain.startswith("_") or is_valid_ipv4(self.mail_domain): + elif self.mail_domain.startswith("_") or is_valid_ipv4(params["mail_domain"]): self.tls_cert_mode = "self" self.tls_cert_path = "/etc/ssl/certs/mailserver.pem" self.tls_key_path = "/etc/ssl/private/mailserver.key" diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index aace1693..8bd1e0f3 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -87,7 +87,7 @@ def run_cmd_options(parser): def run_cmd(args, out): """Deploy chatmail services on the remote server.""" - ssh_host = args.ssh_host if args.ssh_host else args.config.mail_domain + ssh_host = args.ssh_host if args.ssh_host else args.config.mail_domain.strip("[").strip("]") sshexec = get_sshexec(ssh_host) require_iroh = args.config.enable_iroh_relay strict_tls = args.config.tls_cert_mode == "acme"