From: Jo-Philipp Wich Date: Sat, 30 May 2009 18:06:08 +0000 (+0000) Subject: applications/luci-splash: fix mac address detection in mixed IPv4/IPv6 environments X-Git-Tag: 0.8.8~32 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=a89c1fa5d241de47e1efd490ad3f14e37fdcb654;p=project%2Fluci.git applications/luci-splash: fix mac address detection in mixed IPv4/IPv6 environments --- diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua index 5731efc8ca..c209647207 100644 --- a/applications/luci-splash/luasrc/controller/splash/splash.lua +++ b/applications/luci-splash/luasrc/controller/splash/splash.lua @@ -19,7 +19,10 @@ function action_dispatch() end function action_activate() - local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) + local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1" + local mac = luci.sys.net.ip4mac( + ip:match("::") and (ip:gsub("^%[::ffff:(.+)%]", "%1")) or ip + ) if mac and luci.http.formvalue("accept") then os.execute("luci-splash add "..mac.." >/dev/null 2>&1") luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage"))