make the gemini server more generic
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
cd8a9a1168
commit
d5dfe68ad6
37
gemini.moon
37
gemini.moon
|
@ -1,17 +1,5 @@
|
||||||
cqueues = require "cqueues"
|
|
||||||
socket = require "cqueues.socket"
|
|
||||||
ln = require "ln"
|
|
||||||
url = require "net.url"
|
url = require "net.url"
|
||||||
|
|
||||||
srv = socket.listen "127.0.0.1", "58816"
|
|
||||||
|
|
||||||
cq = cqueues.new!
|
|
||||||
|
|
||||||
class ProxyRequestRefusedHandler
|
|
||||||
run: (ctx, conn) =>
|
|
||||||
conn\write "53 Proxy request refused \r\n"
|
|
||||||
ln.log ctx, {status: 53}
|
|
||||||
|
|
||||||
class Server
|
class Server
|
||||||
new: (cq, hdlr) =>
|
new: (cq, hdlr) =>
|
||||||
@cq = cq
|
@cq = cq
|
||||||
|
@ -30,26 +18,9 @@ class Server
|
||||||
host: u.host
|
host: u.host
|
||||||
path: u.path
|
path: u.path
|
||||||
query: u.query
|
query: u.query
|
||||||
@hdlr\run ctx, conn
|
@hdlr\serve ctx, conn
|
||||||
\close!
|
\close!
|
||||||
|
|
||||||
-- cq\wrap ->
|
{
|
||||||
-- for conn in srv\clients!
|
:Server
|
||||||
-- cq\wrap ->
|
}
|
||||||
-- with conn
|
|
||||||
-- _, ip = \peername!
|
|
||||||
-- request = \read "*l"
|
|
||||||
-- u = url.parse request
|
|
||||||
-- ctx =
|
|
||||||
-- :ip
|
|
||||||
-- host: u.host
|
|
||||||
-- path: u.path
|
|
||||||
-- query: u.query
|
|
||||||
-- ln.log ctx
|
|
||||||
-- \write "53 Proxy request refused\r\n"
|
|
||||||
-- \close!
|
|
||||||
|
|
||||||
with Server cq, ProxyRequestRefusedHandler!
|
|
||||||
\listen srv
|
|
||||||
|
|
||||||
assert cq\loop!
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
cqueues = require "cqueues"
|
||||||
|
socket = require "cqueues.socket"
|
||||||
|
ln = require "ln"
|
||||||
|
|
||||||
|
gemini = require "gemini"
|
||||||
|
|
||||||
|
cq = cqueues.new!
|
||||||
|
|
||||||
|
class ProxyRequestRefusedHandler
|
||||||
|
serve: (ctx, conn) =>
|
||||||
|
conn\write "53 Proxy request refused \r\n"
|
||||||
|
ln.log ctx, {status: 53}
|
||||||
|
|
||||||
|
with gemini.Server cq, ProxyRequestRefusedHandler!
|
||||||
|
\listen socket.listen "127.0.0.1", "58816"
|
||||||
|
\listen socket.listen
|
||||||
|
path: "./var/mipha.sock"
|
||||||
|
unlink: true
|
||||||
|
|
||||||
|
assert cq\loop!
|
Loading…
Reference in New Issue