summaryrefslogtreecommitdiffstats
path: root/snort-controller.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-09-23 18:56:53 +0000
committerTed Trask <ttrask01@yahoo.com>2008-09-23 18:56:53 +0000
commit57145e7023e2c57c55f8ceb4673e139c891f61fd (patch)
tree2db1319d9d3149d0299c0288a67f212a41d70fdc /snort-controller.lua
parent6c25bf20b9039513aac252010ebeb99a84562d95 (diff)
downloadacf-snort-57145e7023e2c57c55f8ceb4673e139c891f61fd.tar.bz2
acf-snort-57145e7023e2c57c55f8ceb4673e139c891f61fd.tar.xz
Updated snort to use new libraries and lsp files.
git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@1484 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'snort-controller.lua')
-rw-r--r--snort-controller.lua110
1 files changed, 10 insertions, 100 deletions
diff --git a/snort-controller.lua b/snort-controller.lua
index 737f97c..513627a 100644
--- a/snort-controller.lua
+++ b/snort-controller.lua
@@ -1,119 +1,29 @@
module (..., package.seeall)
-- Load libraries
-require("posix")
+require("controllerfunctions")
-- ################################################################################
-- 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",
- })
-
- -- Disable management buttons based on if the process is running or not
- if (pidofstatus) then
- management.start.disabled = "yes"
- else
- management.stop.disabled = "yes"
- management.restart.disabled = "yes"
- end
-
- return management
-end
-
-- ################################################################################
-- PUBLIC FUNCTIONS
default_action = "status"
function status(self)
- local srvcmdresult = nil
- local srvcmd = self.clientdata.srvcmd
- local status = self.model:getstatus(self)
-
- local alerts,alertresult = self.model:read_alert()
- return ({
- status = status,
- alerts=alerts,
- alertresult=alertresult,
- url = self.conf.script .. self.conf.prefix .. self.conf.controller} )
+ return self.model.getstatus()
end
-function expert(self)
- local cmd = self.clientdata.cmd
- local url = self.conf.script .. self.conf.prefix .. self.conf.controller
-
- local modifications = self.clientdata.filecontent or ""
- if ( self.clientdata.cmdsave ) then
- modifications = self.model:update_filecontent(modifications)
- end
-
- -- 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(self)
- local file = self.model:get_filedetails()
-
- -- Add buttons
- file.cmdsave = cfe ({
- name="cmdsave",
- label="Apply settings",
- value="Apply",
- type="submit",
- })
- if (self.clientdata.cmdsave) then
- file.cmdsave.descr="* Changes has been saved!"
- end
+function details(self)
+ return self.model.read_alert()
+end
- -- 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
- if (status) and (status.version) and (#status.version.value == 0) then
- management.start.disabled = "yes"
- management.stop.disabled = "yes"
- management.restart.disabled = "yes"
- end
+function startstop(self)
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata)
+end
- return ( {
- management = management,
- status = status,
- file = file,
- modifications = modifications,
- url = url, } )
+function expert(self)
+ return controllerfunctions.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Configuration", "Configuration Set")
end