webserv.r for local use?
[1/5] from: jeremy:bear:gm:ail at: 15-Mar-2005 22:00
Hello, I have a question regarding webserv.r. I'm considering using it for an application that will be only used locally. I don't really want to use it as a web server, but more like an application server. Is there any way that I can make it so that only the local machine that it's running on can connect the the port it opens? Thanks, Jeremy
[2/5] from: antonr::lexicon::net at: 16-Mar-2005 15:48
Check port/remote-ip, if it is not localhost (127.0.0.1) then immediately close the connection to that port. Otherwise I guess you could use a firewall to prevent machines connecting to start with. Anton.
[3/5] from: jeremy::bear::gmail::com at: 15-Mar-2005 23:18
Hmmmm... Okay, I'm really showing my ignorance here, but I'm pretty new to Rebol. How do I check port/remote-ip? Thanks. On Wed, 16 Mar 2005 15:48:32 +1100, Anton Rolls <[antonr--lexicon--net]> wrote:
[4/5] from: antonr::lexicon::net at: 17-Mar-2005 1:42
Ok, example: 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 change: if error? try [ request: parse first (conn: first listen) none ] [ close conn return ] to: 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. Anton.
[5/5] from: jeremy::bear::gmail::com at: 16-Mar-2005 20:20
Ah, thank you, Anton. I believe I understand now. I'll give it a shot and see what I can come up with. Thanks, Jeremy On Thu, 17 Mar 2005 01:42:31 +1100, Anton Rolls <[antonr--lexicon--net]> wrote: