Commit Diff


commit - 5adcb046c4f9bf418975f74ffbd6efa4061c4de8
commit + ecdd11bebb96abe6f21ba4c3e35dd4599e8bdac5
blob - b27ec6d382e790f29b8f6f82f34001bba83c7b63 (mode 644)
blob + aa6c67467a3f2a2cd9bdde4272237630f9ca26b5 (mode 755)
--- lonk.py
+++ lonk.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 import ssl
 from sqlite3 import connect as sqlite3_connect
 from argparse import ArgumentParser
@@ -238,45 +239,10 @@ def demo():
         print(_format_honk(honk, header))
 
 
-def create_schema(dbcon):
-    pass
-
-
-def server():
-    parser = ArgumentParser()
-    parser.add_argument("--address", default="127.0.0.1", help="bind to this address (default: %(default)s)")
-    parser.add_argument("--port", default=1965, type=int, help="bind to this port (default: %(default)s)")
-    parser.add_argument("--certfile", required=True, help="path server certificate file")
-    parser.add_argument("--keyfile", required=True, help="path certificate private key file")
-    parser.add_argument("--dbfile", required=True, help="path to databale file")
-    args = parser.parse_args()
-
-    need_to_create_schema = not Path(args.dbfile).exists()
-    dbcon = sqlite3_connect(args.dbfile)
-    if need_to_create_schema:
-        with dbcon:
-            create_schema(dbcon)
-
-    ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
-    ssl_ctx.verify_mode = ssl.CERT_OPTIONAL
-    ssl_ctx.minimum_version = ssl.TLSVersion.TLSv1_2
-    ssl_ctx.check_hostname = False
-    ssl_ctx.load_cert_chain(args.certfile, args.keyfile)
+def vgi():
+    print("20 text/gemini\r")
+    demo()
 
-    with socket() as sock:
-        sock.bind((args.address, args.port))
-        sock.listen()
-        with ssl_ctx.wrap_socket(sock, server_side=True) as ssl_sock:
-            while True:
-                conn, addr = ssl_sock.accept()
-                client_cert = conn.getpeercert(binary_form=True)
-                if client_cert is None:
-                    conn.write(b"60 Certificate required\r\n")
-                    conn.close()
-                    continue
-                raise NotImplementedError(client_cert)
-
-
 if __name__ == '__main__':
-    demo()
-    # server()
+    # demo()
+    vgi()