From: wessels <> Date: Wed, 28 Aug 1996 02:10:46 +0000 (+0000) Subject: Excellent DNS TTL hack from Balint Nagy Endre X-Git-Tag: SQUID_3_0_PRE1~5901 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6bf652356e41d8509d1f0e64652b035d8328d813;p=thirdparty%2Fsquid.git Excellent DNS TTL hack from Balint Nagy Endre --- diff --git a/configure b/configure index fb2d5f00b1..b442acd924 100755 --- a/configure +++ b/configure @@ -517,7 +517,7 @@ fi -# From configure.in Revision: 1.27 +# From configure.in Revision: 1.28 ac_aux_dir= for ac_dir in aux $srcdir/aux; do if test -f $ac_dir/install-sh; then @@ -2468,6 +2468,30 @@ fi rm -f conftest* +echo $ac_n "checking for libresolv _dns_ttl_ hack""... $ac_c" 1>&6 +cat > conftest.$ac_ext <&6 +cat >> confdefs.h <<\EOF +#define LIBRESOLV_DNS_TTL_HACK 1 +EOF + +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* + + XTRA_OBJS='' if test "$HAVE_LIBMALLOC" = "yes" ; then if test -r /usr/lib/debug/malloc.o ; then diff --git a/configure.in b/configure.in index cf2dd64cae..cf1809c31f 100644 --- a/configure.in +++ b/configure.in @@ -3,13 +3,13 @@ dnl Configuration input file for Squid dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.28 1996/08/27 18:01:34 wessels Exp $ +dnl $Id: configure.in,v 1.29 1996/08/27 20:10:47 wessels Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.28 $)dnl +AC_REVISION($Revision: 1.29 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(aux) @@ -434,6 +434,12 @@ AC_MSG_RESULT(yes), [AC_MSG_RESULT(no) AC_DEFINE(NEED_SYS_ERRLIST)]) +AC_MSG_CHECKING(for libresolv _dns_ttl_ hack) +AC_TRY_LINK(extern int _dns_ttl_;,return _dns_ttl_;, +[AC_MSG_RESULT(yes) +AC_DEFINE(LIBRESOLV_DNS_TTL_HACK)], +AC_MSG_RESULT(no)) + dnl Need the debugging version of malloc if available XTRA_OBJS='' if test "$HAVE_LIBMALLOC" = "yes" ; then diff --git a/include/autoconf.h.in b/include/autoconf.h.in index d29838a581..d89cf714b9 100644 --- a/include/autoconf.h.in +++ b/include/autoconf.h.in @@ -55,6 +55,9 @@ /* If gettimeofday is known to take only one argument */ #undef GETTIMEOFDAY_NO_TZP +/* If libresolv.a has been hacked to export _dns_ttl_ */ +#undef LIBRESOLV_DNS_TTL_HACK + /* The number of bytes in a int. */ #undef SIZEOF_INT diff --git a/src/dnsserver.cc b/src/dnsserver.cc index f82cffaaa5..905f7a0b82 100644 --- a/src/dnsserver.cc +++ b/src/dnsserver.cc @@ -1,6 +1,6 @@ /* - * $Id: dnsserver.cc,v 1.13 1996/08/26 19:57:04 wessels Exp $ + * $Id: dnsserver.cc,v 1.14 1996/08/27 20:10:51 wessels Exp $ * * DEBUG: section 0 DNS Resolver * AUTHOR: Harvest Derived @@ -216,6 +216,10 @@ extern int h_errno; +#if LIBRESOLV_DNS_TTL_HACK +extern int _dns_ttl_; /* this is a really *dirty* hack - bne */ +#endif + int do_debug = 0; /* error messages from gethostbyname() */ @@ -435,6 +439,13 @@ int main(argc, argv) printf("%s\n", result->h_aliases[i]); } +#if LIBRESOLV_DNS_TTL_HACK + /* DNS TTL handling - bne@CareNet.hu + * for first try it's a dirty hack, by hacking getanswer + * to place th e ttl in a global variable */ + printf("$ttl %d\n", _dns_ttl_); +#endif + printf("$end\n"); fflush(stdout); continue; diff --git a/src/ipcache.cc b/src/ipcache.cc index b894c7f2c6..8438a74595 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,5 +1,5 @@ /* - * $Id: ipcache.cc,v 1.44 1996/08/27 05:19:09 wessels Exp $ + * $Id: ipcache.cc,v 1.45 1996/08/27 20:10:52 wessels Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -723,6 +723,16 @@ static int ipcache_parsebuffer(buf, offset, dnsData) k++; } } + /* DNS TTL - bne@CareNet.hu */ + /* next line is either a $ttl ttl\n or a $end\n */ + if (strstr(line_cur->line, "$ttl")) { + tmp_ptr = line_cur->line; + /* skip the first token */ + token = strtok(tmp_ptr, w_space); + tmp_ptr = NULL; + token = strtok(tmp_ptr, w_space); + i->expires = squid_curtime + atoi(token); + } ipcache_call_pending(i); debug(14, 10, "ipcache_parsebuffer: $name succeeded.\n"); }