diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-15 16:03:10 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-15 16:03:10 +0000 |
commit | 4bac51eb98c5b5c184b697dcb5af63ec8b999db2 (patch) | |
tree | d3828f733330c0b4a5fa6fe7dcfaf2010de0db40 /snort-controller.lua | |
parent | 9c3419edaf3086aa1828be9fc2998e8cf090dd8b (diff) | |
download | acf-snort-4bac51eb98c5b5c184b697dcb5af63ec8b999db2.tar.bz2 acf-snort-4bac51eb98c5b5c184b697dcb5af63ec8b999db2.tar.xz |
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
Diffstat (limited to 'snort-controller.lua')
-rw-r--r-- | snort-controller.lua | 35 |
1 files changed, 19 insertions, 16 deletions
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 |