|
|
@ -73,9 +73,11 @@ class FileResolver(BaseResolver):
|
|
|
|
|
|
|
|
|
|
|
|
# Request method for uploads
|
|
|
|
# Request method for uploads
|
|
|
|
if qry_type == "SRV":
|
|
|
|
if qry_type == "SRV":
|
|
|
|
with open('/tmp/dns-srv.log', 'w') as f:
|
|
|
|
with open('/tmp/dns-srv.log', 'a') as f:
|
|
|
|
f.write(name.stripSuffix(self.domain))
|
|
|
|
f.write(str(name.stripSuffix("." + self.domain)) + "\n")
|
|
|
|
reply.add_answer(RR(name, QTYPE.SRV, ttl=self.ttl, rdata=TXT("accepted")))
|
|
|
|
reply.add_answer(RR(name, QTYPE.SRV, ttl=self.ttl, rdata=TXT("accepted")))
|
|
|
|
|
|
|
|
return reply
|
|
|
|
|
|
|
|
|
|
|
|
# Request method for downloads
|
|
|
|
# Request method for downloads
|
|
|
|
if qry_type == "TXT":
|
|
|
|
if qry_type == "TXT":
|
|
|
|
# Format is filename.count.domain for count
|
|
|
|
# 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
|
|
|
|
# parts[0] should be filename, parts[1] should be segment or count
|
|
|
|
pname = '.'.join(parts[:-2])
|
|
|
|
pname = '.'.join(parts[:-2])
|
|
|
|
path = self.directory + "/" + pname
|
|
|
|
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):
|
|
|
|
if not os.path.isfile(path):
|
|
|
|
reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT("File not found")))
|
|
|
|
reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT("File not found")))
|
|
|
|
return reply
|
|
|
|
return reply
|
|
|
@ -101,14 +109,14 @@ class FileResolver(BaseResolver):
|
|
|
|
# Finally divide into number of 254 byte chunks
|
|
|
|
# Finally divide into number of 254 byte chunks
|
|
|
|
chunks = (length / 254)
|
|
|
|
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))))
|
|
|
|
reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT(str(chunks))))
|
|
|
|
return reply
|
|
|
|
return reply
|
|
|
|
|
|
|
|
|
|
|
|
if ''.join(parts[-2:-1]).isdigit():
|
|
|
|
if command.isdigit():
|
|
|
|
# Woo it's a number
|
|
|
|
# Woo it's a number
|
|
|
|
# lets base64 the file
|
|
|
|
# lets base64 the file
|
|
|
|
chunk = int(''.join(parts[-2:-1]))
|
|
|
|
chunk = int(command)
|
|
|
|
if chunk > chunks or chunk < 0:
|
|
|
|
if chunk > chunks or chunk < 0:
|
|
|
|
reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT("Chunk out of range")))
|
|
|
|
reply.add_answer(RR(name, QTYPE.TXT, ttl=self.ttl, rdata=TXT("Chunk out of range")))
|
|
|
|
return reply
|
|
|
|
return reply
|
|
|
|