make the gemini server have its own cqueue
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
d5dfe68ad6
commit
3f1df57558
10
gemini.moon
10
gemini.moon
|
@ -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
|
||||
|
|
|
@ -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!
|
||||
|
|
Loading…
Reference in New Issue