diff --git a/server.py b/server.py index 6548f84..90c96aa 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -import asyncio, traceback, socket, ssl, zipfile, random, string, io +import asyncio, traceback, socket, ssl, zipfile, uuid, io from OpenSSL import crypto from urllib.parse import urlparse, quote from flask import Flask, request, redirect, send_file, Response, make_response @@ -37,7 +37,7 @@ def loadcert_backend(): if cert.filename == '' or privkey.filename == '': return "Please upload a certificate and private key." if allowed_file(cert.filename) and allowed_file(privkey.filename): - random_name = ''.join(random.choice(string.ascii_lowercase+string.digits+string.ascii_uppercase) for i in range(8)) + random_name = str(uuid.uuid4()) cert.save(homefolder + "/certs/" + random_name + "-chain.pem") privkey.save(homefolder + "/certs/" + random_name + "-privkey.pem") resp = make_response('Success!

Go home

') @@ -49,7 +49,7 @@ def loadcert_backend(): return "Cannot go to /certload with GET, perhaps you're looking for /loadcert" @app.route("/gencert.zip") def gencert(): - random_name = ''.join(random.choice(string.ascii_lowercase+string.digits+string.ascii_uppercase) for i in range(8)) + random_name = str(uuid.uuid4()) k = crypto.PKey() k.generate_key(crypto.TYPE_RSA, 2048) cert = crypto.X509() @@ -195,12 +195,17 @@ def relay(): goto = temp.split(" ")[0] prse = urlparse(goto) extra = "" + qury = None extracomment = goto if prse.netloc == "" and prse.scheme == "": isdir = url[len(url) - 1] == "/" isabs = goto[0] == "/" or goto[0:2] == "//" + isquery = goto[0] == "?" dubleslash = goto[0:2] == "//" - if isabs: + if isquey: + tempurl = url + qury = "" + elif isabs: tempurl = urlparse(fulladdr).hostname + (goto[1:] if dubleslash else goto) elif isdir: tempurl = url + goto