Restrict To Localhost

From PlainOldWebserver

Jump to: navigation, search

I want to use POW to experiment with server side javascript but don't want to expose my efforts to the world (or even others on the local network) just yet. I want POW to respond only to requests on the loopback connector (127.0.0.1, localhost).

It's easy to make POW do this by editing the source code in the server.js file. Change line 496

               from: 	pow_serv.init(pow_global_port,false,-1);
                 to:	pow_serv.init(pow_global_port,true,-1);

Apparently, the second parameter in this function tells the socket listener created by Mozilla whether or not to only respond to requests on the loopback.

I know next to nothing about coding Firefox extensions, but thanks to comments by Jeff Walden on a post about POW at Ajaxian (http://ajaxian.com/archives/pow-excuse-me-sir-you-seem-to-have-a-server-in-your-client), and a link to the source of the Mozilla web server he wrote (http://lxr.mozilla.org/mozilla/source/netwerk/test/httpserver/httpd.js), it was pretty easy to figure out.

Where is the server.js file, you say? All the POW code is in C:\Documents and Settings\UserName\Application Data\Mozilla\Firefox\Profiles\SomeNumber.default\extensions\{5776FCEA-FDBF-11DA-A132-001321F5C1D9}\chrome\pow.jar (on Windows -- don't know on OSX or 'nix)

The pow.jar file is really just a .zip file. Rename it with a .zip extension and you can unzip it and find the source code files. Edit, rezip, your modifications are live.


Update: You can Download an extension with all 0.1.0 bug fixes from the wiki and Restriction to Local Host at the link below.

http://www.scottwickham.com/dr/dr-0.1.0.xpi

FYI: I named it DR -- or the Doctor for Desktop Runtime

This is fixed in POW 0.1.2.

Personal tools
Navigation