]> git.pld-linux.org Git - packages/squid.git/blame - squid-contrib.patch
- updated
[packages/squid.git] / squid-contrib.patch
CommitLineData
49542ef7
AM
1diff -urN squid-2.5.STABLE1.org/contrib/config.site squid-2.5.STABLE1/contrib/config.site
2--- squid-2.5.STABLE1.org/contrib/config.site Thu Jan 1 01:00:00 1970
3+++ squid-2.5.STABLE1/contrib/config.site Tue Sep 24 22:28:05 1996
4@@ -0,0 +1,46 @@
5+# This is file config.site.
6+# Set environment variable CONFIG_SITE to this file
7+# to get site specific defaults for configure
8+# AUTHOR: Markus Gyger
9+
10+# HP ANSI/ISO C compiler
11+: ${CC="cc -Ae"}
12+: ${CFLAGS="-O -g"}
13+: ${LDFLAGS="${CFLAGS}"}
14+
15+# Default installation directory layout based on prefix path
16+case $prefix in
17+/opt/*) # AT&T SVR4, OSF/1 file system layout defaults
18+# prefix='/opt/<appname>'
19+# exec_prefix='${prefix}'
20+# bindir='${exec_prefix}/bin'
21+# sbindir='${exec_prefix}/sbin'
22+ libexecdir='${exec_prefix}/lbin'
23+# datadir='${prefix}/share'
24+ sysconfdir='/etc${prefix}'
25+ sharedstatedir='/var/share${prefix}'
26+ localstatedir='/var${prefix}'
27+# libdir='${exec_prefix}/lib'
28+ includedir='${datadir}/include'
29+# oldincludedir='/usr/include'
30+ infodir='${datadir}/info'
31+ mandir='${datadir}/man'
32+ ;;
33+
34+*) # GNU, BSD file system directory layout defaults
35+# prefix=/usr/local
36+# exec_prefix='${prefix}'
37+# bindir='${exec_prefix}/bin'
38+# sbindir='${exec_prefix}/sbin'
39+# libexecdir='${exec_prefix}/libexec'
40+# datadir='${prefix}/share'
41+# sysconfdir='${prefix}/etc'
42+# sharedstatedir='${prefix}/com'
43+# localstatedir='${prefix}/var'
44+# libdir='${exec_prefix}/lib'
45+# includedir='${prefix}/include'
46+# oldincludedir='/usr/include'
47+# infodir='${prefix}/info'
48+# mandir='${prefix}/man'
49+ ;;
50+esac
51diff -urN squid-2.5.STABLE1.org/contrib/rredir.c squid-2.5.STABLE1/contrib/rredir.c
52--- squid-2.5.STABLE1.org/contrib/rredir.c Thu Jan 1 01:00:00 1970
53+++ squid-2.5.STABLE1/contrib/rredir.c Sat Sep 14 18:54:47 1996
54@@ -0,0 +1,102 @@
55+/* $Id$ */
56+
57+/*
58+ * From: richard@hekkihek.hacom.nl (Richard Huveneers)
59+ * To: squid-users@nlanr.net
60+ * Subject: Save 15% on your bandwidth...
61+ * Date: 12 Sep 1996 21:21:55 GMT
62+ * ===========================================================================
63+ *
64+ * I have downloaded the multi-megabyte files from Netscape and Microsoft
65+ * that our users like to download from every mirror in the world,
66+ * defeating the usual caching.
67+ *
68+ * I put these files in a separate directory and installed a basic
69+ * redirector for Squid that checks if the file (so hostname and pathname
70+ * are disregarded) is present in this directory.
71+ *
72+ * After a few days of testing (the redirector looks very stable) it looks
73+ * like this is saving us approx. 15% on our cache flow. Also, our own WWW
74+ * server has become more popular than ever :)
75+ *
76+ * I'm sure this code will be useful to others too, so I've attached it at
77+ * the end of this message. Improvements, extensions etc. are welcome.
78+ *
79+ * I'm going on holidays now, so I won't be able to respond to e-mail
80+ * quickly.
81+ *
82+ * Enjoy, Richard.
83+ */
84+
85+/*
86+ * rredir - redirect to local directory
87+ *
88+ * version 0.1, 7 sep 1996
89+ * - initial version (Richard Huveneers <Richard.Huveneers@hekkihek.hacom.nl>)
90+ */
91+
92+#include <stdio.h>
93+#include <unistd.h>
94+#include <string.h>
95+#include <ctype.h>
96+
97+#define ACCESS_LOCAL_DIR "/var/lib/httpd/htdocs/local/rredir"
98+#define REDIRECT_TO_URL "http://www.hacom.nl/local/rredir"
99+#define BUFFER_SIZE (16*1024)
100+
101+int
102+main()
103+{
104+ char buf[BUFFER_SIZE];
105+ char *s, *t;
106+ int tlu = 0;
107+
108+ /* make standard output line buffered */
109+ if (setvbuf(stdout, NULL, _IOLBF, 0) != 0)
110+ return 1;
111+
112+ /* speed up the access() calls below */
113+ if (chdir(ACCESS_LOCAL_DIR) == -1)
114+ return 1;
115+
116+ /* scan standard input */
117+ while (fgets(buf, BUFFER_SIZE, stdin) != NULL) {
118+ /* check for too long urls */
119+ if (strchr(buf, '\n') == NULL) {
120+ tlu = 1;
121+ continue;
122+ }
123+ if (tlu)
124+ goto dont_redirect;
125+
126+ /* determine end of url */
127+ if ((s = strchr(buf, ' ')) == NULL)
128+ goto dont_redirect;
129+ *s = '\0';
130+
131+ /* determine first character of filename */
132+ if ((s = strrchr(buf, '/')) == NULL)
133+ goto dont_redirect;
134+ s++;
135+
136+ /* security: do not redirect to hidden files, the current
137+ * ** directory or the parent directory */
138+ if (*s == '.' || *s == '\0')
139+ goto dont_redirect;
140+
141+ /* map filename to lower case */
142+ for (t = s; *t != '\0'; t++)
143+ *t = (char) tolower((int) *t);
144+
145+ /* check for a local copy of this file */
146+ if (access(s, R_OK) == 0) {
147+ (void) printf("%s/%s\n", REDIRECT_TO_URL, s);
148+ continue;
149+ }
150+ dont_redirect:
151+ tlu = 0;
152+ (void) printf("\n");
153+ }
154+
155+ return 0;
156+}
157diff -urN squid-2.5.STABLE1.org/contrib/rredir.pl squid-2.5.STABLE1/contrib/rredir.pl
158--- squid-2.5.STABLE1.org/contrib/rredir.pl Thu Jan 1 01:00:00 1970
159+++ squid-2.5.STABLE1/contrib/rredir.pl Wed Jul 16 22:31:48 1997
160@@ -0,0 +1,60 @@
161+#!/usr/bin/perl -T -w
162+#
163+# rredir.pl
164+#
165+# Author: Peter Eisenhauer <pe@pipetronix.de>
166+# First Version: 26. May 1997
167+#
168+# Description: Direct all request to files who are in a local dir to
169+# this directory
170+#
171+use File::Basename;
172+use URI::URL;
173+
174+# customization part
175+
176+# Local Domainame from which no redirects should be done
177+$localdomain = 'pipetronix.de';
178+# Local domainame qouted for regexps
179+$regexlocaldomain = quotemeta($localdomain);
180+# Path under which the scripts accesses the local dir (must end with /)
181+$access_local_dir='/opt/utils/etc/httpd/htdocs/local-rredir/';
182+# Information for the redirected URL (redirect_path must end with /)
183+$redirect_scheme = 'http';
184+$redirect_host = 'ws-server.pipetronix.de';
185+$redirect_path = 'local-rredir/';
186+
187+# end of customization part
188+
189+# flush after every print
190+$| = 1;
191+
192+# Process lines of the form 'URL ip-address/fqdn ident method'
193+# See release notes of Squid 1.1 for details
194+while ( <> ) {
195+ ($url, $addr, $fqdn, $ident, $method) = m:(\S*) (\S*)/(\S*) (\S*) (\S*):;
196+
197+ $url = url $url;
198+ $host = lc($url->host);
199+
200+ # do not process hosts in local domain or unqualified hostnames
201+ if ( $host =~ /$regexlocaldomain/ || $host !~ /\./ ) {
202+ next;
203+ }
204+
205+ # just the file, without any host or path parts
206+ # and just in case: lowercase the file name, so you should make sure
207+ # all the files in the local dir are only lowercase !!
208+ $file = lc(basename($url->path));
209+
210+ # look if in local dir, if yes redirect
211+ if ( $file && -r $access_local_dir . $file
212+ && $file ne '.' && $file ne '..' ) {
213+ $url->scheme($redirect_scheme);
214+ $url->host($redirect_host);
215+ $url->path($redirect_path . $file);
216+ }
217+
218+} continue {
219+ print "$url $addr/$fqdn $ident $method\n"
220+}
221diff -urN squid-2.5.STABLE1.org/contrib/squid.options squid-2.5.STABLE1/contrib/squid.options
222--- squid-2.5.STABLE1.org/contrib/squid.options Thu Jan 1 01:00:00 1970
223+++ squid-2.5.STABLE1/contrib/squid.options Fri Oct 11 01:30:40 1996
224@@ -0,0 +1,13 @@
225+#!/sbin/sh
226+#
227+# Squid Internet Object Cache configuration
228+# AUTHOR: Markus Gyger
229+# This is file /etc/rc.config.d/squid or /var/config/squid.options
230+
231+# SQUID: Set to 1 to enable Squid (HP-UX 10 only)
232+# SQUID_OPTIONS: Options passed to Squid (e.g. "-f .../squid.conf")
233+# SQUID_RESPAWN: Set to 1 to automatically restart squid after failure
234+
235+SQUID=0
236+SQUID_OPTIONS="-s"
237+SQUID_RESPAWN=1
238diff -urN squid-2.5.STABLE1.org/contrib/squid.rc squid-2.5.STABLE1/contrib/squid.rc
239--- squid-2.5.STABLE1.org/contrib/squid.rc Thu Jan 1 01:00:00 1970
240+++ squid-2.5.STABLE1/contrib/squid.rc Fri Oct 11 01:30:40 1996
241@@ -0,0 +1,119 @@
242+#!/sbin/sh
243+
244+# Squid Internet Object Cache startup
245+# AUTHOR: Markus Gyger
246+# This is squid's startup file /sbin/init.d/squid or /etc/init.d/squid
247+
248+
249+PATH=/opt/squid/bin:/usr/sbin:/usr/bin:/sbin:/bin
250+export PATH
251+
252+
253+config()
254+{
255+ # SGI IRIX 6.2
256+ if [ -f /sbin/chkconfig ]
257+ then if /sbin/chkconfig squid
258+ then if [ -f /var/config/squid.options ]
259+ then . /var/config/squid.options
260+ fi
261+ SQUID=1
262+ else SQUID=0
263+ fi
264+
265+ # Digital UNIX
266+ elif [ -f /usr/sbin/rcmgr ]
267+ then SQUID=`/usr/sbin/rcmgr get SQUID 0`
268+ SQUID_OPTIONS=`/usr/sbin/rcmgr get SQUID_OPTIONS "-s"`
269+ SQUID_RESPAWN=`/usr/sbin/rcmgr get SQUID_RESPAWN 1`
270+
271+ # HP-UX 10 / Linux
272+ elif [ -f /etc/rc.config ]
273+ then . /etc/rc.config
274+
275+ # SUN Solaris 2
276+ else SQUID=1
277+ SQUID_OPTIONS="-s"
278+ SQUID_RESPAWN=1
279+ fi
280+
281+ [ 1 = "${SQUID-}" ]
282+}
283+
284+
285+respawn()
286+{
287+ trap "" 1
288+ fails=0
289+ while [ $fails -le 5 ]
290+ do start=`date +%d%H%M%S`
291+ if "$@"
292+ then logger -t "$1" -p local4.notice \
293+ "respawn[$$]: Exiting due to shutdown"
294+ return 0
295+ fi
296+ stop=`date +%d%H%M%S`
297+ time=`expr $stop - $start`
298+ [ "$time" -gt 10 ] && fails=0
299+ fails=`expr $fails + 1`
300+ done
301+
302+ logger -t "$1" -p local4.alert \
303+ "respawn[$$]: Exiting due to repeated, frequent failures"
304+ return 1
305+}
306+
307+
308+case $* in
309+start_msg)
310+ echo "Start Squid Internet Object Cache"
311+ ;;
312+
313+stop_msg)
314+ echo "Stopping Squid Internet Object Cache"
315+ ;;
316+
317+start)
318+ config || exit 2 # Squid not enabled
319+
320+ if whence=`type squid 2>&1`
321+ then trap "" 1
322+ if [ 0 = "${SQUID_RESPAWN-}" ]
323+ then squid ${SQUID_OPTIONS-} &
324+ else respawn squid ${SQUID_OPTIONS-} &
325+ fi
326+
327+ else echo "ERROR: $whence" >&2
328+ exit 1
329+ fi
330+ ;;
331+
332+stop)
333+ config || exit 2 # Squid not enabled
334+
335+ squid ${SQUID_OPTIONS-} -k shutdown || exit 1
336+ ;;
337+
338+reconf*|rotate|int*|debug|check|kill)
339+ config
340+
341+ squid ${SQUID_OPTIONS-} -k "$1"
342+ ;;
343+
344+*)
345+ echo "usage: $0 {start|stop|reconfigure|rotate|interrupt|debug|check|kill}" >&2
346+ echo " start start squid" >&2
347+ echo " stop clean shutdown" >&2
348+ echo " reconfigure reread configuration files" >&2
349+ echo " rotate rotate log files" >&2
350+ echo " interrupt quick clean shutdown " >&2
351+ echo " debug toggle debug logging" >&2
352+ echo " check check for running squid" >&2
353+ echo " kill terminate squid by brute force" >&2
354+
355+ exit 1
356+ ;;
357+esac
358+
359+[ $? -eq 0 ] # only 0 and 1 exit values allowed
360+exit
361diff -urN squid-2.5.STABLE1.org/contrib/url-normalizer.pl squid-2.5.STABLE1/contrib/url-normalizer.pl
362--- squid-2.5.STABLE1.org/contrib/url-normalizer.pl Thu Jan 1 01:00:00 1970
363+++ squid-2.5.STABLE1/contrib/url-normalizer.pl Fri Dec 6 18:54:31 1996
364@@ -0,0 +1,51 @@
365+#!/usr/local/bin/perl -Tw
366+
367+# From: Markus Gyger <mgyger@itr.ch>
368+#
369+# I'd like to see a redirector which "normalizes" URLs to have
370+# a higher chance to get a hit. I didn't see such a redirector,
371+# so I thought I would send my little attempt. However, I have
372+# no real idea how much CPU time it needs using the LWP modules,
373+# but it seems to work.
374+
375+require 5.003;
376+use strict;
377+use URI::URL;
378+
379+$| = 1; # force a flush after every print on STDOUT
380+
381+my ($url, $addr, $fqdn, $ident, $method);
382+
383+while (<>) {
384+ ($url, $addr, $fqdn, $ident, $method) = m:(\S*) (\S*)/(\S*) (\S*) (\S*):;
385+
386+ # "normalize" URL
387+ $url = url $url; # also removes default port number
388+ $url->host(lc $url->host); # map host name to lower case
389+ my $epath = $url->epath;
390+ $epath =~ s/%7e/~/ig; # unescape ~
391+ $epath =~ s/(%[\da-f]{2})/\U$1/ig; # capitalize escape digits
392+ if ($url->scheme =~ /^(http|ftp)$/) {
393+ $epath =~ s:/\./:/:g; # safe?
394+ $epath =~ s://:/:g; # safe?
395+ }
396+ $url->epath($epath);
397+
398+
399+ # ...
400+
401+
402+} continue {
403+ print "$url $addr/$fqdn $ident $method\n"
404+}
405+
406+
407+BEGIN {
408+ unless (URI::URL::implementor('cache_object')) {
409+ package cache_object;
410+ @cache_object::ISA = (URI::URL::implementor());
411+ URI::URL::implementor('cache_object', 'cache_object');
412+
413+ sub default_port { 3128 }
414+ }
415+}
416diff -urN squid-2.5.STABLE1.org/contrib/user-agents.pl squid-2.5.STABLE1/contrib/user-agents.pl
417--- squid-2.5.STABLE1.org/contrib/user-agents.pl Thu Jan 1 01:00:00 1970
418+++ squid-2.5.STABLE1/contrib/user-agents.pl Fri Dec 6 18:28:56 1996
419@@ -0,0 +1,47 @@
420+#!/usr/bin/perl
421+#
422+# John@MCC.ac.uk
423+# John@Pharmweb.NET
424+
425+require "getopts.pl";
426+&Getopts('FML:');
427+
428+open (ACCESS, "/opt/Squid/logs/useragent.0");
429+
430+while (<ACCESS>) {
431+ ($host, $timestamp, $agent) =
432+ /^(\S+) \[(.+)\] \"(.+)\"\s/;
433+ if ($agent ne '-') {
434+ if ($opt_M) {
435+ $agent =~ tr/\// /;
436+ $agent =~ tr/\(/ /;
437+ }
438+ if ($opt_F) {
439+ next unless $seen{$agent}++;
440+ } else {
441+ @inline=split(/ /, $agent);
442+ next unless $seen{$inline[0]}++;
443+ }
444+ }
445+}
446+
447+$total=0;
448+if (!$opt_L) {$opt_L=0}
449+
450+print "Summary of User-Agent Strings\n(greater than $opt_L percent)\n\n";
451+
452+foreach $browser (keys(%seen)) {
453+ $total=$total+$seen{$browser};
454+}
455+
456+foreach $browser (sort keys(%seen)) {
457+ $percent=$seen{$browser}/$total*100;
458+ if ($percent >= $opt_L) { write; }
459+}
460+
461+print "\n\nTotal entries in log = $total\n";
462+
463+format STDOUT =
464+@>>>>>>> :@##.####% : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
465+$seen{$browser}, $percent, $browser
466+.
This page took 0.094981 seconds and 4 git commands to generate.