From f9e85abf11c0dfc699e8634fbf4fd25f4be01ec0 Mon Sep 17 00:00:00 2001 From: Andreas Brodmann Date: Tue, 27 Nov 2007 16:23:30 +0000 Subject: daily update on the acf-squid module (separated dansguardian config from squid config) git-svn-id: svn://svn.alpinelinux.org/acf/squid/trunk@373 ab2d0c66-481e-0410-8bed-d214d4d58bed --- Makefile | 1 + dansguardian-controller.lua | 34 +++++++++++++++++++++++++++++++++- dansguardian-general-html.lsp | 2 +- dansguardian-model.lua | 39 ++++++++++++++++++++++++++++++++++++++- dansguardian.menu | 3 ++- 5 files changed, 75 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 00f67fd..3b77e0c 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ APP_DIST=squid-controller.lua \ dansguardian-controller.lua \ dansguardian-model.lua \ dansguardian-general-html.lsp \ + dansguardian-plain-html.lsp \ dansguardian.menu EXTRA_DIST=README Makefile config.mk diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua index e749965..db72884 100644 --- a/dansguardian-controller.lua +++ b/dansguardian-controller.lua @@ -43,7 +43,7 @@ general = function( self ) if self.clientdata.srvcmd then srvcmd = self.clientdata.srvcmd if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then - self.model.service_control( srvcmd ) + service.message = self.model.service_control( srvcmd ) end end @@ -66,3 +66,35 @@ general = function( self ) return ( cfe ({ option = option, service = service }) ) end +plain = function( self ) + + local option = { script = ENV["SCRIPT_NAME"], + prefix = self.conf.prefix, + controller = self.conf.controller, + action = self.conf.action, + extra = "" + } + + local service = { message="", status="", config="" } + + if self.clientdata.srvcmd then + srvcmd = self.clientdata.srvcmd + if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then + service.message = self.model.service_control( srvcmd ) + end + end + + if self.clientdata.cmd then + if self.clientdata.cmd == "save" then + local conf = self.clientdata + local config = conf.config + self.model.update_plain_config( config ) + end + end + + service.status = self.model.get_status() + service.config, service.cfgerr = self.model.get_plain_config() + + return ( cfe ({ option = option, service = service }) ) +end + diff --git a/dansguardian-general-html.lsp b/dansguardian-general-html.lsp index faddfdf..0e88e96 100644 --- a/dansguardian-general-html.lsp +++ b/dansguardian-general-html.lsp @@ -38,7 +38,6 @@ generally not necessary. DansGuardian must be used in combination with a

-

This process runs as a service. When you make and save changes, the configuration files for the service are changed. However, the changes will not be applied @@ -46,6 +45,7 @@ until you restart the service.


Configuration

+

Listener service

These parameters define the interface and port that Dansguardian uses to accept connections.

diff --git a/dansguardian-model.lua b/dansguardian-model.lua index f313eec..5289ee3 100644 --- a/dansguardian-model.lua +++ b/dansguardian-model.lua @@ -74,12 +74,32 @@ get_general_config = function() end fptr:close() else - error = "Failed to open /etc/dansguardian/dansguardian.conf file!" + error = "Failed to open " .. dansguardiancfg .. " file!" end return retval, error end +get_plain_config = function() + + local retval = "" + local error = "" + + local fptr = io.open( dansguardiancfg, "r" ) + if fptr ~= nil then + retval = fptr:read( "*a" ) + fptr:close() + if retval == nil then + retval = "" + error = "Failed to read " .. dansguardiancfg .. " file!" + end + else + error = "Failed to open " .. dansguardiancfg .. " file!" + end + + return retval, error +end + update_general_config = function( config ) local retval = "" @@ -126,6 +146,23 @@ update_general_config = function( config ) return retval end +update_plain_config = function( config ) + + local retval = "" + local cfgptr = -1 + local error = "" + + cfgptr = io.open( dansguardiancfg, "wb+" ) + if cfgptr ~= nil then + cfgptr:write( config ) + cfgptr:close() + else + retval = "Failed to open " .. dansguardiancfg .. " file!" + end + + return retval +end + get_cfg_value = function( str ) local retval = "" diff --git a/dansguardian.menu b/dansguardian.menu index ec99d87..ea2dbad 100644 --- a/dansguardian.menu +++ b/dansguardian.menu @@ -1,4 +1,5 @@ # Prefix and controller are already known at this point # Cat Group Tab Action Web_Proxy Content_Filter - general -Web_Proxy Content_Filter_(Adv) advanced +Web_Proxy Content_Filter_(Plain) - plain +Web_Proxy Content_Filter_(Advanced) advanced -- cgit v1.2.3