1
0
Fork 0

Some bugs fixed

master
Simon Moser vor 3 Jahren
Ursprung 5f028a37bb
Commit 7ace71b3b9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 83765B895FF2CFC6

@ -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

Laden…
Abbrechen
Speichern