]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Excellent DNS TTL hack from Balint Nagy Endre <bne@CareNet.hu>
authorwessels <>
Wed, 28 Aug 1996 02:10:46 +0000 (02:10 +0000)
committerwessels <>
Wed, 28 Aug 1996 02:10:46 +0000 (02:10 +0000)
configure
configure.in
include/autoconf.h.in
src/dnsserver.cc
src/ipcache.cc

index fb2d5f00b121d2e8fe007a1e23921c0376bbc061..b442acd92461b352a695bea12c80439e2ecd5087 100755 (executable)
--- 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 <<EOF
+#line 2474 "configure"
+#include "confdefs.h"
+extern int _dns_ttl_;
+int main() { return 0; }
+int t() {
+return _dns_ttl_;
+; return 0; }
+EOF
+if eval $ac_link; then
+  rm -rf conftest*
+  echo "$ac_t""yes" 1>&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
index cf2dd64cae1b9c046dc24b2c0ac0ff0380bef9dc..cf1809c31ff28f6bec388a9347cbfc84e14fab09 100644 (file)
@@ -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
index d29838a581b85a6b411ae3b20a9105281ba5ae41..d89cf714b9c544d123894d415bc62451c7facb53 100644 (file)
@@ -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
 
index f82cffaaa55d37db8bce1c8145f26fe11a15cd5f..905f7a0b82e824b826e2904192a75a791954d970 100644 (file)
@@ -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
 
 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;
index b894c7f2c6a0e78300a809328c2d9fa55a673b17..8438a74595bb6d21f31cce69f584d5ee05970bda 100644 (file)
@@ -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");
                }