diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-10-10 13:11:01 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-10-10 13:11:01 +0200 |
commit | f6bfac21173a1312152f0fdd623a417cf7fa53d1 (patch) | |
tree | 1788720fa898a992a92879ccc13696caaf5a3ed2 /modules/luci-mod-status/luasrc/controller/admin/status.lua | |
parent | 24d1e7608b23cd80eca41a78916a2a0f2bd224c2 (diff) |
luci-mod-status: rework iptables status page
- Parse and format iptables listing in client side JS
- Dynamically update packet counters
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-status/luasrc/controller/admin/status.lua')
-rw-r--r-- | modules/luci-mod-status/luasrc/controller/admin/status.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/luci-mod-status/luasrc/controller/admin/status.lua b/modules/luci-mod-status/luasrc/controller/admin/status.lua index 4f04cce54..5b496d83f 100644 --- a/modules/luci-mod-status/luasrc/controller/admin/status.lua +++ b/modules/luci-mod-status/luasrc/controller/admin/status.lua @@ -8,6 +8,7 @@ function index() entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1) entry({"admin", "status", "iptables"}, template("admin_status/iptables"), _("Firewall"), 2).leaf = true + entry({"admin", "status", "iptables_dump"}, call("dump_iptables")).leaf = true entry({"admin", "status", "iptables_action"}, post("action_iptables")).leaf = true entry({"admin", "status", "routes"}, template("admin_status/routes"), _("Routes"), 3) @@ -44,6 +45,37 @@ function action_dmesg() luci.template.render("admin_status/dmesg", {dmesg=dmesg}) end +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 + local ipt = io.popen( + "/usr/sbin/%stables -t %s --line-numbers -nxvL" + %{ prefix, table }) + + if ipt then + luci.http.prepare_content("text/plain") + + while true do + s = ipt:read(1024) + if not s then break end + luci.http.write(s) + end + + ipt:close() + return + end + end + end + end + + luci.http.status(404, "No such table") + luci.http.prepare_content("text/plain") +end + function action_iptables() if luci.http.formvalue("zero") then if luci.http.formvalue("family") == "6" then |