import only the necessary and fix import
This commit is contained in:
parent
f1dd358441
commit
f8e02ee51e
1 changed files with 16 additions and 12 deletions
28
main.py
28
main.py
|
@ -6,7 +6,8 @@ import configparser
|
||||||
import dns.name
|
import dns.name
|
||||||
import dns.rdataset
|
import dns.rdataset
|
||||||
import dns.rdatatype
|
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
|
from re2oapi import Re2oAPIClient
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ def format_mname(name: str):
|
||||||
|
|
||||||
return mname
|
return mname
|
||||||
|
|
||||||
|
|
||||||
def soa_handler(zone, records):
|
def soa_handler(zone, records):
|
||||||
"""Handler for SOA record"""
|
"""Handler for SOA record"""
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ def originv4_handler(zone, records):
|
||||||
ipv4_addr = zone["originv4"]["ipv4"]
|
ipv4_addr = zone["originv4"]["ipv4"]
|
||||||
|
|
||||||
records["@"].append(
|
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
|
ipv6_addr = zone["originv6"] # Yes, re2o is this weird and inconsistent
|
||||||
|
|
||||||
records["@"].append(
|
records["@"].append(
|
||||||
dns.rdtypes.ANY.AAAA.AAAA(
|
dns.rdtypes.IN.AAAA.AAAA(
|
||||||
dns.rdataclass.IN, dns.rdatatype.AAAA, ipv6_addr
|
dns.rdataclass.IN, dns.rdatatype.AAAA, ipv6_addr
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -121,6 +123,7 @@ def sshfp_record_handler(zone, records):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def mx_records_handler(zone, records):
|
def mx_records_handler(zone, records):
|
||||||
"""Handler for the MX record"""
|
"""Handler for the MX record"""
|
||||||
|
|
||||||
|
@ -128,15 +131,13 @@ def mx_records_handler(zone, records):
|
||||||
preference = record["priority"]
|
preference = record["priority"]
|
||||||
exchange = record["target"]
|
exchange = record["target"]
|
||||||
|
|
||||||
records['@'].append(
|
records["@"].append(
|
||||||
dns.rdtype.ANY.MX.MX(
|
dns.rdtype.ANY.MX.MX(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN, dns.rdatatype.MX, preference, priority
|
||||||
dns.rdatatype.MX,
|
|
||||||
preference,
|
|
||||||
priority
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def txt_records_handler(zone, records):
|
def txt_records_handler(zone, records):
|
||||||
"""Handler for TXT record"""
|
"""Handler for TXT record"""
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ def srv_records_handler(zone, records):
|
||||||
name_key = name.to_text()
|
name_key = name.to_text()
|
||||||
|
|
||||||
records[name_key].append(
|
records[name_key].append(
|
||||||
dns.rdtypes.ANY.SRV.SRV(
|
dns.rdtypes.IN.SRV.SRV(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN,
|
||||||
dns.rdatatype.SRV,
|
dns.rdatatype.SRV,
|
||||||
record["priority"],
|
record["priority"],
|
||||||
|
@ -179,13 +180,14 @@ def a_records_handler(zone, records):
|
||||||
ipv4_addr = record["ipv4"]
|
ipv4_addr = record["ipv4"]
|
||||||
|
|
||||||
records[record["hostname"]].append(
|
records[record["hostname"]].append(
|
||||||
dns.rdtypes.ANY.A.A(
|
dns.rdtypes.IN.A.A(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN,
|
||||||
dns.rdatatype.A,
|
dns.rdatatype.A,
|
||||||
ipv4_addr,
|
ipv4_addr,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def aaaa_records_handler(zone, records):
|
def aaaa_records_handler(zone, records):
|
||||||
"""Handler for AAAA Record"""
|
"""Handler for AAAA Record"""
|
||||||
|
|
||||||
|
@ -194,16 +196,18 @@ def aaaa_records_handler(zone, records):
|
||||||
ipv6_addr = record["ipv6"]
|
ipv6_addr = record["ipv6"]
|
||||||
|
|
||||||
records[record["hostname"]].append(
|
records[record["hostname"]].append(
|
||||||
dns.rdtypes.ANY.AAAA.AAAA(
|
dns.rdtypes.IN.AAAA.AAAA(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN,
|
||||||
dns.rdatatype.AAAA,
|
dns.rdatatype.AAAA,
|
||||||
ipv6_addr,
|
ipv6_addr,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def pass_handler(zone, records):
|
def pass_handler(zone, records):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
HANDLERS = {
|
HANDLERS = {
|
||||||
"soa": soa_handler,
|
"soa": soa_handler,
|
||||||
"originv4": originv4_handler,
|
"originv4": originv4_handler,
|
||||||
|
@ -215,7 +219,7 @@ HANDLERS = {
|
||||||
"srv_records": srv_records_handler,
|
"srv_records": srv_records_handler,
|
||||||
"a_records": a_records_handler,
|
"a_records": a_records_handler,
|
||||||
"aaaa_records": aaaa_records_handler,
|
"aaaa_records": aaaa_records_handler,
|
||||||
"name": pass_handler
|
"name": pass_handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue