include/IPAddress.h lib/IPAddress.cc:
include/rfc3596.h lib/rfc3596.cc:
src/ICMPv6.h src/ICMPv6.cc:
+helpers/url_rewrite/fake/ fake.h, fake.cc, url_fake_rewrite.sh:
- This code is copyright (C) 2007 by Treehouse Networks Ltd
+ This code is copyright (C) 2007-2009 by Treehouse Networks Ltd
of New Zealand. It is published and Licensed as an extension of
squid under the same conditions as the main squid application.
#include "compat/stdvarargs.h"
#include "compat/assert.h"
+
/*****************************************************/
/* component-specific portabilities */
/*****************************************************/
+/* helper debugging requires some hacks to be clean */
+#include "compat/helper_debug.h"
+
/* Valgrind API macros changed between two versions squid supports */
#include "compat/valgrind.h"
--- /dev/null
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef COMPAT_HELPER_DEBUG_H
+#define COMPAT_HELPER_DEBUG_H
+
+/*
+ * A debug method for use of external helpers.
+ * It shunts the debug messages down stderr for logging by Squid
+ * of display to the user instead of corrupting the stdout data stream.
+ */
+
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+/* Debugging stuff */
+
+/* the macro overload style is really a gcc-ism */
+#ifdef __GNUC__
+
+SQUIDCEXTERN int debug_enabled;
+
+#define helper_debug(X...) \
+ if (debug_enabled) { \
+ fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
+ fprintf(stderr,X); \
+ }
+
+#else /* __GNUC__ */
+
+/* TODO: non-GCC compilers can't do the above macro define yet. */
+inline void
+helper_debug(char *format,...)
+{
+ ; // nothing to do.
+}
+#endif
+
+
+#endif /* COMPAT_HELPER_DEBUG_H */
fi
AC_SUBST(EXTERNAL_ACL_HELPERS)
+dnl Select url_rewrite helpers to build
+URL_REWRITE_HELPERS=all
+AC_ARG_ENABLE(url-rewrite-helpers,
+ AC_HELP_STRING([--enable-url-rewrite-helpers="list of helpers"],
+ [This option selects which url_rewrite helpers to
+ build and install as part of the normal build
+ process. For a list of available helpers see the
+ helpers/url_rewrite directory.]),
+[ case "$enableval" in
+ yes)
+ URL_REWRITE_HELPERS=all
+ ;;
+ no)
+ URL_REWRITE_HELPERS=""
+ ;;
+ *)
+ URL_REWRITE_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/ */ /g'`"
+ ;;
+ esac
+])
+if test "$URL_REWRITE_HELPERS" = "all" ; then
+ URL_REWRITE_HELPERS=""
+ for dir in $srcdir/helpers/url_rewrite/*; do
+ helper="`basename $dir`"
+ if test -f $dir/config.test && sh $dir/config.test "$@"; then
+ URL_REWRITE_HELPERS="$URL_REWRITE_HELPERS $helper"
+ fi
+ done
+fi
+if test -n "$URL_REWRITE_HELPERS"; then
+ for helper in $URL_REWRITE_HELPERS; do
+ if test -f $srcdir/helpers/url_rewrite/$helper/Makefile.in; then
+ :
+ else
+ AC_MSG_ERROR(url_rewrite helper $helper does not exist)
+ fi
+ done
+ AC_MSG_NOTICE([url_rewrite helpers built: $URL_REWRITE_HELPERS])
+fi
+AC_SUBST(URL_REWRITE_HELPERS)
+
+
AC_ARG_WITH(valgrind-debug,
AS_HELP_STRING([--with-valgrind-debug],[Include debug instrumentation for use with valgrind]),
[ case $withval in
helpers/external_acl/wbinfo_group/Makefile \
helpers/external_acl/mswin_ad_group/Makefile \
helpers/external_acl/mswin_lm_group/Makefile \
+ helpers/url_rewrite/Makefile \
+ helpers/url_rewrite/fake/Makefile \
tools/Makefile
])
my_program_name, my_program_name);
}
-char debug_enabled=0;
+int debug_enabled=0;
void
process_options(int argc, char *argv[])
/* Debugging stuff */
-
+#ifndef debug /* already provided */
#ifdef __GNUC__ /* this is really a gcc-ism */
#ifdef DEBUG
#include <stdio.h>
#include <unistd.h>
static const char *__foo;
-extern char debug_enabled;
+extern int debug_enabled;
#define debug(X...) if (debug_enabled) { \
fprintf(stderr,"ntlm-auth[%ld](%s:%d): ", (long)getpid(), \
((__foo=strrchr(__FILE__,'/'))==NULL?__FILE__:__foo+1),\
debug(char *format,...)
{
}
-
#endif
-
+#endif /* debug already defined */
/* A couple of harmless helper macros */
#define SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n");
--- /dev/null
+
+DIST_SUBDIRS = fake
+SUBDIRS = @URL_REWRITE_HELPERS@
--- /dev/null
+include $(top_srcdir)/src/Common.am
+
+libexec_PROGRAMS = url_fake_rewrite url_fake_rewrite.sh
+
+url_fake_rewrite_SOURCES = fake.cc
+url_fake_rewrite_LDADD = $(COMPAT_LIBS)
--- /dev/null
+#!/bin/sh
+exit 0
--- /dev/null
+/*
+ * AUTHOR: Amos Jeffries <squid3@treenet.co.nz>
+ *
+ * Example url re-writer program for Squid.
+ *
+ * This code gets the url and returns it. No re-writing is done.
+ * It is intended for testing use and as a base for further implementation.
+ *
+ *
+ * This code is copyright (C) 2009 by Treehouse Networks Ltd
+ * of New Zealand. It is published and Licensed as an extension of
+ * squid under the same conditions as the main squid application.
+ */
+
+#include "config.h"
+
+#define BUFFER_SIZE 10240
+
+/**
+ * options:
+ * -d enable debugging.
+ * -h interface help.
+ */
+char *my_program_name = NULL;
+int concurrent_detected = -1;
+
+
+static void
+usage(void)
+{
+ fprintf(stderr,
+ "Usage: %s [-d] [-v] [-h]\n"
+ " -d enable debugging.\n"
+ " -h this message\n\n",
+ my_program_name);
+}
+
+static void
+process_options(int argc, char *argv[])
+{
+ int opt, had_error = 0;
+
+ opterr = 0;
+ while (-1 != (opt = getopt(argc, argv, "hd"))) {
+ switch (opt) {
+ case 'd':
+ debug_enabled = 1;
+ break;
+ case 'h':
+ usage();
+ exit(0);
+ case '?':
+ opt = optopt;
+ /* fall thru to default */
+ default:
+ fprintf(stderr, "unknown option: -%c. Exiting\n", opt);
+ usage();
+ had_error = 1;
+ }
+ }
+ if (had_error)
+ exit(1);
+}
+
+bool
+detect_concurrent(const char *)
+{
+ // TODO: scan the char* input and see if it is 100% numeric.
+ // if so, enable concurrent support IDs.
+}
+
+int
+main(int argc, char *argv[])
+{
+ char buf[BUFFER_SIZE];
+ int buflen = 0;
+ char helper_command[3];
+
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
+
+ my_program_name = argv[0];
+
+ process_options(argc, argv);
+
+ helper_debug("%s build " __DATE__ ", " __TIME__ " starting up...\n", my_program_name);
+
+ while (fgets(buf, BUFFER_SIZE, stdin) != NULL) {
+
+ if ((p = strchr(buf, '\n')) != NULL) {
+ *p = '\0'; /* strip \n */
+ buflen = p - buf; /* length is known already */
+ }
+ else
+ buflen = strlen(buf); /* keep this so we only scan the buffer for \0 once per loop */
+
+/* TODO: later.
+ if (concurrent_detected < 0)
+ detect_concurrent(buf);
+// */
+
+ helper_debug("Got %d bytes '%s' from Squid\n", buflen, buf);
+
+ /* send 'no-change' result back to Squid */
+ fprintf(stdout,"\n");
+ }
+ helper_debug("%s build " __DATE__ ", " __TIME__ " shutting down...\n", my_program_name);
+ exit(0);
+}
--- /dev/null
+#!/bin/sh
+#
+# Author: Amos Jeffries <squid3@treenet.co.nz>
+#
+# This code is copyright (C) 2009 by Treehouse Networks Ltd
+# of New Zealand. It is published and Licensed as an extension of
+# squid under the same conditions as the main squid application.
+#
+
+if test "${1}" = "-d" ; then
+ echo "Usage: $0 [-h] [-d logfile]"
+ echo " -h Help: this help text"
+ echo " -d logfile Debug: log all data received to the named file"
+ exit 1
+fi
+
+DEBUG=0
+if test "${1}" = "-d" ; then
+ DEBUG=1
+ LOG="${2}"
+fi
+
+while read url rest; do
+ if test ${DEBUG} ; then
+ echo "$url $rest" >>${LOG}
+ fi
+ echo # blank line for no change, or replace with another URL.
+done
## make all compiled sources depend on generated files
## XXX: Do we really need this? Does auto-dependency tracking work?
$(OBJS): $(top_srcdir)/include/version.h $(top_builddir)/include/autoconf.h
+
+## Because compatibility is almost universal. And the link order is important.
+COMPAT_LIBS = \
+ -L$(top_builddir)/lib -lmiscutil \
+ $(top_builddir)/compat/libcompat.la
helperKickQueue(hlp);
}
-/*
+/**
* DPW 2007-05-08
*
* helperStatefulOpenServers: create the stateful child helper processes
debugs(84, 9, "helperSubmit: " << buf);
}
-/* lastserver = "server last used as part of a reserved request sequence"
- */
+/// lastserver = "server last used as part of a reserved request sequence"
void
helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, void *data, helper_stateful_server * lastserver)
{
debugs(84, 9, "helperStatefulSubmit: placeholder: '" << r->placeholder << "', buf '" << buf << "'.");
}
-/*
+/**
* DPW 2007-05-08
*
* helperStatefulReleaseServer tells the helper that whoever was
helperStatefulServerDone(srv);
}
+/** return a pointer to the stateful routines data area */
void *
helperStatefulServerGetData(helper_stateful_server * srv)
-/* return a pointer to the stateful routines data area */
{
return srv->data;
}
+/**
+ * Dump some stats about the helper states to a StoreEntry
+ */
void
helperStats(StoreEntry * sentry, helper * hlp, const char *label)
{
for (dlink_node *link = hlp->servers.head; link; link = link->next) {
helper_stateful_server *srv = (helper_stateful_server *)link->data;
- double tt = 0.001 * tvSubMsec(srv->dispatch_time,
- srv->flags.busy ? current_time : srv->answer_time);
- storeAppendPrintf(sentry, "%7d\t%7d\t%7d\t%11d\t%c%c%c%c%c\t%7.3f\t%7d\t%s\n",
+ double tt = 0.001 * tvSubMsec(srv->dispatch_time, srv->flags.busy ? current_time : srv->answer_time);
+ double tr = 0.001 * tvSubMsec(srv->dispatch_time, current_time);
+ storeAppendPrintf(sentry, "%7d\t%7d\t%7d\t%11d\t%c%c%c%c%c\t%7.3f\t%7.3f\t%7d\t%s\n",
srv->index + 1,
srv->rfd,
srv->pid,
srv->flags.reserved ? 'R' : ' ',
srv->flags.shutdown ? 'S' : ' ',
srv->request ? (srv->request->placeholder ? 'P' : ' ') : ' ',
- tt < 0.0 ? 0.0 : tt,
- (int) srv->roffset,
- srv->request ? log_quote(srv->request->buf) : "(none)");
+ tt < 0.0 ? 0.0 : tt,
+ srv->flags.reserved || tr > 0.0 ? tr : 0.0,
+ (int) srv->roffset,
+ srv->request ? log_quote(srv->request->buf) : "(none)");
}
storeAppendPrintf(sentry, "\nFlags key:\n\n");
{
icmpEngine.Close();
#if USE_DNSSERVERS
-
dnsShutdown();
#endif
-
redirectShutdown();
authenticateShutdown();
externalAclShutdown();
+
_db_rotate_log(); /* cache.log */
storeDirWriteCleanLogs(1);
storeLogRotate(); /* store.log */
icapLogRotate(); /*icap.log*/
#endif
#if WIP_FWD_LOG
-
fwdLogRotate();
#endif
icmpEngine.Open();
#if USE_DNSSERVERS
-
dnsInit();
#endif
-
redirectInit();
authenticateInit(&Config.authConfiguration);
externalAclInit();