From a3965b138f8c37b32cc28889250d55e20124983f Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 15 May 2008 15:12:42 +0000 Subject: Saving work for today. Applying the component functionallity to acf-shorewall. Cleaning up and rebuilding the view-files. git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@1121 ab2d0c66-481e-0410-8bed-d214d4d58bed --- shorewall-check-html.lsp | 20 ++++----- shorewall-config-html.lsp | 85 +++++++++++++++++++----------------- shorewall-controller.lua | 99 +++++++++++++----------------------------- shorewall-edit-html.lsp | 13 ++---- shorewall-expert-html.lsp | 24 ++++------ shorewall-logfile-html.lsp | 15 ++----- shorewall-model.lua | 60 ++++++++++++++----------- shorewall-startstop-html.lsp | 26 +++++++++++ shorewall-status-html.lsp | 18 +++----- shorewall-statusbasic-html.lsp | 17 ++++++++ shorewall.menu | 2 +- shorewall.roles | 4 +- 12 files changed, 184 insertions(+), 199 deletions(-) create mode 100644 shorewall-startstop-html.lsp create mode 100644 shorewall-statusbasic-html.lsp diff --git a/shorewall-check-html.lsp b/shorewall-check-html.lsp index 7cfe4bf..f970a97 100644 --- a/shorewall-check-html.lsp +++ b/shorewall-check-html.lsp @@ -1,7 +1,5 @@ - -DEBUGGING

DEBUG INFO: CFE

") io.write(html.cfe_unpack(view)) @@ -9,14 +7,9 @@ io.write("
") --]] ?> -

SYSTEM INFO

-
- -
+

CONFIGURATION

@@ -38,3 +31,8 @@ if (myform) then end ?> + + + diff --git a/shorewall-config-html.lsp b/shorewall-config-html.lsp index 41ca945..c644fec 100644 --- a/shorewall-config-html.lsp +++ b/shorewall-config-html.lsp @@ -1,4 +1,4 @@ -DEBUGGING

DEBUG INFO: CFE

") @@ -23,36 +23,26 @@ local descr = { ['labels'] = { "ACTION", "SOURCE", "DEST", "PROTO", "DEST
PORT", "SOURCE
PORT(S)", "ORIGINAL
DEST", "RATE
LIMIT", "USER/
GROUP", "MARK", }, ['width'] = { "100", "70", "70", "70", "100", } }, + ['masq'] = { + ['labels'] = { "INTERFACE", "SOURCE", "ADDRESS", "PROTO", "PORT(S)", "IPSEC", "MARK" }, + ['width'] = { "100", "70", "70", "70", "100", } + }, } ?> -

SYSTEM INFO

-
- -
+ -
-

CONFIGURATION

-

Advanced configuration

-

Parameters

-
- -
+

GUIDED CONFIGURATION

-

Interfaces

- + +

Defince zones

+
- @@ -64,7 +54,6 @@ for i=1, #form.config[myform]['option'] do ?> - @@ -80,12 +69,11 @@ end
">
.png' width='16' height='16' alt>
-

Defince zones

- +

Interfaces

+
- @@ -97,7 +85,6 @@ for i=1, #form.config[myform]['option'] do ?> - @@ -113,12 +100,12 @@ end
">
.png' width='16' height='16' alt>
+

Default policy

- @@ -130,7 +117,6 @@ for i=1, #form.config[myform]['option'] do ?> - @@ -153,7 +139,6 @@ local val = {1,2,3,4,5,6,7,8,10,}
">
.png' width='16' height='16' alt>
- @@ -165,7 +150,6 @@ for i=1, #form.config[myform]['option'] do ?> - @@ -181,16 +165,35 @@ end
">
.png' width='16' height='16' alt>
+

Masq

+ +
+ + + + + + + - + - -

MANAGEMENT

-
- + +
+ + + + - - +
">
+ + + +
+
+ + diff --git a/shorewall-controller.lua b/shorewall-controller.lua index bfa680b..967c4d6 100644 --- a/shorewall-controller.lua +++ b/shorewall-controller.lua @@ -9,35 +9,6 @@ local newrecordtxt = "[New]" -- ################################################################################ -- LOCAL FUNCTIONS -local function displaycmdmanagement(pidofstatus) - -- Add a management buttons - local management = {} ---[[ - management.start = cfe({ name="cmdmanagement", - label="Program control-panel", - value="Start", - type="submit", - }) - management.stop = cfe({ name="cmdmanagement", - label="Program control-panel", - value="Stop", - type="submit", - }) ---]] - management.restart = cfe({ name="cmdmanagement", - label="Program control-panel", - value="Restart", - type="submit", - }) - -- next CFE can be used to present the result of the previous action - management.actionresult = cfe({ name="actionresult", - label="Previous action result", - }) - - return management -end - - local function displaycmdsave(self) -- Add a cmd button to the view local cmdsave = cfe({ name="cmdsave", @@ -475,7 +446,14 @@ function editrecords(self,types,record,errormessage) end function status(self) - return { status=self.model.getstatus() } + return { status=self.model.getstatusdetails() } +end +function statusbasic(self) + return { + status=self.model.getstatus(), + version=self.model.getversion(), + autostart=self.model.getautostart(), + } end function config(self) @@ -521,7 +499,6 @@ function config(self) end local config=self.model:getconfig() - local status=self.model.getstatus() -- Add a [New] record to the options table.insert(config.params.option, newrecordtxt) @@ -635,7 +612,6 @@ function config(self) end return { - status=status, config=config, option={ script=self.conf.script, prefix=self.conf.prefix, @@ -649,41 +625,16 @@ function config(self) end function check(self) - -- Start/Stop/Restart process - local cmdmanagement, actionresult - if ( self.clientdata.cmdmanagement) then - cmdmanagement = cfe({ - name="cmdmanagement", - label="Previous action result", - action=cfe({ - name="cmdmanagement", - value=string.lower(self.clientdata.cmdmanagement), -- This row contains start/stop/restart (one of these commands) - }), - }) - actionresult, cmdmanagement = self.model:startstop_service( cmdmanagement.action ) - end - local status = self.model.getstatus() local config = self.model:configcheck() - -- Management buttons (Hide/show buttons - local pidofstatus - if (string.lower(status.status.value) == "enabled" ) then pidofstatus = true end - management = displaycmdmanagement(pidofstatus) - if (actionresult) then - management.actionresult.descr=cmdmanagement.descr - management.actionresult.errtxt=cmdmanagement.errtxt - end - return { option={ script=self.conf.script, prefix=self.conf.prefix, controller = self.conf.controller, action = "expert", link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, - management = management, config = config, - status = status, startstop = startstop, debugclientdata = self.clientdata, } @@ -692,7 +643,6 @@ end function logfile(self) - local status = self.model.getstatus() local config = self.model:getlogfile() return { @@ -702,7 +652,6 @@ function logfile(self) action = "expert", link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, config = config, - status = status, startstop = startstop, debugclientdata = self.clientdata, } @@ -710,34 +659,28 @@ function logfile(self) end function expert(self) - - local status = self.model.getstatus() - local config = self.model:getfilelist() - return { option={ script=self.conf.script, prefix=self.conf.prefix, controller = self.conf.controller, action = "expert", link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, - config = config, - status = status, + config = self.model:getfilelist(), startstop = startstop, debugclientdata = self.clientdata, } - end function edit(self) -- Save changes + local cmdsaveresult, cmdsaveerror if ( self.clientdata.cmdsave) then local filetochange = cfe ({ name=self.clientdata.filename, value=self.clientdata.filecontent, }) - modifications = self.model:updatefilecontent(filetochange) + cmdsaveresult, cmdsaveerror = self.model:updatefilecontent(filetochange) self.clientdata.name = self.clientdata.filename end - local status = self.model.getstatus() local config = self.model:getfiledetails(cfe({ name="editfile", value=self.clientdata.name, @@ -745,8 +688,9 @@ function edit(self) -- Display save button config.cmdsave = displaycmdsave() - if (self.clientdata.cmdsave) then + if (cmdsaveresult) then config.cmdsave.descr="* Changes has been saved!" + redirect(self,"expert") end return { @@ -757,11 +701,26 @@ function edit(self) link = self.conf.script .. self.conf.prefix .. self.conf.controller, }, modifications = modifications, config = config, - status = status, startstop = startstop, debugclientdata = self.clientdata, } end +function startstop(self) + local result + if self.clientdata.action then + result = self.model:startstop_service(self.clientdata.action) + self.sessiondata.syslogstartstopresult = result + self.redirect_to_referrer(self) + end + + local status = self.model.getstatus() + if self.sessiondata.syslogstartstopresult then + result = self.sessiondata.syslogstartstopresult + self.sessiondata.syslogstartstopresult = nil + end + + return cfe({ type="group", value={status=status, result=result} }) +end diff --git a/shorewall-edit-html.lsp b/shorewall-edit-html.lsp index 6fde10f..e6231b0 100644 --- a/shorewall-edit-html.lsp +++ b/shorewall-edit-html.lsp @@ -1,15 +1,10 @@ - -

SYSTEM INFO

-
- -
+

CONFIGURATION

diff --git a/shorewall-expert-html.lsp b/shorewall-expert-html.lsp index 522e110..1eff27b 100644 --- a/shorewall-expert-html.lsp +++ b/shorewall-expert-html.lsp @@ -1,4 +1,4 @@ - ") --]] ?> -

SYSTEM INFO

-
- -
- -

CONFIGURATION

+ -

Expert config

-

List of configfiles

+

EXPERT CONFIGURATION

@@ -35,9 +27,9 @@ displayinfo(myform,tags,"viewonly") - - - + + + diff --git a/shorewall-logfile-html.lsp b/shorewall-logfile-html.lsp index 38b41d8..4f35c40 100644 --- a/shorewall-logfile-html.lsp +++ b/shorewall-logfile-html.lsp @@ -1,7 +1,5 @@ - -DEBUGGING

DEBUG INFO: CFE

") io.write(html.cfe_unpack(view)) @@ -9,14 +7,9 @@ io.write("
") --]] ?> -

SYSTEM INFO

-
- -
+

LOGIFLES

DETAILS

diff --git a/shorewall-model.lua b/shorewall-model.lua index 92c4640..a8627c7 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -199,15 +199,9 @@ function modify_config(self, addremove, file, value, orgvalue ) return addremove_config(addremove, file, value, orgvalue ) end --- action should be a CFE function startstop_service ( self, action ) - local cmd = action.value - local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, cmd) - action.descr=cmdmessage - action.errtxt=cmderror - -- Reporting back (true|false, the original acition) - return cmdresult,action - + local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, action) + return cfe({ type="boolean", value=cmdresult, descr=cmdmessage, errtxt=cmderror, label=action.." result" }) end function getconfig() @@ -252,41 +246,55 @@ function getconfig() option=read_config("rules"), }) + config.masq = cfe({ + name = "masq", + label="List of rules", + type="select", + option=read_config("masq"), + }) + return config end -function getstatus() - local status = {} - +function getversion() local value, errtxt = processinfo.package_version(packagename) - status.version = cfe({ name = "version", + local version = cfe({ name = "version", label="Program version", value=value, errtxt=errtxt, }) + return version +end +function getautostart() + local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname) + local autostart = cfe({ name="autostart", + label="Autostart sequence", + value=autostart_sequense, + errtxt=autostart_errtxt, + }) + return autostart +end +function getstatus() local programversion,programstatus,programstate = getdetails() - status.status = cfe({ name="status", + local status = cfe({ name="status", label="Program status", value=programstatus, }) - - status.state = cfe({ name="state", + return status +end +function getstatusdetails() + local details = {} + local programversion,programstatus,programstate = getdetails() + details.state = cfe({ name="state", label="Program reports", value=programstate, }) - - local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname) - status.autostart = cfe({ name="autostart", - label="Autostart sequence", - value=autostart_sequense, - errtxt=autostart_errtxt, - }) - - return status + return details end + function configcheck () local check = {} local f,err = io.popen("/bin/echo -n '>> Check starts at: ';/bin/date; /bin/echo; /etc/init.d/shorewall check; /bin/echo; /bin/echo -n '>> Check stops at: '; /bin/date;") @@ -400,11 +408,11 @@ function updatefilecontent (self, filetochange) end if not (path) then filetochange.errtxt = "Invalid path!" - return filetochange + return false, filetochange end local file_result,err = fs.write_file(path, format.dostounix(filetochange.value)) - return file_result, err + return true end diff --git a/shorewall-startstop-html.lsp b/shorewall-startstop-html.lsp new file mode 100644 index 0000000..3f6492a --- /dev/null +++ b/shorewall-startstop-html.lsp @@ -0,0 +1,26 @@ + + + +

MANAGEMENT

+
+
+
Program control-panel
+
+> +> +> +
+
+ + +
Previous action result
+
+ +

") ?>

+ +

") ?>

+ +
+
diff --git a/shorewall-status-html.lsp b/shorewall-status-html.lsp index 9122797..d670e47 100644 --- a/shorewall-status-html.lsp +++ b/shorewall-status-html.lsp @@ -1,22 +1,17 @@ - -DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(viewlibrary)) +io.write("----------") io.write(html.cfe_unpack(form)) io.write("
") --]] ?> -

SYSTEM INFO

-
- -
+

PROGRAM SPECIFIC OPTIONS/INFORMATION

@@ -26,4 +21,3 @@ local tags = { "state", } displayinfo(myform,tags,"viewonly") ?>
- diff --git a/shorewall-statusbasic-html.lsp b/shorewall-statusbasic-html.lsp new file mode 100644 index 0000000..861d8a8 --- /dev/null +++ b/shorewall-statusbasic-html.lsp @@ -0,0 +1,17 @@ +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(form)) +io.write("
") +--]] +?> + +

SYSTEM INFO

+
+ +
diff --git a/shorewall.menu b/shorewall.menu index fac6de9..ddf5a28 100644 --- a/shorewall.menu +++ b/shorewall.menu @@ -2,6 +2,6 @@ Networking 40Firewall Status status Networking 40Firewall Config config Networking 40Firewall Expert expert -Networking 40Firewall Check check +Networking 40Firewall Check/Start/Stop/Restart check Networking 40Firewall Logfile logfile diff --git a/shorewall.roles b/shorewall.roles index db7e5fe..270dea4 100644 --- a/shorewall.roles +++ b/shorewall.roles @@ -1,2 +1,2 @@ -READ=shorewall:status,shorewall:logfile -UPDATE=shorewall:editrecords,shorewall:config,shorewall:check,shorewall:expert,shorewall:edit +READ=shorewall:status,shorewall:statusbasic,shorewall:logfile +UPDATE=shorewall:editrecords,shorewall:config,shorewall:check,shorewall:expert,shorewall:edit,shorewall:startstop -- cgit v1.2.3