Added timestamps for logging
This commit is contained in:
@@ -2,6 +2,7 @@ import dns.update
|
|||||||
import dns.query
|
import dns.query
|
||||||
import dns.tsigkeyring
|
import dns.tsigkeyring
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
@@ -9,7 +10,9 @@ config = {}
|
|||||||
def add_records(records):
|
def add_records(records):
|
||||||
keyring = dns.tsigkeyring.from_text(
|
keyring = dns.tsigkeyring.from_text(
|
||||||
{config['TSIG_NAME']: config['TSIG_KEY']})
|
{config['TSIG_NAME']: config['TSIG_KEY']})
|
||||||
|
|
||||||
for hostname, ip in records.items():
|
for hostname, ip in records.items():
|
||||||
|
print(datetime.now().isoformat(), end=" ")
|
||||||
print("Adding record for " + hostname + "(" + ip + ")")
|
print("Adding record for " + hostname + "(" + ip + ")")
|
||||||
|
|
||||||
rrtype = "A"
|
rrtype = "A"
|
||||||
@@ -27,8 +30,11 @@ def add_records(records):
|
|||||||
def delete_records(records):
|
def delete_records(records):
|
||||||
keyring = dns.tsigkeyring.from_text(
|
keyring = dns.tsigkeyring.from_text(
|
||||||
{config['TSIG_NAME']: config['TSIG_KEY']})
|
{config['TSIG_NAME']: config['TSIG_KEY']})
|
||||||
|
|
||||||
for hostname, ip in records.items():
|
for hostname, ip in records.items():
|
||||||
|
print(datetime.now().isoformat(), end=" ")
|
||||||
print("Deleting record for " + hostname + "(" + ip + ")")
|
print("Deleting record for " + hostname + "(" + ip + ")")
|
||||||
|
|
||||||
update = dns.update.Update(config['DOMAIN'], keyring=keyring)
|
update = dns.update.Update(config['DOMAIN'], keyring=keyring)
|
||||||
update.delete(hostname)
|
update.delete(hostname)
|
||||||
dns.query.tcp(update, config['NAMESERVER'], timeout=2)
|
dns.query.tcp(update, config['NAMESERVER'], timeout=2)
|
||||||
|
|||||||
Reference in New Issue
Block a user