From b90167f8e8917f777906fef6aa3c81626139f713 Mon Sep 17 00:00:00 2001 From: Danamir Date: Wed, 22 May 2019 23:43:12 +0200 Subject: [PATCH] Auto remove sub-domain if found in the domain configuration --- dyn_gandi.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dyn_gandi.py b/dyn_gandi.py index 91d09fd..f90c82e 100644 --- a/dyn_gandi.py +++ b/dyn_gandi.py @@ -16,6 +16,7 @@ import json import os import sys +import re from configparser import ConfigParser from datetime import datetime @@ -180,7 +181,13 @@ def main(): print("Wrote %s to %s file." % (ip, out_file)) # Query LiveDNS API - domain = config['dns']['domain'] + domain = config['dns']['domain'] # type: str + + if re.match(r"^.+\.[^.]+\.[^.]+$", domain): + if verbose: + print("Warning: removing sub-domain part of %s" % domain) + domain = re.sub(r"^.+\.([^.]+\.[^.]+)$", r"\g<1>", domain) + if verbose: print("Domain: %s" % domain)