[luci] To Get Client IP Addr - Lucittpd seems not running in CGI Mode

Jo-Philipp Wich xm at subsignal.org
Thu Jan 14 13:08:43 CET 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Patrick Sun schrieb:
> Hi all,
> 
> Can anyone with a deep understanding of LuCI give me a hint on how
> Lucittpd works with LuCI?

Sure.

Lucittpd is an application server implemented in Lua and C. It preloads
the LuCI framework on the server start and keeps it in memory, this
speeds up serving of requests and allows more control over the HTTP
communication, means low level access to the client connection,
including custom HTTP message parsing etc.

> maybe lucittpd  always think 'http://localhost:8080/luci' as a script to
> run.

The '/luci' is a virtual url registered in the server, any request to
this particular resource is mapped to an internal LuCI handler.

> Which local file  does http://localhost:8080/luci  maps to ?

None. It is intercepted by the server and handled by a LuCI handler.



Regarding your question about the environment;
Even in the case of lucittpd, the usual env vars are simulated, however
you should not access them via os.getenv() since this will only work
when running as CGI application. There is a higher level abstraction
api, luci.http.getenv() which should be used.

Try to obtain the client addr with:

local addr = luci.http.getenv("REMOTE_ADDR") .. ":" ..
    luci.http.getenv("REMOTE_PORT")


~ JoW
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktPCUoACgkQdputYINPTPNEpQCeP1LMdfrXImjzJCBEVhtM6RTF
Fa0An2EUsV0qjV4BRDktaDpASAJ/vnG9
=jA8W
-----END PGP SIGNATURE-----


More information about the luci mailing list