[luci] To Get Client IP Addr - luci.http is imcomplete in lucittpd.
Patrick Sun
lawipac at gmail.com
Fri Jan 15 03:09:36 CET 2010
Hi JoW,
> >Try to obtain the client addr with:
> >
> >local addr = luci.http.getenv("REMOTE_ADDR") .. ":" ..
> > luci.http.getenv("REMOTE_PORT")
The luci.http.getenv actually works very well if we deploy it
to a real remote host with busybox httpd. It only refuse to work
under lucittpd.
I think the reason is that Lucittpd does not give a proper
emulation of luci.http parameters; It's quite OK with
most of module development with LuCI though.
What I did was try to print the table luci.http.getenv() returned
on both lucittpd and busybox-httpd, and the output is as follows
On lucittpd:
> HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> PATH_INFO /test/test
> SCRIPT_NAME /luci
> QUERY_STRING
> HTTP_ACCEPT_ENCODING gzip,deflate
> HTTP_USER_AGENT Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7
> HTTP_REFERER http://localhost:8080/luci/bandwidthc
> HTTP_HOST localhost:8080
> HTTP_ACCEPT_LANGUAGE en-us,zh-cn;q=0.7,zh;q=0.3
> HTTP_CONNECTION keep-alive
> HTTP_ACCEPT_CHARSET GB2312,utf-8;q=0.7,*;q=0.7
> SCRIPT_FILENAME
> REQUEST_URI /luci/bandwidthc/test
> SERVER_PROTOCOL HTTP/1.1
> REQUEST_METHOD GET
while on busybox httpd:
> HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> CONFIG_cfg024e53_TYPE httpd
> CONFIG_NUM_SECTIONS 1
> HOME /
> CONFIG_cfg02f02f_TYPE system
> GATEWAY_INTERFACE CGI/1.1
> CONFIG_SECTIONS cfg024e53
> home /www
> CONFIG_cfg04315a_TYPE button
> SCRIPT_FILENAME /www/cgi-bin/l
> REQUEST_URI /cgi-bin/l/test/test
> c_file
> CONFIG_cfg0638e0_TYPE button
> CONFIG_cfg04315a_button reset
> CONFIG_cfg0638e0_button reset
> CONFIG_cfg024e53_port 80
> CONFIG_cfg04315a_handler logger reboot
> CONFIG_cfg0638e0_max 30
> HTTP_ACCEPT_LANGUAGE en-us;q=0.7,zh;q=0.3
> CONFIG_cfg0638e0_min 5
> CONFIG_cfg024e53_home /www
> HTTP_USER_AGENT Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7
> CONFIG_SECTION cfg024e53
> CONFIG_cfg0638e0_handler logger factory default
> SCRIPT_NAME /cgi-bin/l
> TERM vt102
> PWD /
> HTTP_REFERER http://192.168.1.1/cgi-bin/l/mini/
> CONFIG_cfg04315a_min 0
> port 80
> CONTENT_TYPE application/x-www-form-urlencoded
> hostname OpenWrt
> CONFIG_cfg04315a_max 4
> HTTP_COOKIE sysauth=AFB48B008DA348DC6A6AE50D63449627
> CONTENT_LENGTH 23
> realm OpenWrt
> REMOTE_PORT 55111
> SHELL /bin/sh
> REMOTE_ADDR 192.168.1.2
> CONFIG_cfg02f02f_hostname OpenWrt
> SERVER_PROTOCOL HTTP/1.0
> PATH /sbin:/usr/sbin:/bin:/usr/bin
> QUERY_STRING
> SERVER_SOFTWARE busybox httpd/1.11.2
> USER root
> PATH_INFO /test/test
> cfgtype httpd
> args -p 80 -h "/www" -r "OpenWrt"
> CONFIG_cfg04315a_action released
> CONFIG_cfg0638e0_action released
> CONFIG_cfg02f02f_timezone UTC
> REQUEST_METHOD POST
We can notice a lot of difference between the two..
Regards
Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.subsignal.org/pipermail/luci/attachments/20100115/1bb954e7/attachment.htm
More information about the luci
mailing list