🚨 use black
This commit is contained in:
parent
6d2409b166
commit
0aa88e5347
1 changed files with 29 additions and 34 deletions
63
main.py
63
main.py
|
@ -45,6 +45,7 @@ def format_mname(name: str):
|
||||||
|
|
||||||
return mname
|
return mname
|
||||||
|
|
||||||
|
|
||||||
HANDLERS = {
|
HANDLERS = {
|
||||||
"soa": soa_handler,
|
"soa": soa_handler,
|
||||||
"originv4": originv4_handler,
|
"originv4": originv4_handler,
|
||||||
|
@ -58,12 +59,13 @@ HANDLERS = {
|
||||||
"aaaa_records": aaaa_records_handler,
|
"aaaa_records": aaaa_records_handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def soa_handler(zone, records):
|
def soa_handler(zone, records):
|
||||||
"""Handler for SOA record"""
|
"""Handler for SOA record"""
|
||||||
|
|
||||||
soa = zone['soa']
|
soa = zone["soa"]
|
||||||
|
|
||||||
records['@'].append(
|
records["@"].append(
|
||||||
dns.rdtypes.ANY.SOA.SOA(
|
dns.rdtypes.ANY.SOA.SOA(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN,
|
||||||
dns.rdatatype.SOA,
|
dns.rdatatype.SOA,
|
||||||
|
@ -77,58 +79,50 @@ def soa_handler(zone, records):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def originv4_hanlder(zone, records):
|
def originv4_hanlder(zone, records):
|
||||||
"""Handler for the IPv4 origin"""
|
"""Handler for the IPv4 origin"""
|
||||||
|
|
||||||
ipv4_addr = zone["originv4"]["ipv4"]
|
ipv4_addr = zone["originv4"]["ipv4"]
|
||||||
|
|
||||||
records['@'].append(
|
records["@"].append(
|
||||||
dns.rdtypes.ANY.A.A(
|
dns.rdtypes.ANY.A.A(dns.rdataclass.IN, dns.rdatatypes.A, ipv4_addr)
|
||||||
dns.rdataclass.IN,
|
)
|
||||||
dns.rdatatypes.A,
|
|
||||||
ipv4_addr
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def originv6_handler(zone, records):
|
def originv6_handler(zone, records):
|
||||||
"""Handler for the IPv6 origin"""
|
"""Handler for the IPv6 origin"""
|
||||||
|
|
||||||
ipv6_addr = zone["originv6"] # Yes, re2o is this weird and inconsistent
|
ipv6_addr = zone["originv6"] # Yes, re2o is this weird and inconsistent
|
||||||
|
|
||||||
records['@'].append(
|
records["@"].append(
|
||||||
dns.rdtypes.ANY.AAAA.AAAA(
|
dns.rdtypes.ANY.AAAA.AAAA(dns.rdataclass.IN, dns.rdatatype.AAAA, ipv6_addr)
|
||||||
dns.rdataclass.IN,
|
)
|
||||||
dns.rdatatype.AAAA,
|
|
||||||
ipv6_addr
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def ns_records_handler(zone, records):
|
def ns_records_handler(zone, records):
|
||||||
"""Handler for the NS record"""
|
"""Handler for the NS record"""
|
||||||
|
|
||||||
for record in zone["ns_records"]:
|
for record in zone["ns_records"]:
|
||||||
|
|
||||||
target = record["target"]
|
target = record["target"]
|
||||||
|
|
||||||
records["@"].append(
|
records["@"].append(
|
||||||
dns.rdtypes.ANY.NS.NS(
|
dns.rdtypes.ANY.NS.NS(dns.rdataclass.IN, dns.rdatatype.NS, target)
|
||||||
dns.rdataclass.IN,
|
|
||||||
dns.rdatatype.NS,
|
|
||||||
target
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def sshfp_record_handler(zone, records):
|
def sshfp_record_handler(zone, records):
|
||||||
"""Handler for the SSHFP record"""
|
"""Handler for the SSHFP record"""
|
||||||
|
|
||||||
for record in zone["sshfp"]:
|
for record in zone["sshfp"]:
|
||||||
for fp in record["sshfp"]:
|
for fp in record["sshfp"]:
|
||||||
|
|
||||||
algorithm = fp["algo_id"]
|
algorithm = fp["algo_id"]
|
||||||
|
|
||||||
for fp_type in fp["hash"]:
|
for fp_type in fp["hash"]:
|
||||||
|
|
||||||
fingerprint = fp["hash"][fp_type]
|
fingerprint = fp["hash"][fp_type]
|
||||||
|
|
||||||
records[record["hostname"]].append(
|
records[record["hostname"]].append(
|
||||||
dns.rdtype.ANY.SSHFP.SSHFP(
|
dns.rdtype.ANY.SSHFP.SSHFP(
|
||||||
|
@ -136,10 +130,11 @@ def sshfp_record_handler(zone, records):
|
||||||
dns.rdatatype.SSHFP,
|
dns.rdatatype.SSHFP,
|
||||||
algorithm,
|
algorithm,
|
||||||
fp_type,
|
fp_type,
|
||||||
fingerprint
|
fingerprint,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def txt_records_handler(zone, records):
|
def txt_records_handler(zone, records):
|
||||||
"""Handler for TXT record"""
|
"""Handler for TXT record"""
|
||||||
|
|
||||||
|
@ -149,12 +144,11 @@ def txt_records_handler(zone, records):
|
||||||
|
|
||||||
records[name].append(
|
records[name].append(
|
||||||
dns.rdtypes.ANY.TXT.TXT(
|
dns.rdtypes.ANY.TXT.TXT(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN, dns.rdatatype.TXT, record["field2"]
|
||||||
dns.rdatatype.TXT,
|
|
||||||
record["field2"]
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def srv_records_handler(zone, records):
|
def srv_records_handler(zone, records):
|
||||||
"""Handler for SRV record"""
|
"""Handler for SRV record"""
|
||||||
|
|
||||||
|
@ -167,13 +161,13 @@ def srv_records_handler(zone, records):
|
||||||
dns.rdtypes.ANY.SRV.SRV(
|
dns.rdtypes.ANY.SRV.SRV(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN,
|
||||||
dns.rdatatype.SRV,
|
dns.rdatatype.SRV,
|
||||||
record['priority'],
|
record["priority"],
|
||||||
record['weight'],
|
record["weight"],
|
||||||
record['port'],
|
record["port"],
|
||||||
record['target']
|
record["target"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def a_records_handler(zone, recordds):
|
def a_records_handler(zone, recordds):
|
||||||
"""Handler for A Record"""
|
"""Handler for A Record"""
|
||||||
|
@ -187,6 +181,7 @@ def a_records_handler(zone, recordds):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
Loading…
Reference in a new issue