From 5b498310b0a369c08b8317edafc0afb8df545a36 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Mon, 5 Apr 2021 18:01:35 +0200 Subject: [PATCH] Use short name for modules + reformat --- main.py | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 79d2be9..b16c526 100644 --- a/main.py +++ b/main.py @@ -53,7 +53,7 @@ def soa_handler(zone, records): soa = zone["soa"] records["@"].append( - dns.rdtypes.ANY.SOA.SOA( + SOA.SOA( dns.rdataclass.IN, dns.rdatatype.SOA, format_mname(soa["name"]), @@ -73,7 +73,11 @@ def originv4_handler(zone, records): ipv4_addr = zone["originv4"]["ipv4"] records["@"].append( - dns.rdtypes.IN.A.A(dns.rdataclass.IN, dns.rdatatype.A, ipv4_addr) + A.A( + dns.rdataclass.IN, + dns.rdatatype.A, + ipv4_addr + ) ) @@ -83,8 +87,10 @@ def originv6_handler(zone, records): ipv6_addr = zone["originv6"] # Yes, re2o is this weird and inconsistent records["@"].append( - dns.rdtypes.IN.AAAA.AAAA( - dns.rdataclass.IN, dns.rdatatype.AAAA, ipv6_addr + AAAA.AAAA( + dns.rdataclass.IN, + dns.rdatatype.AAAA, + ipv6_addr ) ) @@ -97,7 +103,11 @@ def ns_records_handler(zone, records): target = record["target"] records["@"].append( - dns.rdtypes.ANY.NS.NS(dns.rdataclass.IN, dns.rdatatype.NS, target) + NS.NS( + dns.rdataclass.IN, + dns.rdatatype.NS, + target + ) ) @@ -114,7 +124,7 @@ def sshfp_record_handler(zone, records): fingerprint = fp["hash"][fp_type] records[record["hostname"]].append( - dns.rdtype.ANY.SSHFP.SSHFP( + SSHFP.SSHFP( dns.rdataclass.IN, dns.rdatatype.SSHFP, algorithm, @@ -132,8 +142,11 @@ def mx_records_handler(zone, records): exchange = record["target"] records["@"].append( - dns.rdtype.ANY.MX.MX( - dns.rdataclass.IN, dns.rdatatype.MX, preference, priority + MX.MX( + dns.rdataclass.IN, + dns.rdatatype.MX, + preference, + priority ) ) @@ -146,8 +159,10 @@ def txt_records_handler(zone, records): name = record["field1"] records[name].append( - dns.rdtypes.ANY.TXT.TXT( - dns.rdataclass.IN, dns.rdatatype.TXT, record["field2"] + TXT.TXT( + dns.rdataclass.IN + dns.rdatatype.TXT + record["field2"] ) ) @@ -161,13 +176,13 @@ def srv_records_handler(zone, records): name_key = name.to_text() records[name_key].append( - dns.rdtypes.IN.SRV.SRV( + SRV.SRV( dns.rdataclass.IN, dns.rdatatype.SRV, record["priority"], record["weight"], record["port"], - record["target"], + record["target"] ) ) @@ -180,10 +195,10 @@ def a_records_handler(zone, records): ipv4_addr = record["ipv4"] records[record["hostname"]].append( - dns.rdtypes.IN.A.A( + A.A( dns.rdataclass.IN, dns.rdatatype.A, - ipv4_addr, + ipv4_addr ) ) @@ -196,10 +211,10 @@ def aaaa_records_handler(zone, records): ipv6_addr = record["ipv6"] records[record["hostname"]].append( - dns.rdtypes.IN.AAAA.AAAA( + AAAA.AAAA( dns.rdataclass.IN, dns.rdatatype.AAAA, - ipv6_addr, + ipv6_addr ) )