aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-11-22 11:37:14 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-11-22 11:37:14 +0900
commit842e86619dffe9cbc985d98ec581042ed5dc8ba3 (patch)
treeada51aedb8fd427ab2886281b12e67a4e54e462a
parent7e72e98e49bda05d1d523346336f207799f43017 (diff)
downloadascension-842e86619dffe9cbc985d98ec581042ed5dc8ba3.tar.gz
ascension-842e86619dffe9cbc985d98ec581042ed5dc8ba3.zip
fix SOA parsing
-rw-r--r--ascension/ascension.py10
-rw-r--r--ascension/util/classes.py4
-rw-r--r--ascension/util/keyfile.py2
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():
182 if not record_data.data: 182 if not record_data.data:
183 self.logger.warning("Empty record %s", record_data) 183 self.logger.warning("Empty record %s", record_data)
184 return 184 return
185 self.logger.debug("Payload: %s", payload.to_json()) 185 #self.logger.debug("Payload: %s", payload.to_json())
186 186
187 # Replace the records already present in GNS as old ones are not deleted 187 # Replace the records already present in GNS as old ones are not deleted
188 self.logger.debug(payload.record_name + "." + domain + ":\n") 188 self.logger.debug(payload.record_name + "." + domain + ":\n")
189 self.ns_process.stdin.write(payload.record_name + "." + domain + ":\n") 189 self.ns_process.stdin.write(payload.record_name + "." + domain + ":\n")
190 i = 0
190 for r in payload.data: 191 for r in payload.data:
191 flags = "[r{}]".format('p' if not r.is_private else '') 192 flags = "[r{}]".format('p' if not r.is_private else '')
193 i += 1
194 if i > 100:
195 return
192 # FIXME we have many more flags. but probably not in our use 196 # FIXME we have many more flags. but probably not in our use
193 # case? We always have relative expirations, for example. 197 # case? We always have relative expirations, for example.
194 self.logger.debug("{} {} {} {}\n".format(r.record_type, 198 self.logger.debug("{} {} {} {}\n".format(r.record_type,
@@ -226,8 +230,12 @@ class Ascension():
226 # Do it single threaded because threading scares me 230 # Do it single threaded because threading scares me
227 self.ns_process = subprocess.Popen(["gnunet-namestore", "-a", "-S"], stdin=subprocess.PIPE, text=True) 231 self.ns_process = subprocess.Popen(["gnunet-namestore", "-a", "-S"], stdin=subprocess.PIPE, text=True)
228 start = time.time() 232 start = time.time()
233 i = 0
229 for name, rdatasets in self.dnszone.zone.nodes.items(): 234 for name, rdatasets in self.dnszone.zone.nodes.items():
230 # log if the rdataset is empty for some reason 235 # log if the rdataset is empty for some reason
236 i += 1
237 if i > 100:
238 break
231 if not rdatasets: 239 if not rdatasets:
232 self.logger.warning("Empty Rdataset!") 240 self.logger.warning("Empty Rdataset!")
233 continue 241 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():
104 if response.status_code == 404: 104 if response.status_code == 404:
105 return 0 105 return 0
106 106
107 data = response.json() 107 data = [response.json()]
108 if not isinstance(data, list): 108 if not isinstance(data, list):
109 error = data.get('error') 109 error = data.get('error')
110 if error in ascension.util.rest.NAMESTORE_REST_API_ERRORS: 110 if error in ascension.util.rest.NAMESTORE_REST_API_ERRORS:
@@ -112,7 +112,7 @@ class GNSZone():
112 self.logger.warning("Task failed with unknown error: %s", error) 112 self.logger.warning("Task failed with unknown error: %s", error)
113 return 0 113 return 0
114 114
115 soapattern = re.compile(r'.+\s(\d+),\d+,\d+,\d+,\d+', re.M) 115 soapattern = re.compile(r'.+\s(\d+) \d+ \d+ \d+ \d+', re.M)
116 recordlists = [x for x in data if x.get('data')] 116 recordlists = [x for x in data if x.get('data')]
117 soa_serials = [0] 117 soa_serials = [0]
118 for rlist in recordlists: 118 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
25import dns.name 25import dns.name
26import dns.tsig 26import dns.tsig
27 27
28@staticmethod 28#@staticmethod
29def parse_bind_keyfile(keyring: str) -> dict[dns.name.Name, dns.tsig.Key]: 29def parse_bind_keyfile(keyring: str) -> dict[dns.name.Name, dns.tsig.Key]:
30 """ 30 """
31 Reads a BIND style keyfile and creates a dictionary in the form of: 31 Reads a BIND style keyfile and creates a dictionary in the form of: