/*
	Add the user-agent to redirector.c. Replace the following:
	
    snprintf(buf, 8192, "%s %s/%s %s %s\n",
        r->orig_url,
        inet_ntoa(r->client_addr),
        fqdn,
        r->client_ident,
        r->method_s);
	with the whole section below
*/
if (1)
{
	request_t *request = http->request;
	const HttpHeader *req_hdr = &request->header;
	const char *str;

	if ((str = httpHeaderGetStr(req_hdr, HDR_USER_AGENT)))
	{
		snprintf(buf, 8192, "%s %s/%s %s %s %s\n",
		r->orig_url,
		inet_ntoa(r->client_addr),
		fqdn,
		r->client_ident,
		r->method_s,
		str);
	}
	else
	{
		snprintf(buf, 8192, "%s %s/%s %s %s\n",
		r->orig_url,
		inet_ntoa(r->client_addr),
		fqdn,
		r->client_ident,
		r->method_s);
	}
}
else
{
    snprintf(buf, 8192, "%s %s/%s %s %s\n",
        r->orig_url,
        inet_ntoa(r->client_addr),
        fqdn,
        r->client_ident,
        r->method_s);
}


main_redirector
#!/usr/bin/perl
#

$| = 1;

@endings = qw/ \.gif$ \.jpg$ \.jpeg$ \.png$ \.gz$ \.img$ \.tgz$ \.sit$ \.hqx$ \.
image$ \.bin$ \.Z$ \.TAZ$ \.exe$ \.zip$ \.avi$ \.mov$ \.mp3$ \.mpg$ \.mpeg$ \.mo
v$ \.pkg$ \.wav$ \.dmg$ \.aiff$ \.pdf$ \.iso$ \.toast$ \.bz2$ \.js$ \.css$ /;
while (<>)
{
    ($url, $addr, $fqdn, $ident, $method, $agent) = m:(\S*) (\S*)/(\S*) (\S*) (\
S*) (\S*):;
        if ($method eq "GET")
        {
                $stop = 0;
                foreach $ending (@endings)
                {
                        if (($url =~ /$ending/i))
                        {
                                $stop = 1;
                                break;
                        }
                }
                if ($stop == 0)
                {
                        system("/opt/servers/squid_main/preget $url $agent");
                }
        }
        print "\n";
}
# EOF

preget
#!/bin/sh
#

#echo "$1" >> /opt/data/squid_back/logs/mylog

#http_proxy="http://10.163.3.1:3129/"
http_proxy="http://10.163.3.2:3129/"
export http_proxy

echo "pregetting $1 $2" >> /opt/data/squid_main/logs/myurls

wget -q --level=1 -nd -U "$2" --directory-prefix=/tmp/targ/ -p "$1"

rm -rf /tmp/targ/* &
# EOF