2015-01-16 22:38:38 +00:00
|
|
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
2015-01-16 22:46:42 +00:00
|
|
|
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
|
2015-01-16 22:38:38 +00:00
|
|
|
-- Licensed to the public under the Apache License 2.0.
|
2011-08-12 13:16:27 +00:00
|
|
|
|
2008-05-25 17:00:30 +00:00
|
|
|
module("luci.controller.admin.status", package.seeall)
|
2008-05-13 17:32:11 +00:00
|
|
|
|
|
|
|
function action_syslog()
|
2008-05-25 17:00:30 +00:00
|
|
|
local syslog = luci.sys.syslog()
|
|
|
|
luci.template.render("admin_status/syslog", {syslog=syslog})
|
2008-11-16 22:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function action_dmesg()
|
|
|
|
local dmesg = luci.sys.dmesg()
|
|
|
|
luci.template.render("admin_status/dmesg", {dmesg=dmesg})
|
|
|
|
end
|
2009-02-08 03:56:50 +00:00
|
|
|
|
2018-10-10 11:11:01 +00:00
|
|
|
function dump_iptables(family, table)
|
|
|
|
local prefix = (family == "6") and "ip6" or "ip"
|
|
|
|
local ok, lines = pcall(io.lines, "/proc/net/%s_tables_names" % prefix)
|
|
|
|
if ok and lines then
|
|
|
|
local s
|
|
|
|
for s in lines do
|
|
|
|
if s == table then
|
2018-12-02 19:15:34 +00:00
|
|
|
luci.http.prepare_content("text/plain")
|
|
|
|
luci.sys.process.exec({
|
|
|
|
"/usr/sbin/%stables" % prefix, "-w", "-t", table,
|
|
|
|
"--line-numbers", "-nxvL"
|
|
|
|
}, luci.http.write)
|
|
|
|
return
|
2018-10-10 11:11:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
luci.http.status(404, "No such table")
|
|
|
|
luci.http.prepare_content("text/plain")
|
|
|
|
end
|
|
|
|
|
2009-02-08 03:56:50 +00:00
|
|
|
function action_iptables()
|
2011-01-29 22:50:13 +00:00
|
|
|
if luci.http.formvalue("zero") then
|
2015-10-20 20:27:39 +00:00
|
|
|
if luci.http.formvalue("family") == "6" then
|
|
|
|
luci.util.exec("/usr/sbin/ip6tables -Z")
|
2011-01-29 22:50:13 +00:00
|
|
|
else
|
2015-10-20 20:27:39 +00:00
|
|
|
luci.util.exec("/usr/sbin/iptables -Z")
|
2011-01-29 22:50:13 +00:00
|
|
|
end
|
2015-10-20 20:27:39 +00:00
|
|
|
elseif luci.http.formvalue("restart") then
|
2015-07-03 14:59:37 +00:00
|
|
|
luci.util.exec("/etc/init.d/firewall restart")
|
2009-02-08 03:56:50 +00:00
|
|
|
end
|
2015-10-20 20:27:39 +00:00
|
|
|
|
|
|
|
luci.http.redirect(luci.dispatcher.build_url("admin/status/iptables"))
|
2009-02-08 03:56:50 +00:00
|
|
|
end
|