summaryrefslogtreecommitdiffstats
path: root/snort-controller.lua
diff options
context:
space:
mode:
Diffstat (limited to 'snort-controller.lua')
-rw-r--r--snort-controller.lua35
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