diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-22 11:37:14 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-22 11:37:14 +0900 |
commit | 842e86619dffe9cbc985d98ec581042ed5dc8ba3 (patch) | |
tree | ada51aedb8fd427ab2886281b12e67a4e54e462a | |
parent | 7e72e98e49bda05d1d523346336f207799f43017 (diff) |
fix SOA parsing
-rw-r--r-- | ascension/ascension.py | 10 | ||||
-rw-r--r-- | ascension/util/classes.py | 4 | ||||
-rw-r--r-- | ascension/util/keyfile.py | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/ascension/ascension.py b/ascension/ascension.py index 643e20a..16ba90d 100644 --- a/ascension/ascension.py +++ b/ascension/ascension.py @@ -182,13 +182,17 @@ class Ascension(): if not record_data.data: self.logger.warning("Empty record %s", record_data) return - self.logger.debug("Payload: %s", payload.to_json()) + #self.logger.debug("Payload: %s", payload.to_json()) # Replace the records already present in GNS as old ones are not deleted self.logger.debug(payload.record_name + "." + domain + ":\n") self.ns_process.stdin.write(payload.record_name + "." + domain + ":\n") + i = 0 for r in payload.data: flags = "[r{}]".format('p' if not r.is_private else '') + i += 1 + if i > 100: + return # FIXME we have many more flags. but probably not in our use # case? We always have relative expirations, for example. self.logger.debug("{} {} {} {}\n".format(r.record_type, @@ -226,8 +230,12 @@ class Ascension(): # Do it single threaded because threading scares me self.ns_process = subprocess.Popen(["gnunet-namestore", "-a", "-S"], stdin=subprocess.PIPE, text=True) start = time.time() + i = 0 for name, rdatasets in self.dnszone.zone.nodes.items(): # log if the rdataset is empty for some reason + i += 1 + if i > 100: + break if not rdatasets: self.logger.warning("Empty Rdataset!") continue diff --git a/ascension/util/classes.py b/ascension/util/classes.py index 43913bf..09880c0 100644 --- a/ascension/util/classes.py +++ b/ascension/util/classes.py @@ -104,7 +104,7 @@ class GNSZone(): if response.status_code == 404: return 0 - data = response.json() + data = [response.json()] if not isinstance(data, list): error = data.get('error') if error in ascension.util.rest.NAMESTORE_REST_API_ERRORS: @@ -112,7 +112,7 @@ class GNSZone(): self.logger.warning("Task failed with unknown error: %s", error) return 0 - soapattern = re.compile(r'.+\s(\d+),\d+,\d+,\d+,\d+', re.M) + soapattern = re.compile(r'.+\s(\d+) \d+ \d+ \d+ \d+', re.M) recordlists = [x for x in data if x.get('data')] soa_serials = [0] for rlist in recordlists: diff --git a/ascension/util/keyfile.py b/ascension/util/keyfile.py index 824f9c6..4e85418 100644 --- a/ascension/util/keyfile.py +++ b/ascension/util/keyfile.py @@ -25,7 +25,7 @@ import shlex import dns.name import dns.tsig -@staticmethod +#@staticmethod def parse_bind_keyfile(keyring: str) -> dict[dns.name.Name, dns.tsig.Key]: """ Reads a BIND style keyfile and creates a dictionary in the form of: |