From 4bac51eb98c5b5c184b697dcb5af63ec8b999db2 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Tue, 15 Jan 2008 16:03:10 +0000 Subject: Cleaned up code and used lib's instead. Added functionallity to change the config-file. git-svn-id: svn://svn.alpinelinux.org/acf/snort/trunk@579 ab2d0c66-481e-0410-8bed-d214d4d58bed --- snort-controller.lua | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'snort-controller.lua') diff --git a/snort-controller.lua b/snort-controller.lua index 199ac4e..19d55ea 100644 --- a/snort-controller.lua +++ b/snort-controller.lua @@ -16,18 +16,11 @@ mvc.on_load = function(self, parent) end end --- Public methods - -status = function (self) +function status(self) local srvcmdresult = nil local srvcmd = self.clientdata.srvcmd if (srvcmd ~= nil) then - srvcmdresult = self.model:service_control(srvcmd) - if (srvcmd == "stop") or (srvcmd == "restart") then - posix.sleep(3) -- Wait for the process to start|stop - else - posix.sleep(1) -- Wait for the process to start|stop - end + srvcmdresult = self.model:startstop_service(srvcmd) end local alerts,alertresult = self.model:read_alert() return ({status = self.model:getstatus(), @@ -37,13 +30,23 @@ status = function (self) url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) end ---[[ -function config(self) - return { status = self.model.getstatus() } -end ---]] - function expert(self) - return { file = self.model:get_filedetails(), status = self.model.getstatus(),} + local modifications = self.clientdata.modifications or "" + local cmd = self.clientdata.cmd + local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller + + if ( modifications ~= "") then + modifications = self.model:update_filecontent(modifications) + end + + if ( cmd ~= nil ) then + startstop = self.model:startstop_service( cmd ) + end + + return ( {startstop = startstop, + status = self.model:getstatus(), + file = self.model:get_filedetails(), + modifications = modifications, + url = url, } ) end -- cgit v1.2.3