X-Git-Url: http://git.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-mod-status%2Fluasrc%2Fview%2Fadmin_status%2Fiptables.htm;fp=modules%2Fluci-mod-status%2Fluasrc%2Fview%2Fadmin_status%2Fiptables.htm;h=51e428e40e01a66402134c2bf0b60b3cab0e2467;hp=0000000000000000000000000000000000000000;hb=58d97b5e271bc0d7507eab5b9bd2902181864e02;hpb=6ec0353201435e0d0d7d32820d8ba600b4ca7b5b diff --git a/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm b/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm new file mode 100644 index 0000000000..51e428e40e --- /dev/null +++ b/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm @@ -0,0 +1,155 @@ +<%# + Copyright 2008-2009 Steven Barth + Copyright 2008-2015 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-%> + +<%- + + require "luci.sys.iptparser" + local wba = require "luci.tools.webadmin" + local fs = require "nixio.fs" + local io = require "io" + + local has_ip6tables = fs.access("/usr/sbin/ip6tables") + local mode = 4 + + if has_ip6tables then + mode = luci.dispatcher.context.requestpath + mode = tonumber(mode[#mode] ~= "iptables" and mode[#mode]) or 4 + end + + local ipt = luci.sys.iptparser.IptParser(mode) + + local rowcnt = 1 + function rowstyle() + rowcnt = rowcnt + 1 + return (rowcnt % 2) + 1 + end + + function link_target(t,c) + if ipt:is_custom_target(c) then + return '%s' %{ t:lower(), c, c } + end + return c + end + + function link_iface(i) + local net = wba.iface_get_network(i) + if net and i ~= "lo" then + return '%s' %{ + url("admin/network/network", net), i + } + + end + return i + end + + local tables = { "Filter", "NAT", "Mangle", "Raw" } + if mode == 6 then + tables = { "Filter", "Mangle", "Raw" } + local ok, lines = pcall(io.lines, "/proc/net/ip6_tables_names") + if ok and lines then + local line + for line in lines do + if line == "nat" then + tables = { "Filter", "NAT", "Mangle", "Raw" } + end + end + end + end +-%> + +<%+header%> + + + +

<%:Firewall Status%>

+ +<% if has_ip6tables then %> + +<% end %> + +
+ +
" style="position: absolute; right: 0"> + + + + +
+ +
+ + <% for _, tbl in ipairs(tables) do chaincnt = 0 %> +

<%:Table%>: <%=tbl%>

+ + <% for _, chain in ipairs(ipt:chains(tbl)) do + rowcnt = 0 + chaincnt = chaincnt + 1 + chaininfo = ipt:chain(tbl, chain) + %> +

+ <%:Chain%> <%=chain%> + (<%- if chaininfo.policy then -%> + <%:Policy%>: <%=chaininfo.policy%>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%> + <%- else -%> + <%:References%>: <%=chaininfo.references-%> + <%- end -%>) +

+ +
+
+
+
<%:Pkts.%>
+
<%:Traffic%>
+
<%:Target%>
+
<%:Prot.%>
+
<%:In%>
+
<%:Out%>
+
<%:Source%>
+
<%:Destination%>
+
<%:Options%>
+
+ + <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %> +
+
<%=rule.packets%>
+
<%=wba.byte_format(rule.bytes)%>
+
<%=rule.target and link_target(tbl, rule.target) or "-"%>
+
<%=rule.protocol%>
+
<%=link_iface(rule.inputif)%>
+
<%=link_iface(rule.outputif)%>
+
<%=rule.source%>
+
<%=rule.destination%>
+
<%=#rule.options > 0 and luci.util.pcdata(table.concat(rule.options, " ")) or "-"%>
+
+ <% end %> + + <% if rowcnt == 1 then %> +
+
<%:No rules in this chain%>
+
+ <% end %> +
+
+ <% end %> + + <% if chaincnt == 0 then %> + <%:No chains in this table%> + <% end %> + +

+ <% end %> +
+
+ +<%+footer%>