Compare commits
No commits in common. "7ba71b5eefcf15bb21aea17bd7f4d9cba4fa9680" and "989df5a8498880a0cdde3d78c72791c62c5637f6" have entirely different histories.
7ba71b5eef
...
989df5a849
|
@ -7,8 +7,6 @@ import subprocess
|
|||
|
||||
import smolcgi
|
||||
|
||||
smolcgi.require_cool_client("This script is not publicly available, sorry!")
|
||||
|
||||
if not smolcgi.query_string_dec:
|
||||
smolcgi.require_input("Provide an email address to check.")
|
||||
|
||||
|
|
60
smolcgi.py
60
smolcgi.py
|
@ -68,23 +68,15 @@ def header(code, meta):
|
|||
print(f"{code} {meta}", end="\r\n")
|
||||
|
||||
|
||||
def success(mime):
|
||||
header(20, mime)
|
||||
|
||||
|
||||
def exit_with_header(code, meta):
|
||||
header(code, meta)
|
||||
exit()
|
||||
|
||||
|
||||
def require_input(reason=""):
|
||||
def require_input(reason):
|
||||
exit_with_header(10, reason)
|
||||
|
||||
|
||||
def require_sensitive_input(reason=""):
|
||||
exit_with_header(11, reason)
|
||||
|
||||
|
||||
def redirect_temp(url):
|
||||
exit_with_header(30, url)
|
||||
|
||||
|
@ -93,43 +85,15 @@ def redirect_perm(url):
|
|||
exit_with_header(31, url)
|
||||
|
||||
|
||||
def temp_error(reason=""):
|
||||
exit_with_header(40, reason)
|
||||
|
||||
|
||||
def server_unavailable(reason=""):
|
||||
exit_with_header(41, reason)
|
||||
|
||||
|
||||
def cgi_error(reason=""):
|
||||
def temp_error(reason):
|
||||
exit_with_header(42, reason)
|
||||
|
||||
|
||||
def proxy_error(reason=""):
|
||||
exit_with_header(43, reason)
|
||||
|
||||
|
||||
def slow_down(num_seconds):
|
||||
exit_with_header(44, num_seconds)
|
||||
|
||||
|
||||
def perm_error(reason=""):
|
||||
exit_with_header(50, reason)
|
||||
|
||||
|
||||
def not_found(reason=""):
|
||||
def not_found(reason="Not found"):
|
||||
exit_with_header(51, reason)
|
||||
|
||||
|
||||
def gone(reason=""):
|
||||
exit_with_header(52, reason)
|
||||
|
||||
|
||||
def proxy_request_refused(reason=""):
|
||||
exit_with_header(53, reason)
|
||||
|
||||
|
||||
def bad_request(reason=""):
|
||||
def bad_request(reason="Bad request"):
|
||||
exit_with_header(59, reason)
|
||||
|
||||
|
||||
|
@ -138,22 +102,6 @@ def require_client_cert():
|
|||
exit_with_header(60, "You need a certificate to use this app")
|
||||
|
||||
|
||||
def cert_not_authorised(reason=""):
|
||||
exit_with_header(61, reason)
|
||||
|
||||
|
||||
def require_cool_client(reason=""):
|
||||
require_client_cert()
|
||||
with open(get_storage_path() / "cool_hashes", "rt") as f:
|
||||
cool_hashes = f.read().rstrip().split("\n")
|
||||
if tls_client_hash not in cool_hashes:
|
||||
cert_not_authorised(reason)
|
||||
|
||||
|
||||
def cert_not_valid(reason=""):
|
||||
exit_with_header(62, reason)
|
||||
|
||||
|
||||
def print_env():
|
||||
globz = globals()
|
||||
for key in cgi_vars:
|
||||
|
|
Reference in a new issue