mirror of
https://codeberg.org/bunbun/bunbun.dev
synced 2025-01-22 04:34:29 -08:00
30 lines
730 B
Fennel
30 lines
730 B
Fennel
(local socket (require :socket))
|
|
(local ssl (require :ssl))
|
|
|
|
(local handle-client (. (require :client-handler) :handle-client))
|
|
|
|
(local port 50625)
|
|
(local server (socket.tcp))
|
|
|
|
(server:bind "*" port)
|
|
(server:listen)
|
|
|
|
(local params {:mode "server"
|
|
:protocol "tlsv1_2"
|
|
:key "../privkey.pem"
|
|
:certificate "../fullchain.pem"
|
|
:cafile "../chain.pem"
|
|
:verify "none"
|
|
:options "all"})
|
|
|
|
(while true
|
|
(var client (server:accept))
|
|
|
|
(set (_G.client-address _G.client-port) (client:getpeername))
|
|
|
|
(set client (ssl.wrap client params))
|
|
(client:dohandshake)
|
|
|
|
(let [co (coroutine.create (fn [] (handle-client client)))]
|
|
(coroutine.resume co)))
|