diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-03-03 16:54:31 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-03-03 16:54:31 +0000 |
commit | 8c41156d76be7332fd34d1ab18a078510745b81a (patch) | |
tree | b6c940129b860f8844e6c031e47ef9120b673a45 | |
parent | 7c698f58e0661639b5bff855e82a76fff8c90b65 (diff) | |
download | acf-shorewall-8c41156d76be7332fd34d1ab18a078510745b81a.tar.bz2 acf-shorewall-8c41156d76be7332fd34d1ab18a078510745b81a.tar.xz |
Cleaning up the code a bit.
Adding some examples into the config-tab.
Minor modifications on the view-files.
git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@794 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | shorewall-controller.lua | 12 | ||||
-rw-r--r-- | shorewall-edit-html.lsp | 10 | ||||
-rw-r--r-- | shorewall-model.lua | 98 |
3 files changed, 27 insertions, 93 deletions
diff --git a/shorewall-controller.lua b/shorewall-controller.lua index a2ff244..efcaa65 100644 --- a/shorewall-controller.lua +++ b/shorewall-controller.lua @@ -71,8 +71,20 @@ function config(self) local status=getstatus(self) -- Add a [New] record to the options + table.insert(config.interfaces_list.option, "[New]") table.insert(config.zones_list.option, "[New]") table.insert(config.policies_list.option, "[New]") + table.insert(config.rules_list.option, "[New]") + + -- Add button + config.interfaces_list_cmd = cfe ({ + name="interfaces_list_cmd", + label="Edit above record", + value="Edit", + type="submit", + disabled="yes", + }) + config.interfaces_list_cmd.descr="Mark a item in above list before pressing [" .. config.interfaces_list_cmd.value .. "]" -- Add button config.zones_list_cmd = cfe ({ diff --git a/shorewall-edit-html.lsp b/shorewall-edit-html.lsp index bc9b409..c5f9e6e 100644 --- a/shorewall-edit-html.lsp +++ b/shorewall-edit-html.lsp @@ -8,7 +8,6 @@ io.write("</span>") ?> <? function informationform(myform,tags) - io.write("<DL>") for k,v in pairs(tags) do if (myform[v]) then local val = myform[v] @@ -22,12 +21,10 @@ function informationform(myform,tags) io.write("\t\t</DD>\n") end end - io.write("</DL>") end ?> <? function configform(myform,tags) - io.write("<DL>") for k,v in pairs(tags) do if (myform[v]) then local val = myform[v] @@ -41,17 +38,18 @@ function configform(myform,tags) io.write("\t\t</DD>\n") end end - io.write("</DL>") end ?> <H1>SYSTEM INFO</H1> +<DL> <? local myform = form.status local tags = { "status", "version", } informationform(myform,tags) ?> +</DL> <H1>CONFIGURATION</H1> <? local myform = form.config ?> @@ -60,6 +58,7 @@ informationform(myform,tags) <H2>EXPERT CONFIGURATION</H2> <H3>FILE DETAILS</H3> +<DL> <? local tags = { "filename", } informationform(myform,tags) @@ -71,6 +70,7 @@ informationform(myform,tags) local tags = { "filesize", "mtime", "sumerrors" } informationform(myform,tags) ?> +</DL> <H3>FILE CONTENT</H3> <input type="hidden" value="<?= myform.filename.value ?>" name="<?= myform.filename.name ?>"> @@ -79,10 +79,12 @@ io.write(html.form[form.config.filecontent.type](form.config.filecontent)) ?> <H2>SAVE AND APPLY ABOVE SETTINGS</H2> +<DL> <? local tags = { "cmdsave", } configform(myform,tags) ?> +</DL> </form> <? end ?> diff --git a/shorewall-model.lua b/shorewall-model.lua index c572cc9..cecf0a1 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -50,6 +50,15 @@ end function getconfig() local config = {} + + config.interfaces_list = cfe({ + name = "interfaces_list", + label="List of interfaces", + type="select", + option={"BRN", "DMZ", "REZ", } + }) + config.interfaces_list.size=#config.interfaces_list.option + 1 + config.zones_list = cfe({ name = "zones_list", label="List of zones", @@ -291,92 +300,3 @@ end - - ---[===[ - --- shorewall model methods -module (..., package.seeall) -require("format") -require("fs") -require("daemoncontrol") - -local baseurl = "/etc/shorewall/" - --- ################################################################################ --- PUBLIC FUNCTIONS - -function startstop_service ( self, state ) - return daemoncontrol.daemoncontrol("shorewall", state) -end - - -function getstatus () - local f,error = io.popen("/sbin/shorewall status") - local fake = f:read("*l") - local fake = f:read("*l") - local programstatus = f:read("*l") or "" - local programstate = f:read("*l") or "" - f:close() - local f,error = io.popen("/sbin/shorewall version") - local programversion = "shorewall-" .. f:read("*l") - f:close() - return {version=programversion,status=programstatus,state=programstate} -end - -function get_filelist () - local filepath = baseurl - local listed_files = {} - local k,v - for name in posix.files(filepath) do - if not string.match(name, "^%.") and not string.match(name, "^Makefile") then - local filedetails = fs.stat(filepath .. name) - table.insert ( listed_files , {name=name, path=filepath .. name, filedetails=filedetails} ) - end - end - table.sort(listed_files, function (a,b) return (a.name < b.name) end ) - return listed_files -end - -function get_filedetails (self, name) - local name = basename(name) - local path = baseurl .. basename(name) - local file_content = nil - local available_files = get_filelist() - for k,v in pairs(available_files) do - if ( available_files[k].name == name ) then - file_content = cfe{name=name, content=fs.read_file(path), details=fs.stat(path)} - end - end - return file_content -end - -function get_logfile () - local me = {} - local cmdtxt = "cat /var/log/messages | grep Shorewall" - local cmd, error = io.popen(cmdtxt ,r) - local cmdoutput = cmd:read("*a") - cmd:close() - me.value = cmdoutput - me.cmd = cmdtxt - return me -end - -function update_filecontent (self, name, modifications) - path = baseurl .. basename(name) - name=basename(name) - local available_files = get_filelist() - for k,v in pairs(available_files) do - if ( available_files[k].name == name ) then - local file = io.open( path, "w+" ) - local file_result,err = file:write(format.dostounix(modifications)) - file:close() - if (err ~= nil) then - local filedetails = fs.stat(path) - file_content = {name=name, value=file_result, filedetails=filedetails, err=err} - end - end - end - return name, file_content -end ---]===] |