import only the necessary and fix import

This commit is contained in:
otthorn 2021-04-05 01:03:19 +02:00
parent f1dd358441
commit f8e02ee51e

28
main.py
View file

@ -6,7 +6,8 @@ import configparser
import dns.name
import dns.rdataset
import dns.rdatatype
from dns.rdtypes.ANY import *
from dns.rdtypes.ANY import CNAME, DNAME, NS, SOA, SSHFP
from dns.rdtypes.IN import AAAA, SRV, A
from re2oapi import Re2oAPIClient
@ -45,6 +46,7 @@ def format_mname(name: str):
return mname
def soa_handler(zone, records):
"""Handler for SOA record"""
@ -71,7 +73,7 @@ def originv4_handler(zone, records):
ipv4_addr = zone["originv4"]["ipv4"]
records["@"].append(
dns.rdtypes.ANY.A.A(dns.rdataclass.IN, dns.rdatatypes.A, ipv4_addr)
dns.rdtypes.IN.A.A(dns.rdataclass.IN, dns.rdatatypes.A, ipv4_addr)
)
@ -81,7 +83,7 @@ def originv6_handler(zone, records):
ipv6_addr = zone["originv6"] # Yes, re2o is this weird and inconsistent
records["@"].append(
dns.rdtypes.ANY.AAAA.AAAA(
dns.rdtypes.IN.AAAA.AAAA(
dns.rdataclass.IN, dns.rdatatype.AAAA, ipv6_addr
)
)
@ -121,6 +123,7 @@ def sshfp_record_handler(zone, records):
)
)
def mx_records_handler(zone, records):
"""Handler for the MX record"""
@ -128,15 +131,13 @@ def mx_records_handler(zone, records):
preference = record["priority"]
exchange = record["target"]
records['@'].append(
records["@"].append(
dns.rdtype.ANY.MX.MX(
dns.rdataclass.IN,
dns.rdatatype.MX,
preference,
priority
dns.rdataclass.IN, dns.rdatatype.MX, preference, priority
)
)
def txt_records_handler(zone, records):
"""Handler for TXT record"""
@ -160,7 +161,7 @@ def srv_records_handler(zone, records):
name_key = name.to_text()
records[name_key].append(
dns.rdtypes.ANY.SRV.SRV(
dns.rdtypes.IN.SRV.SRV(
dns.rdataclass.IN,
dns.rdatatype.SRV,
record["priority"],
@ -179,13 +180,14 @@ def a_records_handler(zone, records):
ipv4_addr = record["ipv4"]
records[record["hostname"]].append(
dns.rdtypes.ANY.A.A(
dns.rdtypes.IN.A.A(
dns.rdataclass.IN,
dns.rdatatype.A,
ipv4_addr,
)
)
def aaaa_records_handler(zone, records):
"""Handler for AAAA Record"""
@ -194,16 +196,18 @@ def aaaa_records_handler(zone, records):
ipv6_addr = record["ipv6"]
records[record["hostname"]].append(
dns.rdtypes.ANY.AAAA.AAAA(
dns.rdtypes.IN.AAAA.AAAA(
dns.rdataclass.IN,
dns.rdatatype.AAAA,
ipv6_addr,
)
)
def pass_handler(zone, records):
pass
HANDLERS = {
"soa": soa_handler,
"originv4": originv4_handler,
@ -215,7 +219,7 @@ HANDLERS = {
"srv_records": srv_records_handler,
"a_records": a_records_handler,
"aaaa_records": aaaa_records_handler,
"name": pass_handler
"name": pass_handler,
}