<commit_before>module("luci.controller.splash.splash", package.seeall)

function index()
	entry({"admin", "services", "splash"}, cbi("splash/splash"), "Client-Splash")

	node("splash").target = call("action_dispatch")
	node("splash", "activate").target = call("action_activate")
	node("splash", "splash").target   = template("splash_splash/splash")
end

function action_dispatch()
	local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
	local status = luci.util.execl("luci-splash status "..mac)[1]
	if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then
		luci.http.redirect(luci.dispatcher.build_url())
	else
		luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
	end
end

function action_activate()
	local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR"))
	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"))
	else
		luci.http.redirect(luci.dispatcher.build_url())
	end
end<commit_msg>applications/luci-splash: properly fix mac address detection in mixed IPv4/IPv6 environments (thanks stargieg)<commit_after>module("luci.controller.splash.splash", package.seeall)

function index()
	entry({"admin", "services", "splash"}, cbi("splash/splash"), "Client-Splash")

	node("splash").target = call("action_dispatch")
	node("splash", "activate").target = call("action_activate")
	node("splash", "splash").target   = template("splash_splash/splash")
end

function action_dispatch()
	local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
	local status = luci.util.execl("luci-splash status "..mac)[1]
	if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then
		luci.http.redirect(luci.dispatcher.build_url())
	else
		luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
	end
end

function action_activate()
	local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1"
	local mac = luci.sys.net.ip4mac(ip:match("^[\[::ffff:]*(%d+.%d+%.%d+%.%d+)\]*$"))
	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"))
	else
		luci.http.redirect(luci.dispatcher.build_url())
	end
end
{'fraction_non_alphanumeric': 0.18955926401369277, 'fraction_numerical': 0.008557980316645272, 'mean_word_length': 5.718390804597701, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6814323', 'n_tokens_mistral': 903, 'n_tokens_neox': 862, 'n_words': 149}