summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dansguardian-advanced-html.lsp6
-rw-r--r--dansguardian-category-html.lsp8
-rw-r--r--dansguardian-edit-html.lsp4
-rw-r--r--dansguardian-general-html.lsp20
-rw-r--r--dansguardian-plain-html.lsp8
-rw-r--r--squid-advanced-html.lsp8
-rw-r--r--squid-basic-html.lsp22
-rw-r--r--squid-model.lua131
8 files changed, 158 insertions, 49 deletions
diff --git a/dansguardian-advanced-html.lsp b/dansguardian-advanced-html.lsp
index 92c1d81..5fd54ee 100644
--- a/dansguardian-advanced-html.lsp
+++ b/dansguardian-advanced-html.lsp
@@ -31,9 +31,9 @@ generally not necessary. DansGuardian must be used in combination with a
<form action="" method="POST">
<table><tr>
<td>dansguardian 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>
+<td><input class="submit" type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td>
</tr></table>
</form>
diff --git a/dansguardian-category-html.lsp b/dansguardian-category-html.lsp
index 0a831d7..d9ddcac 100644
--- a/dansguardian-category-html.lsp
+++ b/dansguardian-category-html.lsp
@@ -31,9 +31,9 @@ generally not necessary. DansGuardian must be used in combination with a
<form action="" method="POST">
<table><tr>
<td>dansguardian 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>
+<td><input class="submit" type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td>
</tr></table>
</form>
@@ -54,7 +54,7 @@ until you restart the service.<br><br><br>
io.write( "<tr><td><input type=\"checkbox\" name=\"cats\" value=\"" .. v .. "\"> " .. v .. "</td></tr>\n" )
end
?>
-<tr><td><input type="submit" name="cmd" value="delete"></td></tr>
+<tr><td><input class="submit" type="submit" name="cmd" value="delete"></td></tr>
</table>
</form>
diff --git a/dansguardian-edit-html.lsp b/dansguardian-edit-html.lsp
index d74ea5d..96a9c28 100644
--- a/dansguardian-edit-html.lsp
+++ b/dansguardian-edit-html.lsp
@@ -27,8 +27,8 @@ These parameters define the interface and port that Dansguardian uses to accept
<table>
<tr><td><textarea name="config" style="width:600px"><? io.write( service.config ) ?></textarea></td></tr>
</table><br>
-<input type="hidden" name="name" value="<? io.write( service.name ) ?>">
+<input class="text" type="hidden" name="name" value="<? io.write( service.name ) ?>">
-<input type="submit" name="cmd" value="save" style="width:100px"><br>
+<input class="submit" type="submit" name="cmd" value="save" style="width:100px"><br>
</form>
diff --git a/dansguardian-general-html.lsp b/dansguardian-general-html.lsp
index 0e88e96..905c5d2 100644
--- a/dansguardian-general-html.lsp
+++ b/dansguardian-general-html.lsp
@@ -31,9 +31,9 @@ generally not necessary. DansGuardian must be used in combination with a
<form action="" method="POST">
<table><tr>
<td>dansguardian 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>
+<td><input class="submit" type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td>
</tr></table>
</form>
@@ -50,16 +50,16 @@ until you restart the service.<br><br><br>
These parameters define the interface and port that Dansguardian uses to accept connections.<br><br>
<table>
-<tr><td align="right"><b>filterip</b></td><td><input type="text" name="filterip" value="<? io.write( config.filterip.value ) ?>" style="width:100px"></td></tr>
-<tr><td align="right"><b>filterport</b></td><td><input type="text" name="filterport" value="<? io.write( config.filterport.value ) ?>" style="width:100px"></td></tr>
+<tr><td align="right"><b>filterip</b></td><td><input class="text" type="text" name="filterip" value="<? io.write( config.filterip.value ) ?>" style="width:100px"></td></tr>
+<tr><td align="right"><b>filterport</b></td><td><input class="text" type="text" name="filterport" value="<? io.write( config.filterport.value ) ?>" style="width:100px"></td></tr>
</table><br>
<h2>Proxy service</h2>
These parameters define the ip address and port that Dansguardian should forward requests on to.<br><br>
<table>
-<tr><td align="right"><b>proxyip</b></td><td><input type="text" name="proxyip" value="<? io.write( config.proxyip.value ) ?>" style="width:100px"></td></tr>
-<tr><td align="right"><b>proxyport</b></td><td><input type="text" name="proxyport" value="<? io.write( config.proxyport.value ) ?>" style="width:100px"></td></tr>
+<tr><td align="right"><b>proxyip</b></td><td><input class="text" type="text" name="proxyip" value="<? io.write( config.proxyip.value ) ?>" style="width:100px"></td></tr>
+<tr><td align="right"><b>proxyport</b></td><td><input class="text" type="text" name="proxyport" value="<? io.write( config.proxyport.value ) ?>" style="width:100px"></td></tr>
</table><br>
<h2>Filter Actions</h2>
@@ -68,10 +68,10 @@ determines that the content is inappropriate. The "naughtynesslimit" is more sen
The author recommends 50 for "young children", 100 for "older children" and 160 for "young adults".<br><br>
<table>
-<tr><td align="right"><b>accessdeniedaddress</b></td><td><input type="text" name="accessdeniedaddress" value="<? io.write( config.accessdeniedaddress.value ) ?>" style="width:250px"></td></tr>
-<tr><td align="right"><b>naughtynesslimit</b></td><td><input type="text" name="naughtynesslimit" value="<? io.write( config.naughtynesslimit.value ) ?>" style="width:100px"></td></tr>
+<tr><td align="right"><b>accessdeniedaddress</b></td><td><input class="text" type="text" name="accessdeniedaddress" value="<? io.write( config.accessdeniedaddress.value ) ?>" style="width:250px"></td></tr>
+<tr><td align="right"><b>naughtynesslimit</b></td><td><input class="text" type="text" name="naughtynesslimit" value="<? io.write( config.naughtynesslimit.value ) ?>" style="width:100px"></td></tr>
</table><br><br>
-<input type="submit" name="cmd" value="save" style="width:100px"><br>
+<input class="submit" type="submit" name="cmd" value="save" style="width:100px"><br>
</form>
diff --git a/dansguardian-plain-html.lsp b/dansguardian-plain-html.lsp
index 6b0bf2e..ecc9450 100644
--- a/dansguardian-plain-html.lsp
+++ b/dansguardian-plain-html.lsp
@@ -35,9 +35,9 @@
<form action="" method="POST">
<table><tr>
<td>dansguardian 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>
+<td><input class="submit" type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td>
</tr></table>
</form>
@@ -56,6 +56,6 @@ These parameters define the interface and port that Dansguardian uses to accept
<tr><td><textarea name="config" style="width:600px"><? io.write( service.config ) ?></textarea></td></tr>
</table><br>
-<input type="submit" name="cmd" value="save" style="width:100px"><br>
+<input class="submit" type="submit" name="cmd" value="save" style="width:100px"><br>
</form>
diff --git a/squid-advanced-html.lsp b/squid-advanced-html.lsp
index 072da93..920ffcc 100644
--- a/squid-advanced-html.lsp
+++ b/squid-advanced-html.lsp
@@ -28,9 +28,9 @@
<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>
+<td><input class="submit" type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td>
</tr></table>
</form>
@@ -44,6 +44,6 @@ until you restart the service.<br><br>
<form action="" method="POST">
<table>
<tr><td><textarea name="config" style="width:600px;"><? io.write( service.config ) ?></textarea></td></tr>
-<tr><td><input type="submit" name="cmd" value="save" style="width:600px;"></td></tr>
+<tr><td><input class="submit" type="submit" name="cmd" value="save" style="width:600px;"></td></tr>
</table>
</form>
diff --git a/squid-basic-html.lsp b/squid-basic-html.lsp
index 692bd06..c5e795a 100644
--- a/squid-basic-html.lsp
+++ b/squid-basic-html.lsp
@@ -30,9 +30,9 @@ This page determines the general operational settings for squid.<br><br>
<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>
+<td><input class="submit" type="submit" name="srvcmd" value="start" <? io.write( srv1fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="stop" <? io.write( srv2fill ) ?> style="width:100px"></td>
+<td><input class="submit" type="submit" name="srvcmd" value="restart" <? io.write( srv2fill ) ?> style="width:100px"></td>
</tr></table>
</form>
@@ -49,8 +49,8 @@ until you restart the service.<br><br>
These parameters define the interface and port that the web proxy uses to accept connections.<br><br>
<table>
-<tr><td align="right"><b>proxyip</b></td><td><input type="text" name="proxyip" value="<? io.write( config.proxyip.value ) ?>"></td></tr>
-<tr><td align="right"><b>proxyport</b></td><td><input type="text" name="proxyport" value="<? io.write( config.proxyport.value ) ?>"></td></tr>
+<tr><td align="right"><b>proxyip</b></td><td><input class="text" type="text" name="proxyip" value="<? io.write( config.proxyip.value ) ?>"></td></tr>
+<tr><td align="right"><b>proxyport</b></td><td><input class="text" type="text" name="proxyport" value="<? io.write( config.proxyport.value ) ?>"></td></tr>
</table><br>
<h2>Filter Service</h2>
@@ -63,9 +63,9 @@ for filtering. Anything not matching the regular expression filter will bypass t
It is safe to leave this at the default settings.<br><br>
<table>
-<tr><td align="right"><b>filterip</b></td><td><input type="text" name="filterip" value="<? io.write( config.filterip.value ) ?>"</td></tr>
-<tr><td align="right"><b>filterport</b></td><td><input type="text" name="filterport" value="<? io.write( config.filterport.value ) ?>"></td></tr>
-<tr><td align="right"><b>FilterRegex</b></td><td><input type="text" name="filterregex" value="<? io.write( config.filterregex.value ) ?>" style="width:400px;"></td></tr>
+<tr><td align="right"><b>filterip</b></td><td><input class="text" type="text" name="filterip" value="<? io.write( config.filterip.value ) ?>"</td></tr>
+<tr><td align="right"><b>filterport</b></td><td><input class="text" type="text" name="filterport" value="<? io.write( config.filterport.value ) ?>"></td></tr>
+<tr><td align="right"><b>FilterRegex</b></td><td><input class="text" type="text" name="filterregex" value="<? io.write( config.filterregex.value ) ?>" style="width:400px;"></td></tr>
</table><br>
<h2>Access Logs</h2>
@@ -93,10 +93,10 @@ servers run on other ports as well. These fields list all ports and port ranges
It is safe to leave these values at their default values.<br><br>
<table>
-<tr><td align="right"><b>Safe_ports</b></td><td><input type="text" name="safeports" value="<? io.write( config.safeports.value ) ?>" style="width:400px;"></td></tr>
-<tr><td align="right"><b>SSL_ports</b></td><td><input type="text" name="sslports" value="<? io.write( config.sslports.value ) ?>" style="width:400px;"></td></tr>
+<tr><td align="right"><b>Safe_ports</b></td><td><input class="text" type="text" name="safeports" value="<? io.write( config.safeports.value ) ?>" style="width:400px;"></td></tr>
+<tr><td align="right"><b>SSL_ports</b></td><td><input class="text" type="text" name="sslports" value="<? io.write( config.sslports.value ) ?>" style="width:400px;"></td></tr>
</table><br>
-<input type="submit" name="cmd" value="save" style="width:100px"><br>
+<input class="submit" type="submit" name="cmd" value="save" style="width:100px"><br>
</form><br>
diff --git a/squid-model.lua b/squid-model.lua
index 3c80828..6c272c6 100644
--- a/squid-model.lua
+++ b/squid-model.lua
@@ -2,6 +2,8 @@
-- Copyright(c) 2007 A. Brodmann - Licensed under terms of GPL2
module (..., package.seeall)
+require "format"
+
squidconf = "/etc/squid/squid.conf"
--- the tokenizer functions - must be dislocated into a library later
@@ -106,7 +108,7 @@ update_adv_config = function( config )
local ptr = io.open( squidconf, "wb+" )
if ptr ~= nil then
- ptr:write( config )
+ ptr:write( format.dostounix( config ) )
ptr:close()
else
retval = "update_config(): Error, failed to open " .. squidconf .. "!\n"
@@ -411,14 +413,14 @@ config_preblock_copy = function( fromfile, tofile, tag )
end
end
-copy_postblock_copy = function( fromfile, tofile )
+config_postblock_copy = function( fromfile, tofile )
local done = false
local line = ""
while not done do
line = fromfile:read( "*l" )
if line ~= nil then
- tmpfile:write( line .. "\n" )
+ tofile:write( line .. "\n" )
else
done = true
end
@@ -467,7 +469,7 @@ update_basic_config = function( config )
tmpfile = io.open( tmpfilename, "w+" )
cfgfile = io.open( squidconf, "r" )
done = false
-
+
config_preblock_copy( cfgfile, tmpfile, "### ACF-SQUID-TAG-0007" )
local don2 = false
@@ -481,14 +483,26 @@ update_basic_config = function( config )
else
if string.sub( line, 1, 11 ) == "cache_peer " then
don2 = true
- local lap = 0
+ local lap = 1
local cfg2tok = tokenizer.new( line, " " )
- local tmpstr = ""
- while tmpstr ~= nil do
-
+ local tmpval = ""
+ local newstr = ""
+ local tmparr = {}
+ cfg2tok, tmpval = tokenizer.next( cfg2tok )
+ while tmpval ~= nil do
+ tmparr[lap] = tmpval
+ if lap == 2 then
+ newstr = newstr .. config.filterip.value .. " "
+ elseif lap == 4 then
+ newstr = newstr .. config.filterport.value .. " "
+ else
+ newstr = newstr .. tmpval .. " "
+ end
+ lap = lap + 1
+ cfg2tok, tmpval = tokenizer.next( cfg2tok )
end
-
- tmpfile:write( "http_port " .. config.proxyip.value .. ":" .. config.proxyport.value .. "\n" )
+
+ tmpfile:write( newstr .. "\n" )
else
tmpfile:write( line .. "\n" )
end
@@ -512,7 +526,68 @@ update_basic_config = function( config )
while not done do
line = cfgfile:read( "*l" )
-
+ if string.sub( line, 1, 7 ) == "### ACF" then
+ done = true
+ tmpfile:write( line .. "\n" )
+ else
+ if config.diskcache.value == "yes" then
+ if string.sub( line, 1, 16 ) == "#cache_dir diskd" then
+ tmpfile:write( string.sub( line, 2 ) .. "\n" )
+ elseif string.sub( line, 1, 14 ) == "cache_dir null" then
+ tmpfile:write( "#" .. line .. "\n" )
+ else
+ tmpfile:write( line .. "\n" )
+ end
+ else
+ if string.sub( line, 1, 15 ) == "cache_dir diskd" then
+ tmpfile:write( "#" .. line .. "\n" )
+ elseif string.sub( line, 1, 15 ) == "#cache_dir null" then
+ tmpfile:write( string.sub( line, 2 ) .. "\n" )
+ else
+ tmpfile:write( line .. "\n" )
+ end
+ end
+ end
+ end
+
+ config_postblock_copy( cfgfile, tmpfile )
+
+ tmpfile:close()
+ cfgfile:close()
+ os.rename( tmpfilename, squidconf )
+
+
+ --- cache access log parameters
+ tmpfilename = os.tmpname()
+ tmpfile = io.open( tmpfilename, "w+" )
+ cfgfile = io.open( squidconf, "r" )
+ done = false
+
+ config_preblock_copy( cfgfile, tmpfile, "### ACF-SQUID-TAG-0003" )
+
+ while not done do
+ line = cfgfile:read( "*l" )
+ if string.sub( line, 1, 7 ) == "### ACF" then
+ done = true
+ tmpfile:write( line .. "\n" )
+ else
+ if config.accesslog.value == "yes" then
+ if string.sub( line, 1, 17 ) == "#cache_access_log" then
+ tmpfile:write( string.sub( line, 2 ) .. "\n" )
+ elseif string.sub( line, 1, 18 ) == "# cache_access_log" then
+ tmpfile:write( string.sub( line, 3 ) .. "\n" )
+ else
+ tmpfile:write( line .. "\n" )
+ end
+ else
+ if string.sub( line, 1, 16 ) == "cache_access_log" then
+ tmpfile:write( "#" .. line .. "\n" )
+ else
+ tmpfile:write( line .. "\n" )
+ end
+ end
+
+ end
end
config_postblock_copy( cfgfile, tmpfile )
@@ -521,6 +596,40 @@ update_basic_config = function( config )
cfgfile:close()
os.rename( tmpfilename, squidconf )
+
+ --- cache access log parameters
+ tmpfilename = os.tmpname()
+ tmpfile = io.open( tmpfilename, "w+" )
+ cfgfile = io.open( squidconf, "r" )
+ done = false
+
+ config_preblock_copy( cfgfile, tmpfile, "### ACF-SQUID-TAG-0005" )
+
+ while not done do
+ line = cfgfile:read( "*l" )
+ if string.sub( line, 1, 7 ) == "### ACF" then
+ done = true
+ tmpfile:write( line .. "\n" )
+ else
+ if string.sub( line, 1, 18 ) == "acl SSL_ports port" then
+ tmpfile:write( "acl SSL_ports port " .. config.sslports.value .. "\n" )
+ elseif string.sub( line, 1, 19 ) == "acl Safe_ports port" then
+ tmpfile:write( "acl Safe_ports port " .. config.safeports.value .. "\n" )
+ elseif string.sub( line, 1, 34 ) == "acl ContentFilter urlpath_regex -i" then
+ tmpfile:write( "acl ContentFilter urlpath_regex -i " .. config.filterregex.value .. "\n" )
+ else
+ tmpfile:write( line .. "\n" )
+ end
+ end
+ end
+
+ config_postblock_copy( cfgfile, tmpfile )
+
+ tmpfile:close()
+ cfgfile:close()
+ os.rename( tmpfilename, squidconf )
+
+
return error
end