diff options
-rw-r--r-- | Makefile | 45 | ||||
-rw-r--r-- | config.mk | 10 | ||||
-rw-r--r-- | squid-basic-html.lsp | 40 | ||||
-rw-r--r-- | squid-controller.lua | 53 | ||||
-rw-r--r-- | squid-model.lua | 40 | ||||
-rw-r--r-- | squid.menu | 10 |
6 files changed, 198 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2e7c405 --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +APP_NAME=squid +PACKAGE=acf-$(APP_NAME) +VERSION=1.0_alpha1 + +APP_DIST=squid-controller.lua \ + squid-basic-html.lsp \ + squid-model.lua \ + squid.menu + +EXTRA_DIST=README Makefile config.mk + +DISTFILES=$(APP_DIST) $(EXTRA_DIST) + +TAR=tar + +P=$(PACKAGE)-$(VERSION) +tarball=$(P).tar.bz2 +install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME) + +all: +clean: + rm -rf $(tarball) $(P) + +dist: $(tarball) + +install: + mkdir -p "$(install_dir)" + cp -a $(APP_DIST) "$(install_dir)" + +$(tarball): $(DISTFILES) + rm -rf $(P) + mkdir -p $(P) + cp $(DISTFILES) $(P) + $(TAR) -jcf $@ $(P) + rm -rf $(P) + +# target that creates a tar package, unpacks is and install from package +dist-install: $(tarball) + $(TAR) -jxf $(tarball) + $(MAKE) -C $(P) install DESTDIR=$(DESTDIR) + rm -rf $(P) + +include config.mk + +.PHONY: all clean dist install dist-install diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..45f4d21 --- /dev/null +++ b/config.mk @@ -0,0 +1,10 @@ +prefix=/usr +datadir=${prefix}/share +sysconfdir=${prefix}/etc +localstatedir=${prefix}/var +acfdir=${datadir}/acf +wwwdir=${acfdir}/www +cgibindir=${acfdir}/cgi-bin +appdir=${acfdir}/app +acflibdir=${acfdir}/lib +sessionsdir=${localstatedir}/lib/acf/sessions diff --git a/squid-basic-html.lsp b/squid-basic-html.lsp new file mode 100644 index 0000000..941dfba --- /dev/null +++ b/squid-basic-html.lsp @@ -0,0 +1,40 @@ +<? + local form = ... + local data = form.option + local service = form.service + + local srv1fill = "" + local srv2fill = "disabled" + if service.status == "running" then + srv1fill = "disabled" + srv2fill = "" + end + +?> +<h1>Web Proxy</h1> +Squid is a web proxy server. It makes web requests in behalf of the client, and +inspecting the returned and optionally caches that content so that the next time +a client request is made, the content can be served from local disk. This can make +web surfing faster. Squid can also forward its requests on to a content filter, +such as DansGuardian.<br><br> +This page determines the general operational settings for squid.<br> + +<h2>Status</h2> +<form action="" method="POST"> +<table><tr> +<td>squid is: <b><? io.write( service.status ) ?> </b> </td> +<td><input type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td> +<td><input type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td> +<td><input type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td> +</tr></table> + +<pre style="color: #ff2020;"><? io.write( service.message ) ?></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> +until you restart the service.<br> + +<h2>Configuration</h2> + + +</form> diff --git a/squid-controller.lua b/squid-controller.lua new file mode 100644 index 0000000..46da101 --- /dev/null +++ b/squid-controller.lua @@ -0,0 +1,53 @@ +-- the squid controller + +module (..., package.seeall) + +-- Cause an http redirect to our "read" action +-- We use the self.conf table because it already has prefix,controller,etc +-- The redir code is defined in the application error handler (acf-controller) +local list_redir = function (self) + self.conf.action = "home" + self.conf.type = "redir" + error (self.conf) +end + +local pvt = {} +mvc= {} +mvc.on_load = function( self, parent ) + -- If they try to run a bogus action, send them to read + if ( rawget(self.worker, self.conf.action) == nil ) then + list_redir(self) + end + pvt.parent_on_exec = parent.worker.mvc.post_exec +end + +mvc.pre_exec = function( self ) + -- pvt.parent_on_exec () +end + +mvc.post_exec = function( self ) + return pvt.parent_on_exec() +end + +basic = 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="" } + if self.clientdata.srvcmd then + local srvcmd = self.clientdata.srvcmd + if srvcmd == "start" or srvcmd == "stop" or srvcmd == "restart" then + service.message = self.model.service_control( srvcmd ) + end + end + + service.status = self.model.get_status() + + return ( cfe ({ option = option, service = service }) ) +end + diff --git a/squid-model.lua b/squid-model.lua new file mode 100644 index 0000000..c61a4e7 --- /dev/null +++ b/squid-model.lua @@ -0,0 +1,40 @@ +-- acf model for squid +-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2 +module (..., package.seeall) + +get_status = function() + + local retval = "stopped" + + local ptr = io.popen( "/bin/pidof squid" ) + local pid = ptr:read( "*a" ) + ptr:close() + if pid ~= nil then + if #pid > 1 then + retval = "running" + end + end + + return retval +end + +service_control = function( control ) + + local retval = "" + + local ptr = io.popen( "/etc/init.d/squid " .. control, "r" ) + if ptr ~= nil then + local retmsg = ptr:read( "*a" ) + ptr:close() + if retmsg ~= nil then + retval = retmsg + else + retval = "service_control(): Failed to read output from initscript!\n" + end + else + retval = "service_control(): Failed to start/stop/restart service!\n" + end + + return retval +end + diff --git a/squid.menu b/squid.menu new file mode 100644 index 0000000..7b69021 --- /dev/null +++ b/squid.menu @@ -0,0 +1,10 @@ +# Prefix and controller are already known at this point +# Cat Group Tab Action +Web_Proxy 1_Basic_Config Basic basic +Web_Proxy 2_Advanced_Config Advanced advanced +Web_Proxy 3_Digest_Authentication Digest digest +Web_Proxy 4_NTLM_Authentication NTLM ntlm +Web_Proxy 5_Harddisk_Support HDisk hdisk +Web_Proxy 6_Special_Access SAccess saccess +Web_Proxy 7_Content_Filter CFilter cfilter +Web_Proxy 8_Advanced_Content_Filter AdvCFilter advcfilter |