From 15eff0f588679d3743475941345da9a46544f431 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 18 Apr 2012 01:23:12 +0000 Subject: Started work on updating for acf-core-0.15 Removed controllerfunctions library (still needs more work and corresponding work in model) Updated startstop functionality and deleted view Updated for viewfunctions to htmlviewfunctions and modified require statements for acf libraries --- iptables-controller.lua | 21 +++++----------- iptables-details-html.lsp | 1 - iptables-editchain-html.lsp | 4 +-- iptables-editrule-html.lsp | 60 ++++++++++++++++++++++----------------------- iptables-html.lsp | 4 +-- iptables-model.lua | 14 +++++++---- iptables-startstop-html.lsp | 24 ------------------ 7 files changed, 49 insertions(+), 79 deletions(-) delete mode 100644 iptables-startstop-html.lsp diff --git a/iptables-controller.lua b/iptables-controller.lua index 2cecc56..8ea7353 100644 --- a/iptables-controller.lua +++ b/iptables-controller.lua @@ -1,14 +1,5 @@ module(..., package.seeall) --- Load libraries -require("controllerfunctions") - --- ################################################################################ --- LOCAL FUNCTIONS - --- ################################################################################ --- PUBLIC FUNCTIONS - default_action = "status" function status(self) @@ -32,11 +23,11 @@ function manglerules(self) end function editchain(self) - return controllerfunctions.handle_form(self, function() return self.model.read_chain(self.clientdata.table, self.clientdata.chain or "") end, self.model.update_chain, self.clientdata, "Save", "Edit Chain", "Chain saved") + return self.handle_form(self, function() return self.model.read_chain(self.clientdata.table, self.clientdata.chain or "") end, self.model.update_chain, self.clientdata, "Save", "Edit Chain", "Chain saved") end function createchain(self) - return controllerfunctions.handle_form(self, function() return self.model.read_chain(self.clientdata.table) end, self.model.create_chain, self.clientdata, "Create", "Create New Chain", "Chain created") + return self.handle_form(self, function() return self.model.read_chain(self.clientdata.table) end, self.model.create_chain, self.clientdata, "Create", "Create New Chain", "Chain created") end function deletechain(self) @@ -44,11 +35,11 @@ function deletechain(self) end function editrule(self) - return controllerfunctions.handle_form(self, function() return self.model.read_rule(self.clientdata.table, self.clientdata.chain or "", self.clientdata.position or "") end, self.model.update_rule, self.clientdata, "Save", "Edit Rule", "Rule saved") + return self.handle_form(self, function() return self.model.read_rule(self.clientdata.table, self.clientdata.chain or "", self.clientdata.position or "") end, self.model.update_rule, self.clientdata, "Save", "Edit Rule", "Rule saved") end function createrule(self) - return controllerfunctions.handle_form(self, function() return self.model.read_rule(self.clientdata.table, self.clientdata.chain, self.clientdata.position) end, self.model.create_rule, self.clientdata, "Create", "Create New Rule", "Rule created") + return self.handle_form(self, function() return self.model.read_rule(self.clientdata.table, self.clientdata.chain, self.clientdata.position) end, self.model.create_rule, self.clientdata, "Create", "Create New Rule", "Rule created") end function deleterule(self) @@ -56,9 +47,9 @@ function deleterule(self) end function expert(self) - return controllerfunctions.handle_form(self, self.model.readrulesfile, self.model.updaterulesfile, self.clientdata, "Save", "Edit Rules File", "Rules File Saved") + return self.handle_form(self, self.model.readrulesfile, self.model.updaterulesfile, self.clientdata, "Save", "Edit Rules File", "Rules File Saved") end function startstop(self) - return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata) + return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) end diff --git a/iptables-details-html.lsp b/iptables-details-html.lsp index c15ab2a..5310f67 100644 --- a/iptables-details-html.lsp +++ b/iptables-details-html.lsp @@ -1,5 +1,4 @@ <% local data, viewlibrary = ... -require("viewfunctions") %> <% viewlibrary.dispatch_component("status") %> diff --git a/iptables-editchain-html.lsp b/iptables-editchain-html.lsp index 9514d5b..af06bb6 100644 --- a/iptables-editchain-html.lsp +++ b/iptables-editchain-html.lsp @@ -1,5 +1,5 @@ <% local form, viewlibrary, page_info = ... -require("viewfunctions") +require("htmlviewfunctions") %>

<%= html.html_escape(form.label) %>

@@ -11,5 +11,5 @@ require("viewfunctions") form.value.chain.readonly = true end local order = {"table", "chain", "policy"} - displayform(form, order) + htmlviewfunctions.displayform(form, order) %> diff --git a/iptables-editrule-html.lsp b/iptables-editrule-html.lsp index 7e4d156..da1fc61 100644 --- a/iptables-editrule-html.lsp +++ b/iptables-editrule-html.lsp @@ -1,5 +1,5 @@ <% local form, viewlibrary, page_info = ... -require("viewfunctions") +require("htmlviewfunctions") %>

<%= html.html_escape(form.label) %>

@@ -10,47 +10,47 @@ form.value.table.type = "text" form.value.chain.readonly = true form.value.position.readonly = true form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action -displayformstart(form) +htmlviewfunctions.displayformstart(form) %>

Rule Identification

<% -displayformitem(form.value.table) -displayformitem(form.value.chain) -displayformitem(form.value.position) +htmlviewfunctions.displayformitem(form.value.table) +htmlviewfunctions.displayformitem(form.value.chain) +htmlviewfunctions.displayformitem(form.value.position) %>

Basic Parameters

<% -displayformitem(form.value.jump) -displayformitem(form.value.protocol) -displayformitem(form.value.in_interface) -displayformitem(form.value.out_interface) -displayformitem(form.value.source) -displayformitem(form.value.destination) +htmlviewfunctions.displayformitem(form.value.jump) +htmlviewfunctions.displayformitem(form.value.protocol) +htmlviewfunctions.displayformitem(form.value.in_interface) +htmlviewfunctions.displayformitem(form.value.out_interface) +htmlviewfunctions.displayformitem(form.value.source) +htmlviewfunctions.displayformitem(form.value.destination) %>
<% -displayformitem(form.value.goto) -displayformitem(form.value.fragment) -displayformitem(form.value.set_counters) +htmlviewfunctions.displayformitem(form.value.goto) +htmlviewfunctions.displayformitem(form.value.fragment) +htmlviewfunctions.displayformitem(form.value.set_counters) %>

Extended Parameters

<% -displayformitem(form.value.comment) -displayformitem(form.value.addrtype_src_type) -displayformitem(form.value.addrtype_dst_type) -displayformitem(form.value.icmp_type) -displayformitem(form.value.src_range) -displayformitem(form.value.dst_range) -displayformitem(form.value.mac_source) -displayformitem(form.value.sports) -displayformitem(form.value.dports) -displayformitem(form.value.ports) -displayformitem(form.value.state) -displayformitem(form.value.tcp_sport) -displayformitem(form.value.tcp_dport) -displayformitem(form.value.udp_sport) -displayformitem(form.value.udp_dport) +htmlviewfunctions.displayformitem(form.value.comment) +htmlviewfunctions.displayformitem(form.value.addrtype_src_type) +htmlviewfunctions.displayformitem(form.value.addrtype_dst_type) +htmlviewfunctions.displayformitem(form.value.icmp_type) +htmlviewfunctions.displayformitem(form.value.src_range) +htmlviewfunctions.displayformitem(form.value.dst_range) +htmlviewfunctions.displayformitem(form.value.mac_source) +htmlviewfunctions.displayformitem(form.value.sports) +htmlviewfunctions.displayformitem(form.value.dports) +htmlviewfunctions.displayformitem(form.value.ports) +htmlviewfunctions.displayformitem(form.value.state) +htmlviewfunctions.displayformitem(form.value.tcp_sport) +htmlviewfunctions.displayformitem(form.value.tcp_dport) +htmlviewfunctions.displayformitem(form.value.udp_sport) +htmlviewfunctions.displayformitem(form.value.udp_dport) %>

<%= html.html_escape(form.option) %>

-<% displayformend(form) %> +<% htmlviewfunctions.displayformend(form) %> diff --git a/iptables-html.lsp b/iptables-html.lsp index 832568f..13433f1 100644 --- a/iptables-html.lsp +++ b/iptables-html.lsp @@ -1,7 +1,7 @@ <% local data, viewlibrary, page_info, session = ... %> -<% require("viewfunctions") %> +<% require("htmlviewfunctions") %> -<% displaycommandresults({"editchain", "deletechain", "createrule", "deleterule", "editrule", "createchain"}, session) %> +<% htmlviewfunctions.displaycommandresults({"editchain", "deletechain", "createrule", "deleterule", "editrule", "createchain"}, session) %>

<%= html.html_escape(data.label) %>

diff --git a/iptables-model.lua b/iptables-model.lua index d1443d3..162c357 100644 --- a/iptables-model.lua +++ b/iptables-model.lua @@ -2,9 +2,9 @@ module(..., package.seeall) -- Load libraries require("modelfunctions") -require("fs") -require("format") -require("validator") +fs = require("acf.fs") +format = require("acf.format") +validator = require("acf.validator") -- Set variables local packagename = "iptables" @@ -562,6 +562,10 @@ function updaterulesfile(filedetails) return modelfunctions.setfiledetails(filedetails, {rulesfile}) end -function startstop_service(action) - return modelfunctions.startstop_service(servicename, action, {"Start", "Stop", "Restart", "Save", "Reload", "Panic"}) +function get_startstop(clientdata) + return modelfunctions.get_startstop(servicename) +end + +function startstop_service(startstop, action) + return modelfunctions.startstop_service(startstop, action) end diff --git a/iptables-startstop-html.lsp b/iptables-startstop-html.lsp deleted file mode 100644 index 26cbe9a..0000000 --- a/iptables-startstop-html.lsp +++ /dev/null @@ -1,24 +0,0 @@ -<% local data, viewlibrary, page_info = ... %> - -

Management

- -<% if data.value.result then %> -

Previous action result

-<% if data.value.result.value ~= "" then %> -

<%= string.gsub(html.html_escape(data.value.result.value), "\n", "
") %>

-<% end if data.value.result.errtxt then %> -

<%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "
") %>

-<% end end %> - -
-
" method="POST"> -
Load rules from rules file
-
- -
-
Save current rules to rules file
-
- -
-
-
-- cgit v1.2.3