summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-07-30 23:38:57 +0000
committerTed Trask <ttrask01@yahoo.com>2012-07-30 23:38:57 +0000
commit69bf33f5228291767ad9042b7eedd3f2190d6bd2 (patch)
treefd7d978043ab6f6aa4f4cec46cfb8d72c819a32c
parentf24fa679e99dfb4f1e1e9f5b2d5e19a979055b25 (diff)
downloadacf-iptables-69bf33f5228291767ad9042b7eedd3f2190d6bd2.tar.bz2
acf-iptables-69bf33f5228291767ad9042b7eedd3f2190d6bd2.tar.xz
Removed redirect_to_referrer, fixed startstop by moving iptables-html.lsp file, fixed status to use modelfunctions library
-rw-r--r--iptables-controller.lua4
-rw-r--r--iptables-filterrules-html.lsp (renamed from iptables-html.lsp)4
l---------iptables-manglerules-html.lsp1
-rw-r--r--iptables-model.lua65
l---------iptables-natrules-html.lsp1
5 files changed, 39 insertions, 36 deletions
diff --git a/iptables-controller.lua b/iptables-controller.lua
index 8ea7353..95b2bd6 100644
--- a/iptables-controller.lua
+++ b/iptables-controller.lua
@@ -31,7 +31,7 @@ function createchain(self)
end
function deletechain(self)
- return self:redirect_to_referrer(self.model.delete_chain(self.clientdata.table, self.clientdata.chain))
+ return self.handle_form(self, self.model.get_delete_chain, self.model.delete_chain, self.clientdata, "Delete", "Delete Chain", "Chain deleted")
end
function editrule(self)
@@ -43,7 +43,7 @@ function createrule(self)
end
function deleterule(self)
- return self:redirect_to_referrer(self.model.delete_rule(self.clientdata.table, self.clientdata.chain, self.clientdata.position))
+ return self.handle_form(self, self.model.get_delete_rule, self.model.delete_rule, self.clientdata, "Delete", "Delete Rule", "Rule deleted")
end
function expert(self)
diff --git a/iptables-html.lsp b/iptables-filterrules-html.lsp
index 13433f1..7011016 100644
--- a/iptables-html.lsp
+++ b/iptables-filterrules-html.lsp
@@ -12,7 +12,7 @@
<% if chain.policy then %>
<a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/editchain?chain="..chain.name.."&table="..tab.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/document-properties.png' width='16' height='16' title="Edit Chain"></a>
<% else %>
- <a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/deletechain?chain="..chain.name.."&table="..tab.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/list-remove.png' width='16' height='16' title="Delete Chain"></a>
+ <a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/deletechain?submit=true&chain="..chain.name.."&table="..tab.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/list-remove.png' width='16' height='16' title="Delete Chain"></a>
<% end %>
<%= html.html_escape(chain.name) %>
<% if chain.policy then io.write(" ("..html.html_escape(chain.policy)..")\n") end %>
@@ -22,7 +22,7 @@
<TABLE>
<TR><TD WIDTH='80px' STYLE='padding-left:40px'>
<a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/createrule?table="..tab.."&chain="..chain.name.."&position="..j.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/list-add.png' width='16' height='16' title="Insert Rule"></a>
- <a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/deleterule?table="..tab.."&chain="..chain.name.."&position="..j.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/list-remove.png' width='16' height='16' title="Delete Rule"></a>
+ <a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/deleterule?submit=true&table="..tab.."&chain="..chain.name.."&position="..j.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/list-remove.png' width='16' height='16' title="Delete Rule"></a>
<a href="<%= html.html_escape(page_info.script..page_info.prefix..page_info.controller.."/editrule?table="..tab.."&chain="..chain.name.."&position="..j.."&redir="..page_info.orig_action) %>"><IMG SRC='<%= html.html_escape(page_info.wwwprefix..page_info.staticdir) %>/tango/16x16/actions/document-properties.png' width='16' height='16' title="Edit Rule"></a>
</TD>
<TD WIDTH='50px'><%= html.html_escape(line.packets) %></TD><TD WIDTH='50px'><%= html.html_escape(line.bytes) %></TD>
diff --git a/iptables-manglerules-html.lsp b/iptables-manglerules-html.lsp
new file mode 120000
index 0000000..a93ec0b
--- /dev/null
+++ b/iptables-manglerules-html.lsp
@@ -0,0 +1 @@
+iptables-filterrules-html.lsp \ No newline at end of file
diff --git a/iptables-model.lua b/iptables-model.lua
index 06c4915..e06512e 100644
--- a/iptables-model.lua
+++ b/iptables-model.lua
@@ -193,17 +193,7 @@ end
-- PUBLIC FUNCTIONS
function getstatus()
- local status = {}
-
- local value, errtxt = processinfo.package_version(packagename)
- status.version = cfe({
- label="Program version",
- value=value,
- errtxt=errtxt,
- name=packagename
- })
-
- return cfe({ type="group", value=status, label="IPtables Status" })
+ return modelfunctions.getstatus(servicename, packagename, "IPtables Status")
end
function getstatusdetails()
@@ -309,29 +299,32 @@ function create_chain(self, chain)
return chain
end
-function delete_chain(tab, chain)
- local retval = cfe({ label="Delete Chain result" })
- tab = tab or "filter"
- local chn = find_chain(tab, chain)
+function get_delete_chain(self, clientdata)
+ local retval = {}
+ retval.table = cfe({ type="select", value=clientdata.table or "filter", label="Table", option=tables })
+ retval.chain = cfe({ value=clientdata.chain or "", label="Chain" })
+ return cfe({ type="group", value=retval, label="Delete Chain" })
+end
+
+function delete_chain(self, chain)
+ local chn = find_chain(chain.value.table.value, chain.value.chain.value)
if not chn then
- retval.errtxt = "Could not find chain"
+ chain.errtxt = "Could not find chain"
elseif chn.policy then
- retval.errtxt = "Cannot delete built-in chain"
+ chain.errtxt = "Cannot delete built-in chain"
elseif chn.references and tonumber(chn.references) > 0 then
- retval.errtxt = "Cannot delete chain with references"
+ chain.errtxt = "Cannot delete chain with references"
else
- local cmd = path .. "iptables -t "..format.escapespecialcharacters(tab).." -X "..format.escapespecialcharacters(chain).." 2>&1"
+ local cmd = path .. "iptables -t "..format.escapespecialcharacters(chain.value.table.value).." -X "..format.escapespecialcharacters(chain.value.chain.value).." 2>&1"
local f = io.popen(cmd)
local errtxt = f:read("*a")
if errtxt ~= "" then
- retval.errtxt = errtxt
- else
- retval.value = "Deleted Chain"
+ chain.errtxt = errtxt
end
save()
end
- return retval
+ return chain
end
function read_rule(tab, chain, pos)
@@ -536,20 +529,28 @@ function update_rule(self, rule)
return rule
end
-function delete_rule(tab, chain, pos)
- local cmdresult = cfe({ label="Delete Rule Result" })
- if not tab or not chain or not pos then
- cmdresult.errtxt = "Incomplete specification - must define table, chain, and position"
+function get_delete_rule(self, clientdata)
+ local retval = {}
+ -- Identification
+ retval.table = cfe({ type="select", value=clientdata.table or "filter", label="Table", option=tables })
+ retval.chain = cfe({ value=clientdata.chain or "", label="Chain" })
+ retval.position = cfe({ value=clientdata.position or "", label="Position" })
+ return cfe({ type="group", value=retval, label="Delete Rule" })
+end
+
+function delete_rule(self, rule)
+ if "" == rule.value.table.value or "" == rule.value.chain.value or "" == rule.value.position.value then
+ rule.errtxt = "Incomplete specification - must define table, chain, and position"
else
- local cmd = path .. "iptables -t " .. format.escapespecialcharacters(tab) .. " -D " .. format.escapespecialcharacters(chain) .. " " .. format.escapespecialcharacters(pos)
+ local cmd = path .. "iptables -t " .. format.escapespecialcharacters(rule.value.table.value) .. " -D " .. format.escapespecialcharacters(rule.value.chain.value) .. " " .. format.escapespecialcharacters(rule.value.position.value)
local f = io.popen(cmd)
- cmdresult.value = f:read("*a")
+ rule.errtxt = f:read("*a")
f:close()
- if string.match(cmdresult.value, "^%s*$") then
- cmdresult.value = "Deleted rule"
+ if string.match(rule.errtxt, "^%s*$") then
+ rule.errtxt = nil
end
end
- return cmdresult
+ return rule
end
function readrulesfile()
diff --git a/iptables-natrules-html.lsp b/iptables-natrules-html.lsp
new file mode 120000
index 0000000..a93ec0b
--- /dev/null
+++ b/iptables-natrules-html.lsp
@@ -0,0 +1 @@
+iptables-filterrules-html.lsp \ No newline at end of file