-- 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 get_adv_config = function() local retval = "" local ptr = io.open( "/etc/squid/squid.conf", "r" ) if ptr ~= nil then local retcfg = ptr:read( "*a" ) ptr:close() if retcfg == nil then retval = "\n\n Error: Failed to read /etc/squid/squid.conf!\n\n" else retval = retcfg end end return retval end update_adv_config = function( config ) local retval = "Successfully updated /etc/squid/squid.conf!" local ptr = io.open( "/etc/squid/squid.conf", "wb+" ) if ptr ~= nil then ptr:write( config ) ptr:close() else retval = "update_config(): Error, failed to open /etc/squid/squid.conf!\n" end return retval end get_basic_config = function() local config = { proxyip = { value="", type="text", label="Proxy IP" }, proxyport = { value="", type="text", label="Proxy Port" }, filterip = { value="", type="text", label="Filter IP" }, filterport = { value="", type="text", label="Filter Port" }, filterregex = { value="", type="text", label="FilterRegex" }, safeports = { value="", type="text", label="Safe_ports" }, sslports = { value="", type="text", label="SSL_ports" }, accesslog = { value="", type="select", label="Access Logs", option={ "yes", "no" } }, diskcache = { value="", type="select", label="Disk Cache Parameters", option={ "yes", "no" } }, authmethod = { value="", type="select", label="Authentication Method", option={ "digest", "ntlm", "none" } } } config.proxyip.value = "192.168.83.129" config.proxyport.value = 8080 config.accesslog.value = "yes" return config end