mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 14:09:13 -06:00
add in backup incase of no connect
This commit is contained in:
parent
fdbe11b673
commit
17716b880e
@ -36,14 +36,23 @@ class serveRA(http.server.SimpleHTTPRequestHandler):
|
|||||||
if firstline.startswith('remotelist='):
|
if firstline.startswith('remotelist='):
|
||||||
remote = firstline.split('=')[1].strip()
|
remote = firstline.split('=')[1].strip()
|
||||||
response = requests.get(remote, headers={'Accept': 'text/html,*/*'})
|
response = requests.get(remote, headers={'Accept': 'text/html,*/*'})
|
||||||
responsetext = response.text
|
print(f"remote list came back with status code {response.status_code}")
|
||||||
config = file.read().decode('utf-8')
|
if response.status_code == 200:
|
||||||
confgrps = re.findall(r"^permissions/(.+)=(.+)", config, flags=re.M)
|
responsetext = response.text
|
||||||
baseperm = re.match(r"^permissions=(.+)", config, flags=re.M)
|
config = file.read().decode('utf-8')
|
||||||
responsetext = re.sub(r"^Group=(.+):(.+)", fr'Group=\1:{baseperm[0]}', responsetext, flags=re.M)
|
confgrps = re.findall(r"^permissions/(.+)=(.+)", config, flags=re.M)
|
||||||
for congrp in confgrps:
|
baseperm = re.match(r"^permissions=(.+)", config, flags=re.M)
|
||||||
responsetext = re.sub(rf"^Group=({congrp[0]}):(.+)", rf"Group=\1:{congrp[1]}", responsetext, flags=re.M)
|
responsetext = re.sub(r"^Group=(.+):(.+)", fr'Group=\1:{baseperm[0]}', responsetext, flags=re.M)
|
||||||
self.wfile.write(responsetext.encode('utf-8'))
|
for congrp in confgrps:
|
||||||
|
responsetext = re.sub(rf"^Group=({congrp[0]}):(.+)", rf"Group=\1:{congrp[1]}", responsetext, flags=re.M)
|
||||||
|
self.wfile.write(responsetext.encode('utf-8'))
|
||||||
|
backupfile = open(f"./wlgrps/backup-{grpName}.cfg", 'wb')
|
||||||
|
backupfile.write(responsetext.encode('utf-8'))
|
||||||
|
backupfile.close()
|
||||||
|
else:
|
||||||
|
backupfile = open(f"./wlgrps/backup-{grpName}.cfg", 'rb')
|
||||||
|
self.copyfile(backupfile, self.wfile)
|
||||||
|
backupfile.close()
|
||||||
else:
|
else:
|
||||||
self.copyfile(file, self.wfile)
|
self.copyfile(file, self.wfile)
|
||||||
file.close()
|
file.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user