diff --git a/main.py b/main.py index a4e10fc..e1a4829 100755 --- a/main.py +++ b/main.py @@ -33,6 +33,7 @@ template_a = "{hostname} IN A {ipv4}" template_aaaa = "{hostname} IN AAAA {ipv6}" template_cname = "{hostname} IN CNAME {alias}." template_ptr = "{target} IN PTR {hostname}." +template_sshfp = "{hostname} SSHFP {algo} {type} {fp}" template_zone = ("$TTL 2D\n" "{soa}\n" @@ -42,6 +43,9 @@ template_zone = ("$TTL 2D\n" "\n" "{ns_records}\n" "\n" + "{fp_records}\n" + "\n" + "{ns_records}\n" "{mx_records}\n" "\n" "{txt_records}\n" @@ -104,7 +108,16 @@ def write_dns_files(api_client): template_ns.format(target=x['target']) for x in zone['ns_records'] ) + + fp_records = "\n".join( + template_sshfp.format(hostname=host['hostname'], algo=fp['algo_id'], type="1", fp=fp['hash']['1'] ) + + "\n" + + template_sshfp.format(hostname=host['hostname'], algo=fp['algo_id'], type="2", fp=fp['hash']['2'] ) + for host in zone['sshfp_records'] + for fp in host['sshfp'] + ) + mx_records = "\n".join( template_mx.format(priority=x['priority'], target=x['target']) @@ -153,6 +166,7 @@ def write_dns_files(api_client): originv4=originv4, originv6=originv6, ns_records=ns_records, + fp_records=fp_records, mx_records=mx_records, txt_records=txt_records, srv_records=srv_records,