[REBOL] Re: webserv.r for local use?
From: antonr::lexicon::net at: 17-Mar-2005 1:42
Open up a rebol console and type this:
listen: open tcp://:4351
wait listen conn: first listen
Now open up a second rebol console and type:
port: open tcp://127.0.0.1:4351
Back at the first console:
type? conn ;== port!
conn/remote-ip ;== 127.0.0.1
So here is where you examine the remote-ip and decide whether to close
the port or not.
Now, I've used words similar to those used in webserv.r, but here
is the line in the handle-new-connections function I think you need to
if error? try [ request: parse first (conn: first listen) none ] [ close
conn return ]
if error? try [
conn: first listen ; conn is a port!
if conn/remote-ip <> 127.0.0.1 [make error! "Non-local connection!"]
request: parse first conn none
][close conn return]
I haven't tested it, but that should work.