diff --git a/server.py b/server.py index d2deba7..6cbeeee 100644 --- a/server.py +++ b/server.py @@ -37,10 +37,16 @@ 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): + for i in os.listdir(homefolder + "/certs/"): + thisname = "-".join(i.split("-")[:-1]) + if open(homefolder + "/certs/" + thisname + "-privkey.pem").read() == privkey.read() and open(homefolder + "/certs/" + thisname + "-chain.pem").read() == cert.read(): + resp = make_response('The certificate seems to already exist, loading the used file.

Go home

') + resp.set_cookie('certname',thisname) + return resp 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

') + resp = make_response('Success!

Go home

') resp.set_cookie('certname',random_name) return resp else: @@ -158,11 +164,11 @@ def relay(): return redirect("/gem?gemini=" + urlparse(fulladdr).hostname + quote(i.split(" ")[1], safe='')) return redirect("/gem?gemini=" + quote(i.split(" ")[1][9:], safe='')) elif i.split(" ")[0][0] == "1": - return f'\nInput required

Input required

The specified Gemini server wants more data:

{i}




' + return f'\nInput required

Input required

The specified Gemini server wants more data:

{i}




' elif i.split(" ")[0][0] == "6": - return f'\nCertificate requested

Certificate requested

The specified Gemini server wants a client certificate, or the certificate is invalid.

{i}



You can load a certificate in home page.

' + return f'\nCertificate requested

Certificate requested

The specified Gemini server wants a client certificate, or the certificate is invalid.

{i}



You can load a certificate in home page.

' elif i.split(" ")[0][0] != "2": - return f'\nSomething went wrong...

Something went wrong...

The specified Gemini server returned a status of: {i}

' + return f'\nSomething went wrong...

Something went wrong...

The specified Gemini server returned a status of: {i}

' else: firstline = False if i.split(" ")[1].split(";")[0] != "text/gemini": @@ -246,7 +252,7 @@ def relay(): title = "gemini://" + url except: code += "
" + traceback.format_exc() + "
" - return f'\n{title}{code}' + return f'\n{title}{code}' # Run the Hypercorn ASGI server conf = Config()