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"
|
url = require "net.url"
|
||||||
|
|
||||||
class Server
|
class Server
|
||||||
new: (cq, hdlr) =>
|
new: (hdlr) =>
|
||||||
@cq = cq
|
@cq = cqueues.new!
|
||||||
@hdlr = hdlr
|
@hdlr = hdlr
|
||||||
|
|
||||||
|
attach: (cq) =>
|
||||||
|
cq\wrap ->
|
||||||
|
@cq\loop!
|
||||||
|
|
||||||
listen: (srv) =>
|
listen: (srv) =>
|
||||||
@cq\wrap ->
|
@cq\wrap ->
|
||||||
for conn in srv\clients!
|
for conn in srv\clients!
|
||||||
|
@ -12,6 +17,7 @@ class Server
|
||||||
with conn
|
with conn
|
||||||
_, ip = \peername!
|
_, ip = \peername!
|
||||||
request = \read "*l"
|
request = \read "*l"
|
||||||
|
\shutdown "r"
|
||||||
u = url.parse request
|
u = url.parse request
|
||||||
ctx =
|
ctx =
|
||||||
:ip
|
:ip
|
||||||
|
|
|
@ -11,10 +11,11 @@ class ProxyRequestRefusedHandler
|
||||||
conn\write "53 Proxy request refused \r\n"
|
conn\write "53 Proxy request refused \r\n"
|
||||||
ln.log ctx, {status: 53}
|
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 "127.0.0.1", "58816"
|
||||||
\listen socket.listen
|
-- \listen socket.listen
|
||||||
path: "./var/mipha.sock"
|
-- path: "./var/mipha.sock"
|
||||||
unlink: true
|
-- unlink: true
|
||||||
|
\attach cq
|
||||||
|
|
||||||
assert cq\loop!
|
assert cq\loop!
|
||||||
|
|
Loading…
Reference in New Issue