61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
#!/bin/false
|
|
from os import environ
|
|
|
|
def getenv(name):
|
|
return environ.get(name, "")
|
|
|
|
version = getenv("GATEWAY_INTERFACE")
|
|
protocol = getenv("SERVER_PROTOCOL")
|
|
software = getenv("SERVER_SOFTWARE")
|
|
url = getenv("GEMINI_URL")
|
|
script = getenv("SCRIPT_NAME")
|
|
path = getenv("PATH_INFO")
|
|
query = getenv("QUERY_STRING")
|
|
host = getenv("SERVER_NAME")
|
|
port = getenv("SERVER_PORT")
|
|
remote = getenv("REMOTE_HOST")
|
|
tls_cipher = getenv("TLS_CIPHER")
|
|
tls_version = getenv("TLS_VERSION")
|
|
auth_type = getenv("AUTH_TYPE")
|
|
cert_hash = getenv("TLS_CLIENT_HASH")
|
|
cert_sn = getenv("TLS_CLIENT_SERIAL_NUMBER")
|
|
cert_name = getenv("REMOTE_USER")
|
|
|
|
cgi_vars = [
|
|
"version", "protocol", "software", "url", "script", "path", "query", "host",
|
|
"port", "remote", "tls_cipher", "tls_version", "auth_type", "cert_hash",
|
|
"cert_sn", "cert_name"
|
|
]
|
|
|
|
def header(code, meta):
|
|
print(f"{code} {meta}", end="\r\n")
|
|
|
|
def exit_with_header(code, meta):
|
|
header(code, meta)
|
|
exit()
|
|
|
|
def require_input(meta):
|
|
exit_with_header(10, meta)
|
|
|
|
def redirect_temp(url):
|
|
exit_with_header(30, url)
|
|
|
|
def redirect_perm(url):
|
|
exit_with_header(31, url)
|
|
|
|
def temp_error(meta):
|
|
exit_with_header(42, meta)
|
|
|
|
def not_found():
|
|
exit_with_header(51, "File not found.")
|
|
|
|
def debug():
|
|
header(20, "text/plain")
|
|
print_env()
|
|
exit()
|
|
|
|
def print_env():
|
|
globz = globals()
|
|
for key in cgi_vars:
|
|
print(f"{key} = {repr(globz[key])}")
|