dnc

CLI tool to check domain names configuration and statistics
Log | Files | Refs | README | LICENSE

commit cc828689b161ddf7d06538207c27dbc424030062
parent 22ef84e592f69692393d467b4024b8fe03ba9ece
Author: Frederic Cambus <fred@statdns.com>
Date:   Tue, 19 Jan 2021 14:41:41 +0100

Refactor things to allow specifying columns in any possible order.

This makes all options opt in, and adds the ability to query for MX
records and to display SSL certificates expiration dates.

Diffstat:
Mdnc.py | 32++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/dnc.py b/dnc.py @@ -44,22 +44,38 @@ def tls(domain: str, _: str) -> str: ).strftime("%Y-%m-%d") +def domain(domain: str, _: str) -> str: + return domain + + def main(): - getv6 = False results = PrettyTable(hrules=1) + header = ["Domain"] + actions = [(domain, None)] + try: - options, args = getopt.getopt(sys.argv[1:], "6v") + options, args = getopt.getopt(sys.argv[1:], "46mnsv") except getopt.GetoptError as err: print(err) sys.exit(1) - header = ["Domain", "NS", "IPv4"] - for option, arg in options: + if option == "-4": + header.append("IPv4") + actions.append((query, 'A')) if option == "-6": header.append("IPv6") - getv6 = True + actions.append((query, 'AAAA')) + if option == "-m": + header.append("MX") + actions.append((query, 'MX')) + if option == "-n": + header.append("NS") + actions.append((query, 'NS')) + if option == "-s": + header.append("TLS") + actions.append((tls, None)) elif option == "-v": print("dnc 0.2.0") sys.exit(0) @@ -68,11 +84,7 @@ def main(): results.align = "l" for name in args: - row = [name, query(name, 'NS'), query(name, 'A')] - - if getv6: - row.append(query(name, 'AAAA')) - + row = [fn(name, action) for fn, action in actions] results.add_row(row) print(results)