Skip to content

Commit 1fee90e

Browse files
committed
dns: warn if mail_domain is an IP, instead of checking DNS
1 parent 8cec0c9 commit 1fee90e

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

cmdeploy/src/cmdeploy/cmdeploy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def dns_cmd_options(parser):
147147

148148
def dns_cmd(args, out):
149149
"""Check DNS entries and optionally generate dns zone file."""
150+
if is_valid_ipv4(args.config.mail_domain):
151+
print(f"[WARNING] {args.config.mail_domain} is not a domain, skipping DNS checks.")
152+
return 0
150153
ssh_host = args.ssh_host if args.ssh_host else args.config.mail_domain
151154
sshexec = get_sshexec(ssh_host, verbose=args.verbose)
152155
tls_cert_mode = args.config.tls_cert_mode

cmdeploy/src/cmdeploy/tests/test_cmdeploy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def test_init_not_overwrite(self, capsys, tmp_path, monkeypatch):
3939
out, err = capsys.readouterr()
4040
assert "deleting config file" in out.lower()
4141

42+
def test_dns_skip_on_ip(self, capsys):
43+
parser = get_parser()
44+
parser.parse_args([])
45+
assert main(["init", "1.3.3.7"]) == 0
46+
assert main(["dns"]) == 0
47+
out, err = capsys.readouterr()
48+
assert out == "[WARNING] 1.3.3.7 is not a domain, skipping DNS checks.\n"
49+
4250

4351
def test_www_folder(example_config, tmp_path):
4452
reporoot = importlib.resources.files(__package__).joinpath("../../../../").resolve()

0 commit comments

Comments
 (0)