From 46d5dbb07de1377b0e9a9df017f097b1a2bc74eb Mon Sep 17 00:00:00 2001 From: missytake Date: Wed, 20 Dec 2023 16:50:20 +0100 Subject: [PATCH] DNS: nicer output for reverse DNS/PTR records. fixes #143 --- cmdeploy/src/cmdeploy/dns.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cmdeploy/src/cmdeploy/dns.py b/cmdeploy/src/cmdeploy/dns.py index fa530451..ca35bbf8 100644 --- a/cmdeploy/src/cmdeploy/dns.py +++ b/cmdeploy/src/cmdeploy/dns.py @@ -166,17 +166,19 @@ def show_dns(args, out): else: out.green("Great! All your DNS entries are correct.") + to_print = [] if not reverse_ipv4: - print( - f"\nYou should add a PTR/reverse DNS entry for {ipv4}, with the value: {args.config.mail_domain}" - ) - print( - "You can do so at your hosting provider (maybe this isn't your DNS provider)." - ) + to_print.append(f"\tIPv4:\t{ipv4}\t{args.config.mail_domain}") if not reverse_ipv6: - print( - f"\nYou should add a PTR/reverse DNS entry for {ipv6}, with the value: {args.config.mail_domain}" - ) + to_print.append(f"\tIPv6:\t{ipv6}\t{args.config.mail_domain}") + if len(to_print) > 0: + if len(to_print) == 1: + warning = "You should add the following PTR/reverse DNS entry:" + else: + warning = "You should add the following PTR/reverse DNS entries:" + out.red(warning) + for entry in to_print: + print(entry) print( "You can do so at your hosting provider (maybe this isn't your DNS provider)." )