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