From 7ace71b3b90448f48f8de8d24d5caeba03b851dc Mon Sep 17 00:00:00 2001 From: Simon Moser Date: Fri, 4 Feb 2022 16:14:30 +0100 Subject: [PATCH] Some bugs fixed --- server | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server b/server index 3c6e3d6..9d37709 100755 --- a/server +++ b/server @@ -73,9 +73,11 @@ class FileResolver(BaseResolver): # Request method for uploads if qry_type == "SRV": - with open('/tmp/dns-srv.log', 'w') as f: - f.write(name.stripSuffix(self.domain)) + with open('/tmp/dns-srv.log', 'a') as f: + f.write(str(name.stripSuffix("." + self.domain)) + "\n") reply.add_answer(RR(name, QTYPE.SRV, ttl=self.ttl, rdata=TXT("accepted"))) + return reply + # Request method for downloads if qry_type == "TXT": # Format is filename.count.domain for count @@ -88,6 +90,12 @@ class FileResolver(BaseResolver): # parts[0] should be filename, parts[1] should be segment or count pname = '.'.join(parts[:-2]) path = self.directory + "/" + pname + command = ''.join(parts[-2:-1]) + if command == "u": + with open('/tmp/dns-srv.log', 'a') as f: + f.write(str(name.stripSuffix("." + self.domain)) + "\n") + reply.add_answer(RR(name, QTYPE.SRV, ttl=self.ttl, rdata=TXT("accepted"))) + return reply if not os.path.isfile(path): reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT("File not found"))) return reply @@ -101,14 +109,14 @@ class FileResolver(BaseResolver): # Finally divide into number of 254 byte chunks chunks = (length / 254) - if ''.join(parts[-2:-1]) == "count": + if command == "count": reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT(str(chunks)))) return reply - if ''.join(parts[-2:-1]).isdigit(): + if command.isdigit(): # Woo it's a number # lets base64 the file - chunk = int(''.join(parts[-2:-1])) + chunk = int(command) if chunk > chunks or chunk < 0: reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT("Chunk out of range"))) return reply