diff options
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | dansguardian-controller.lua | 34 | ||||
| -rw-r--r-- | dansguardian-general-html.lsp | 2 | ||||
| -rw-r--r-- | dansguardian-model.lua | 39 | ||||
| -rw-r--r-- | dansguardian.menu | 3 | 
5 files changed, 75 insertions, 4 deletions
@@ -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  </form>  <pre style="color: #ff2020;"><? io.write( service.message ) ?></pre><br> -<pre style="color: #ff2020;"><? io.write( service.cfgerr ) ?></pre><br>  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 <i>applied</i>  @@ -46,6 +45,7 @@ until you restart the service.<br><br><br>  <form action="" method="POST">  <h1>Configuration</h1> +<pre style="color: #ff2020;"><? io.write( service.cfgerr ) ?></pre><br>  <h2>Listener service</h2>  These parameters define the interface and port that Dansguardian uses to accept connections.<br><br> 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  | 
