make the gemini server have its own cqueue

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-05-10 14:31:13 +00:00
parent d5dfe68ad6
commit 3f1df57558
2 changed files with 13 additions and 6 deletions

View File

@ -1,10 +1,15 @@
cqueues = require "cqueues"
url = require "net.url"
class Server
new: (cq, hdlr) =>
@cq = cq
new: (hdlr) =>
@cq = cqueues.new!
@hdlr = hdlr
attach: (cq) =>
cq\wrap ->
@cq\loop!
listen: (srv) =>
@cq\wrap ->
for conn in srv\clients!
@ -12,6 +17,7 @@ class Server
with conn
_, ip = \peername!
request = \read "*l"
\shutdown "r"
u = url.parse request
ctx =
:ip

View File

@ -11,10 +11,11 @@ class ProxyRequestRefusedHandler
conn\write "53 Proxy request refused \r\n"
ln.log ctx, {status: 53}
with gemini.Server cq, ProxyRequestRefusedHandler!
with gemini.Server ProxyRequestRefusedHandler!
\listen socket.listen "127.0.0.1", "58816"
\listen socket.listen
path: "./var/mipha.sock"
unlink: true
-- \listen socket.listen
-- path: "./var/mipha.sock"
-- unlink: true
\attach cq
assert cq\loop!