diff options
-rw-r--r-- | shorewall-config-html.lsp | 153 | ||||
-rw-r--r-- | shorewall-controller.lua | 4 | ||||
-rw-r--r-- | shorewall-model.lua | 15 |
3 files changed, 149 insertions, 23 deletions
diff --git a/shorewall-config-html.lsp b/shorewall-config-html.lsp index 80e0e9f..41ca945 100644 --- a/shorewall-config-html.lsp +++ b/shorewall-config-html.lsp @@ -1,5 +1,29 @@ <? local form = ... require("viewfunctions") +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(form)) +io.write("</span>") +--]] + +local descr = { + ['interfaces'] = { + ['labels'] = { "ZONE", "INTERFACES", "BROADCAST", "OPTIONS" }, + ['width'] = { "100", "100", "100", "*" } + }, + ['zones'] = { + ['labels'] = { "ZONE", "INTERFACES", "BROADCAST", "OPTIONS" }, + ['width'] = { "100", "100", "100", "*" } + }, + ['policy'] = { + ['labels'] = { "SOURCE", "DEST", "POLICY", "LOG LEVEL", "LIMIT:BURST" }, + ['width'] = { "100", "100", "100", "100" } + }, + ['rules'] = { + ['labels'] = { "ACTION", "SOURCE", "DEST", "PROTO", "DEST<BR>PORT", "SOURCE<BR>PORT(S)", "ORIGINAL<BR>DEST", "RATE<BR>LIMIT", "USER/<BR>GROUP", "MARK", }, + ['width'] = { "100", "70", "70", "70", "100", } + }, + } ?> <H1>SYSTEM INFO</H1> @@ -24,44 +48,147 @@ displayinfo(myform,tags) </DL> <H3>Interfaces</H3> +<? local myform = "interfaces" ?> <DL> -<? -local tags = { "interfaces", "interfaces_cmd", } -displayinfo(myform,tags) +<TABLE> +<TR> + <TD style="padding:0px;margin:0px;" class="header" WIDTH="17"><IMG SRC='/static/tango/16x16/actions/go-down.png' width='16' height='16' alt></TD> +<? for i=1,#descr[myform]['labels'] do ?> + <TD style="padding-right:10px;text-align:left;" class="header" WIDTH="<? io.write(descr[myform]['width'][i] or "*") ?>"><? io.write(descr[myform]['labels'][i] or "") ?></TD> +<? end ?> + <TD class="header" WIDTH="60"><IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"></TD> +</TR> + +<? +for i=1, #form.config[myform]['option'] do ?> -</DL> +<TR> + <TD><IMG SRC='/static/tango/16x16/actions/go-<? if i == #form.config[myform]['option'] then io.write("bottom") else io.write("down") end ?>.png' width='16' height='16' alt></TD> + <? for ii=1,#descr[myform]['labels'] do ?> + <TD style="padding-right:10px;text-align:left;border-bottom:1px solid #ccc"><? io.write(form.config[myform]['option'][i][ii] or "") ?></TD> + <? end ?> + <TD style="padding-right:0px;text-align:left;border-bottom:1px solid #ccc"> +<IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"> +<IMG SRC='/static/tango/16x16/actions/list-remove.png' width='16' height='16' title="Remove this record"> +<IMG SRC='/static/tango/16x16/actions/document-properties.png' width='16' height='16' title="Edit this record"> +</TD> + </TR> +<? +end +?> +</TABLE> +</DL> <H3>Defince zones</H3> +<? local myform = "zones" ?> <DL> -<? -local tags = { "zones", "zones_cmd", } -displayinfo(myform,tags) +<TABLE> +<TR> + <TD style="padding:0px;margin:0px;" class="header" WIDTH="17"><IMG SRC='/static/tango/16x16/actions/go-down.png' width='16' height='16' alt></TD> +<? for i=1,#descr[myform]['labels'] do ?> + <TD style="padding-right:10px;text-align:left;" class="header" WIDTH="<? io.write(descr[myform]['width'][i] or "*") ?>"><? io.write(descr[myform]['labels'][i] or "") ?></TD> +<? end ?> + <TD class="header" WIDTH="60"><IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"></TD> +</TR> + +<? +for i=1, #form.config[myform]['option'] do +?> + +<TR> + <TD><IMG SRC='/static/tango/16x16/actions/go-<? if i == #form.config[myform]['option'] then io.write("bottom") else io.write("down") end ?>.png' width='16' height='16' alt></TD> + <? for ii=1,#descr[myform]['labels'] do ?> + <TD style="padding-right:10px;text-align:left;border-bottom:1px solid #ccc"><? io.write(form.config[myform]['option'][i][ii] or "") ?></TD> + <? end ?> + <TD style="padding-right:0px;text-align:left;border-bottom:1px solid #ccc"> +<IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"> +<IMG SRC='/static/tango/16x16/actions/list-remove.png' width='16' height='16' title="Remove this record"> +<IMG SRC='/static/tango/16x16/actions/document-properties.png' width='16' height='16' title="Edit this record"> +</TD> + </TR> +<? +end ?> +</TABLE> </DL> <h3>Default policy</h3> +<? local myform = "policy" ?> <DL> -<? -local tags = { "policy", "policy_cmd",} -displayinfo(myform,tags) +<TABLE> +<TR> + <TD style="padding:0px;margin:0px;" class="header" WIDTH="17"><IMG SRC='/static/tango/16x16/actions/go-down.png' width='16' height='16' alt></TD> +<? for i=1,#descr[myform]['labels'] do ?> + <TD style="padding-right:10px;text-align:left;" class="header" WIDTH="<? io.write(descr[myform]['width'][i] or "*") ?>"><? io.write(descr[myform]['labels'][i] or "") ?></TD> +<? end ?> + <TD class="header" WIDTH="60"><IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"></TD> +</TR> + +<? +for i=1, #form.config[myform]['option'] do ?> + +<TR> + <TD><IMG SRC='/static/tango/16x16/actions/go-<? if i == #form.config[myform]['option'] then io.write("bottom") else io.write("down") end ?>.png' width='16' height='16' alt></TD> + <? for ii=1,#descr[myform]['labels'] do ?> + <TD style="padding-right:10px;text-align:left;border-bottom:1px solid #ccc"><? io.write(form.config[myform]['option'][i][ii] or "") ?></TD> + <? end ?> + <TD style="padding-right:0px;text-align:left;border-bottom:1px solid #ccc"> +<IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"> +<IMG SRC='/static/tango/16x16/actions/list-remove.png' width='16' height='16' title="Remove this record"> +<IMG SRC='/static/tango/16x16/actions/document-properties.png' width='16' height='16' title="Edit this record"> +</TD> + </TR> +<? +end +?> +</TABLE> </DL> <h3>Rules</h3> +<? local myform = "rules" +local val = {1,2,3,4,5,6,7,8,10,} +?> <DL> -<? -local tags = { "rules", "rules_cmd",} -displayinfo(myform,tags) +<TABLE> +<TR> + <TD style="padding:0px;margin:0px;" class="header" WIDTH="17"><IMG SRC='/static/tango/16x16/actions/go-down.png' width='16' height='16' alt></TD> +<? for k,i in pairs(val) do ?> + <TD style="padding-right:10px;text-align:left;" class="header" WIDTH="<? io.write(descr[myform]['width'][i] or "*") ?>"><? io.write(descr[myform]['labels'][i] or "") ?></TD> +<? end ?> + <TD class="header" WIDTH="60"><IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"></TD> +</TR> + +<? +for i=1, #form.config[myform]['option'] do ?> + +<TR> + <TD><IMG SRC='/static/tango/16x16/actions/go-<? if i == #form.config[myform]['option'] then io.write("bottom") else io.write("down") end ?>.png' width='16' height='16' alt></TD> + <? for ii,vv in pairs(val) do ?> + <TD style="padding-right:10px;text-align:left;border-bottom:1px solid #ccc"><? io.write(form.config[myform]['option'][i][ii] or "") ?></TD> + <? end ?> + <TD style="padding-right:0px;text-align:left;border-bottom:1px solid #ccc"> +<IMG SRC='/static/tango/16x16/actions/list-add.png' width='16' height='16' title="Add item below this record"> +<IMG SRC='/static/tango/16x16/actions/list-remove.png' width='16' height='16' title="Remove this record"> +<IMG SRC='/static/tango/16x16/actions/document-properties.png' width='16' height='16' title="Edit this record"> +</TD> + </TR> +<? +end +?> +</TABLE> </DL> + </form> <form name="cmd" action="<?= form.option.link ?>/<?= form.option.action ?>" method="POST"> <H1>MANAGEMENT</H1> <dl> <? +local myform = form.config local tags = { "check_cmd",} displayinfo(myform,tags) ?> diff --git a/shorewall-controller.lua b/shorewall-controller.lua index 4b0eba0..def860e 100644 --- a/shorewall-controller.lua +++ b/shorewall-controller.lua @@ -524,10 +524,6 @@ function config(self) local status=self.model.getstatus() -- Add a [New] record to the options - table.insert(config.interfaces.option, newrecordtxt) - table.insert(config.zones.option, newrecordtxt) - table.insert(config.policy.option, newrecordtxt) - table.insert(config.rules.option, newrecordtxt) table.insert(config.params.option, newrecordtxt) -- Add button diff --git a/shorewall-model.lua b/shorewall-model.lua index 023ceed..92c4640 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -49,7 +49,11 @@ local function read_config(file) local output = {} for k,v in pairs(filecontent) do if not string.find ( v, "^[;#].*" ) and not (string.find (v, "^%s*$")) then - table.insert(output, v) + local details = {} + for v in string.gmatch(v, "%S+") do + table.insert(details, v) + end + table.insert(output, details) end end return output @@ -213,8 +217,11 @@ function getconfig() name = "params", label="List of parameters", type="select", - option=read_config("params"), + option={}, }) + for k,v in pairs(read_config("params")) do + table.insert(config.params.option, v[1]) + end config.params.size=#config.params.option + 1 config.interfaces = cfe({ @@ -223,7 +230,6 @@ function getconfig() type="select", option=read_config("interfaces"), }) - config.interfaces.size=#config.interfaces.option + 1 config.zones = cfe({ name = "zones", @@ -231,7 +237,6 @@ function getconfig() type="select", option=read_config("zones"), }) - config.zones.size=#config.zones.option + 1 config.policy = cfe({ name = "policy", @@ -239,7 +244,6 @@ function getconfig() type="select", option=read_config("policy"), }) - config.policy.size=#config.policy.option + 1 config.rules = cfe({ name = "rules", @@ -247,7 +251,6 @@ function getconfig() type="select", option=read_config("rules"), }) - config.rules.size=#config.rules.option + 1 return config |