switched to https and added main.md

This commit is contained in:
2024-05-20 20:40:11 -07:00
parent e2d2a3f1b7
commit a57fd25990
3 changed files with 25 additions and 5 deletions

View File

@ -7,7 +7,9 @@
(fn client-handler.handle-client [client] (fn client-handler.handle-client [client]
(let [request (client:receive :*l)] (let [request (client:receive :*l)]
(print (: "Request from: %s:%s" :format (client:getpeername))) (io.stdout:setvbuf :no)
(print (: "Request from: %s:%s" :format _G.client-address _G.client-port))
(print request) (print request)
(while true (while true
(local request (client:receive :*l)) (local request (client:receive :*l))

5
pages/main.md Normal file
View File

@ -0,0 +1,5 @@
<!--
# Welcome to my Website
Hello, I'm Winter (aka bunbun) and this is my website... _Why are you here?_
-->

View File

@ -1,16 +1,29 @@
(local socket (require :socket)) (local socket (require :socket))
(local ssl (require :ssl))
(local handle-client (. (require :client-handler) :handle-client)) (local handle-client (. (require :client-handler) :handle-client))
(local port 8080) (local port 50625)
(local server (socket.tcp)) (local server (socket.tcp))
(server:bind "*" port) (server:bind "*" port)
(server:listen) (server:listen)
(local params {:mode "server"
:protocol "tlsv1_2"
:key "../privkey.pem"
:certificate "../fullchain.pem"
:cafile "../chain.pem"
:verify "none"
:options "all"})
(while true (while true
(local client (server:accept)) (var client (server:accept))
(local co (coroutine.create (fn [] (handle-client client)))) (set (_G.client-address _G.client-port) (client:getpeername))
(coroutine.resume co)) (set client (ssl.wrap client params))
(client:dohandshake)
(let [co (coroutine.create (fn [] (handle-client client)))]
(coroutine.resume co)))