1 Index: squid/src/cf.data.pre
2 diff -c squid/src/cf.data.pre:1.245.2.54 squid/src/cf.data.pre:1.245.2.55
3 *** squid/src/cf.data.pre:1.245.2.54 Sat Nov 29 11:52:58 2003
4 --- squid/src/cf.data.pre Sat Dec 6 10:19:36 2003
11 LOC: Config.Timeout.idns_query
12 IFDEF: !USE_DNSSERVERS
19 LOC: Config.Timeout.idns_query
20 IFDEF: !USE_DNSSERVERS
26 Upper limit on how long Squid will cache positive DNS responses.
27 ! Default is 6 hours (360 minutes). If you want to minimize the
28 ! use of Squid's ipcache, set this to 1, not 0.
35 Upper limit on how long Squid will cache positive DNS responses.
36 ! Default is 6 hours (360 minutes). This directive must be set
37 ! larger than negative_dns_ttl.
45 LOC: Config.negativeDnsTtl
48 Time-to-Live (TTL) for negative caching of failed DNS lookups.
51 NAME: range_offset_limit
55 LOC: Config.negativeDnsTtl
58 Time-to-Live (TTL) for negative caching of failed DNS lookups.
59 + This also makes sets the lower cache limit on positive lookups.
60 + Minimum value is 1 second, and it is not recommendable to go
61 + much below 10 seconds.
64 NAME: range_offset_limit
67 -----------------------------------------------------------------------------
73 LOC: Config.Timeout.connect
76 ! Some systems (notably Linux) can not be relied upon to properly
77 ! time out connect(2) requests. Therefore the Squid process
78 ! enforces its own timeout on server connections. This parameter
79 ! specifies how long to wait for the connect to complete. The
80 ! default is two minutes (120 seconds).
83 NAME: peer_connect_timeout
85 -----------------------------------------------------------------------------
88 + NAME: forward_timeout
91 + LOC: Config.Timeout.forward
94 + This parameter specifies how long Squid should at most attempt in
95 + finding a forwarding path for the request before giving up.
101 LOC: Config.Timeout.connect
104 ! This parameter specifies how long to wait for the TCP connect to
105 ! the requested server or peer to complete before Squid should
106 ! attempt to find another path where to forward the request.
109 NAME: peer_connect_timeout
110 Index: squid/src/cache_cf.c
111 diff -c squid/src/cache_cf.c:1.396.2.15 squid/src/cache_cf.c:1.396.2.16
112 *** squid/src/cache_cf.c:1.396.2.15 Thu Nov 6 09:50:37 2003
113 --- squid/src/cache_cf.c Sat Dec 6 10:19:36 2003
117 debug(22, 0) ("WARNING: 'maxconn' ACL (%s) won't work with client_db disabled\n", a->name);
120 + if (Config.negativeDnsTtl <= 0) {
121 + debug(22, 0) ("WARNING: resetting negative_dns_ttl to 1 second\n");
122 + Config.negativeDnsTtl = 1;
124 + if (Config.positiveDnsTtl < Config.negativeDnsTtl) {
125 + debug(22, 0) ("NOTICE: positive_dns_ttl must be larger than negative_dns_ttl. Resetting negative_dns_ttl to match\n");
126 + Config.positiveDnsTtl = Config.negativeDnsTtl;
130 /* Parse a time specification from the config file. Store the
131 Index: squid/src/dns.c
132 diff -c squid/src/dns.c:1.86.2.1 squid/src/dns.c:1.86.2.2
133 *** squid/src/dns.c:1.86.2.1 Tue Nov 12 00:12:22 2002
134 --- squid/src/dns.c Sat Dec 6 10:19:37 2003
137 if (squid_curtime - first_warn > 3 * 60)
138 fatal("DNS servers not responding for 3 minutes");
139 debug(34, 1) ("dnsSubmit: queue overload, rejecting %s\n", lookup);
140 ! callback(data, "$fail Temporary network problem, please retry later");
145 if (squid_curtime - first_warn > 3 * 60)
146 fatal("DNS servers not responding for 3 minutes");
147 debug(34, 1) ("dnsSubmit: queue overload, rejecting %s\n", lookup);
148 ! callback(data, (char *) "$fail Temporary network problem, please retry later");
154 snmp_netDnsFn(variable_list * Var, snint * ErrP)
156 variable_list *Answer = NULL;
157 ! debug(49, 5) ("snmp_netDnsFn: Processing request:\n", Var->name[LEN_SQ_NET + 1]);
158 snmpDebugOid(5, Var->name, Var->name_length);
159 *ErrP = SNMP_ERR_NOERROR;
160 switch (Var->name[LEN_SQ_NET + 1]) {
162 snmp_netDnsFn(variable_list * Var, snint * ErrP)
164 variable_list *Answer = NULL;
165 ! debug(49, 5) ("snmp_netDnsFn: Processing request: %d\n", Var->name[LEN_SQ_NET + 1]);
166 snmpDebugOid(5, Var->name, Var->name_length);
167 *ErrP = SNMP_ERR_NOERROR;
168 switch (Var->name[LEN_SQ_NET + 1]) {
169 Index: squid/src/dns_internal.c
170 diff -c squid/src/dns_internal.c:1.45.2.1 squid/src/dns_internal.c:1.45.2.2
171 *** squid/src/dns_internal.c:1.45.2.1 Tue Jun 25 05:44:35 2002
172 --- squid/src/dns_internal.c Sat Dec 6 10:19:37 2003
187 dlinkDelete(&q->lru, &lru_list);
188 idnsRcodeCount(n, q->attempt);
190 debug(78, 3) ("idnsGrokReply: error %d\n", rfc1035_errno);
191 ! if (-2 == n && ++q->attempt < MAX_ATTEMPT) {
193 * RCODE 2 is "Server failure - The name server was
194 * unable to process this query due to a problem with
197 dlinkDelete(&q->lru, &lru_list);
198 idnsRcodeCount(n, q->attempt);
201 debug(78, 3) ("idnsGrokReply: error %d\n", rfc1035_errno);
202 ! q->error = rfc1035_error_message;
204 ! if (q->rcode == 2 && ++q->attempt < MAX_ATTEMPT) {
206 * RCODE 2 is "Server failure - The name server was
207 * unable to process this query due to a problem with
210 valid = cbdataValid(q->callback_data);
211 cbdataUnlock(q->callback_data);
213 ! q->callback(q->callback_data, answers, n);
214 rfc1035RRDestroy(answers, n);
215 memFree(q, MEM_IDNS_QUERY);
218 valid = cbdataValid(q->callback_data);
219 cbdataUnlock(q->callback_data);
221 ! q->callback(q->callback_data, answers, n, q->error);
222 rfc1035RRDestroy(answers, n);
223 memFree(q, MEM_IDNS_QUERY);
227 /* name servers went away; reconfiguring or shutting down */
230 ! if (tvSubDsec(q->sent_t, current_time) < Config.Timeout.idns_retransmit * (1 << q->nsends % nns))
232 debug(78, 3) ("idnsCheckQueue: ID %#04x timeout\n",
235 /* name servers went away; reconfiguring or shutting down */
238 ! if (tvSubDsec(q->sent_t, current_time) < Config.Timeout.idns_retransmit * 1 << ((q->nsends - 1) / nns))
240 debug(78, 3) ("idnsCheckQueue: ID %#04x timeout\n",
244 (int) q->id, q->nsends,
245 tvSubDsec(q->start_t, current_time));
246 cbdataUnlock(q->callback_data);
248 ! q->callback(q->callback_data, NULL, 0);
249 memFree(q, MEM_IDNS_QUERY);
253 (int) q->id, q->nsends,
254 tvSubDsec(q->start_t, current_time));
255 cbdataUnlock(q->callback_data);
258 ! q->callback(q->callback_data, NULL, -q->rcode, q->error);
260 ! q->callback(q->callback_data, NULL, -16, "Timeout");
262 memFree(q, MEM_IDNS_QUERY);
267 q->id = rfc1035BuildAQuery(name, q->buf, &q->sz);
269 /* problem with query data -- query not sent */
270 ! callback(data, NULL, 0);
271 memFree(q, MEM_IDNS_QUERY);
275 q->id = rfc1035BuildAQuery(name, q->buf, &q->sz);
277 /* problem with query data -- query not sent */
278 ! callback(data, NULL, 0, "Internal error");
279 memFree(q, MEM_IDNS_QUERY);
282 Index: squid/src/forward.c
283 diff -c squid/src/forward.c:1.82.2.5 squid/src/forward.c:1.82.2.6
284 *** squid/src/forward.c:1.82.2.5 Sat Nov 29 11:53:00 2003
285 --- squid/src/forward.c Sat Dec 6 10:19:37 2003
289 if (fwdState->origin_tries > 2)
291 ! if (squid_curtime - fwdState->start > Config.Timeout.connect)
293 if (fwdState->flags.dont_retry)
297 if (fwdState->origin_tries > 2)
299 ! if (squid_curtime - fwdState->start > Config.Timeout.forward)
301 if (fwdState->flags.dont_retry)
305 FwdServer *fs = fwdState->servers;
309 struct in_addr outgoing;
313 FwdServer *fs = fwdState->servers;
317 ! int ftimeout = Config.Timeout.forward - (squid_curtime - fwdState->start);
318 struct in_addr outgoing;
324 port = fwdState->request->port;
325 ctimeout = Config.Timeout.connect;
329 + if (ftimeout < ctimeout)
330 + ctimeout = ftimeout;
331 if (fwdCheckRetriable(fwdState)) {
332 if ((fd = pconnPop(host, port)) >= 0) {
333 debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd);
334 Index: squid/src/fqdncache.c
335 diff -c squid/src/fqdncache.c:1.149.2.3 squid/src/fqdncache.c:1.149.2.4
336 *** squid/src/fqdncache.c:1.149.2.3 Thu Dec 4 03:10:12 2003
337 --- squid/src/fqdncache.c Sat Dec 6 10:19:37 2003
342 static HLPCB fqdncacheHandleReply;
343 ! static fqdncache_entry *fqdncacheParse(const char *buf);
345 static IDNSCB fqdncacheHandleReply;
346 ! static fqdncache_entry *fqdncacheParse(rfc1035_rr *, int);
348 static void fqdncacheRelease(fqdncache_entry *);
349 static fqdncache_entry *fqdncacheCreateEntry(const char *name);
353 static HLPCB fqdncacheHandleReply;
354 ! static fqdncache_entry *fqdncacheParse(fqdncache_entry *, const char *buf);
356 static IDNSCB fqdncacheHandleReply;
357 ! static fqdncache_entry *fqdncacheParse(fqdncache_entry *, rfc1035_rr *, int, const char *error_message);
359 static void fqdncacheRelease(fqdncache_entry *);
360 static fqdncache_entry *fqdncacheCreateEntry(const char *name);
364 fqdncacheAddEntry(fqdncache_entry * f)
366 ! hash_link *e = hash_lookup(fqdn_table, f->hash.key);
368 ! /* avoid colission */
369 ! fqdncache_entry *q = (fqdncache_entry *) e;
370 ! fqdncacheRelease(q);
372 hash_join(fqdn_table, &f->hash);
373 dlinkAdd(f, &f->lru, &lru_list);
376 fqdncacheAddEntry(fqdncache_entry * f)
378 ! fqdncache_entry *e = (fqdncache_entry *) hash_lookup(fqdn_table, f->hash.key);
380 ! /* avoid collision */
381 ! if (f->flags.negcached && !e->flags.negcached && e->expires > squid_curtime) {
382 ! /* Don't waste good information */
383 ! fqdncacheFreeEntry(f);
386 ! fqdncacheRelease(e);
388 hash_join(fqdn_table, &f->hash);
389 dlinkAdd(f, &f->lru, &lru_list);
393 static fqdncache_entry *
395 ! fqdncacheParse(const char *inbuf)
397 LOCAL_ARRAY(char, buf, DNS_INBUF_SZ);
399 - static fqdncache_entry f;
401 ! memset(&f, '\0', sizeof(f));
402 ! f.expires = squid_curtime;
403 ! f.flags.negcached = 1;
405 ! debug(35, 1) ("fqdncacheParse: Got <NULL> reply\n");
408 xstrncpy(buf, inbuf, DNS_INBUF_SZ);
409 debug(35, 5) ("fqdncacheParse: parsing: {%s}\n", buf);
410 token = strtok(buf, w_space);
412 ! debug(35, 1) ("fqdncacheParse: Got <NULL>, expecting '$name'\n");
415 if (0 == strcmp(token, "$fail")) {
416 - f.expires = squid_curtime + Config.negativeDnsTtl;
417 token = strtok(NULL, "\n");
418 assert(NULL != token);
419 ! f.error_message = xstrdup(token);
422 if (0 != strcmp(token, "$name")) {
423 ! debug(35, 1) ("fqdncacheParse: Got '%s', expecting '$name'\n", token);
426 token = strtok(NULL, w_space);
428 ! debug(35, 1) ("fqdncacheParse: Got <NULL>, expecting TTL\n");
431 ! f.flags.negcached = 0;
433 ! if (ttl > 0 && ttl < Config.positiveDnsTtl)
434 ! f.expires = squid_curtime + ttl;
436 ! f.expires = squid_curtime + Config.positiveDnsTtl;
437 token = strtok(NULL, w_space);
439 ! f.names[0] = xstrdup(token);
445 ! fqdncacheParse(rfc1035_rr * answers, int nr)
447 - static fqdncache_entry f;
450 ! memset(&f, '\0', sizeof(f));
451 ! f.expires = squid_curtime + Config.negativeDnsTtl;
452 ! f.flags.negcached = 1;
454 ! debug(35, 3) ("fqdncacheParse: Lookup failed (error %d)\n",
456 ! assert(rfc1035_error_message);
457 ! f.error_message = xstrdup(rfc1035_error_message);
461 ! debug(35, 3) ("fqdncacheParse: No DNS records\n");
462 ! f.error_message = xstrdup("No DNS records");
465 ! debug(35, 3) ("fqdncacheParse: %d answers\n", nr);
467 for (k = 0; k < nr; k++) {
468 if (answers[k].type != RFC1035_TYPE_PTR)
470 if (answers[k].class != RFC1035_CLASS_IN)
473 ! f.flags.negcached = 0;
474 ! f.names[0] = xstrndup(answers[k].rdata, answers[k].rdlength);
476 ! if (answers[k].ttl < Config.positiveDnsTtl)
477 ! f.expires = squid_curtime + answers[k].ttl;
479 ! f.expires = squid_curtime + Config.positiveDnsTtl;
482 ! debug(35, 1) ("fqdncacheParse: No PTR record\n");
483 ! f.error_message = xstrdup("No PTR record");
490 static fqdncache_entry *
492 ! fqdncacheParse(fqdncache_entry * f, const char *inbuf)
494 LOCAL_ARRAY(char, buf, DNS_INBUF_SZ);
497 ! const char *name = (const char *) f->hash.key;
498 ! f->expires = squid_curtime + Config.negativeDnsTtl;
499 ! f->flags.negcached = 1;
501 ! debug(35, 1) ("fqdncacheParse: Got <NULL> reply in response to '%s'\n", name);
502 ! f->error_message = xstrdup("Internal Error");
505 xstrncpy(buf, inbuf, DNS_INBUF_SZ);
506 debug(35, 5) ("fqdncacheParse: parsing: {%s}\n", buf);
507 token = strtok(buf, w_space);
509 ! debug(35, 1) ("fqdncacheParse: Got <NULL>, expecting '$name' in response to '%s'\n", name);
510 ! f->error_message = xstrdup("Internal Error");
513 if (0 == strcmp(token, "$fail")) {
514 token = strtok(NULL, "\n");
515 assert(NULL != token);
516 ! f->error_message = xstrdup(token);
519 if (0 != strcmp(token, "$name")) {
520 ! debug(35, 1) ("fqdncacheParse: Got '%s', expecting '$name' in response to '%s'\n", inbuf, name);
521 ! f->error_message = xstrdup("Internal Error");
524 token = strtok(NULL, w_space);
526 ! debug(35, 1) ("fqdncacheParse: Got '%s', expecting TTL in response to '%s'\n", inbuf, name);
527 ! f->error_message = xstrdup("Internal Error");
530 ! f->flags.negcached = 0;
532 ! if (ttl == 0 || ttl > Config.positiveDnsTtl)
533 ! ttl = Config.positiveDnsTtl;
534 ! if (ttl < Config.negativeDnsTtl)
535 ! ttl = Config.negativeDnsTtl;
536 ! f->expires = squid_curtime + ttl;
537 token = strtok(NULL, w_space);
539 ! f->names[0] = xstrdup(token);
545 ! fqdncacheParse(fqdncache_entry * f, rfc1035_rr * answers, int nr, const char *error_message)
549 ! const char *name = (const char *) f->hash.key;
550 ! f->expires = squid_curtime + Config.negativeDnsTtl;
551 ! f->flags.negcached = 1;
553 ! debug(35, 3) ("fqdncacheParse: Lookup of '%s' failed (%s)\n", name, error_message);
554 ! f->error_message = xstrdup(error_message);
558 ! debug(35, 3) ("fqdncacheParse: No DNS records for '%s'\n", name);
559 ! f->error_message = xstrdup("No DNS records");
562 ! debug(35, 3) ("fqdncacheParse: %d answers for '%s'\n", nr, name);
564 for (k = 0; k < nr; k++) {
565 if (answers[k].type != RFC1035_TYPE_PTR)
567 if (answers[k].class != RFC1035_CLASS_IN)
569 ! f->names[f->name_count++] = xstrndup(answers[k].rdata, answers[k].rdlength);
570 ! if (ttl == 0 || answers[k].ttl < ttl)
571 ! ttl = answers[k].ttl;
572 ! if (f->name_count >= FQDN_MAX_NAMES)
575 ! if (f->name_count == 0) {
576 ! debug(35, 1) ("fqdncacheParse: No PTR record\n");
577 ! f->error_message = xstrdup("No PTR record");
580 ! if (ttl == 0 || ttl > Config.positiveDnsTtl)
581 ! ttl = Config.positiveDnsTtl;
582 ! if (ttl < Config.negativeDnsTtl)
583 ! ttl = Config.negativeDnsTtl;
584 ! f->expires = squid_curtime + ttl;
585 ! f->flags.negcached = 0;
593 fqdncacheHandleReply(void *data, char *reply)
595 ! fqdncacheHandleReply(void *data, rfc1035_rr * answers, int na)
599 generic_cbdata *c = data;
600 fqdncache_entry *f = c->data;
601 - fqdncache_entry *x = NULL;
604 n = ++FqdncacheStats.replies;
605 statHistCount(&statCounter.dns.svc_time,
606 tvSubMsec(f->request_time, current_time));
608 ! x = fqdncacheParse(reply);
610 ! x = fqdncacheParse(answers, na);
613 - f->name_count = x->name_count;
614 - for (n = 0; n < (int) f->name_count; n++)
615 - f->names[n] = x->names[n];
616 - f->error_message = x->error_message;
617 - f->expires = x->expires;
618 - f->flags = x->flags;
619 fqdncacheAddEntry(f);
620 fqdncacheCallback(f);
624 fqdncacheHandleReply(void *data, char *reply)
626 ! fqdncacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_message)
630 generic_cbdata *c = data;
631 fqdncache_entry *f = c->data;
634 n = ++FqdncacheStats.replies;
635 statHistCount(&statCounter.dns.svc_time,
636 tvSubMsec(f->request_time, current_time));
638 ! fqdncacheParse(f, reply);
640 ! fqdncacheParse(f, answers, na, error_message);
642 fqdncacheAddEntry(f);
643 fqdncacheCallback(f);
645 Index: squid/src/ipcache.c
646 diff -c squid/src/ipcache.c:1.236.2.1 squid/src/ipcache.c:1.236.2.2
647 *** squid/src/ipcache.c:1.236.2.1 Fri Nov 28 12:14:32 2003
648 --- squid/src/ipcache.c Sat Dec 6 10:19:37 2003
651 static int ipcacheExpiredEntry(ipcache_entry *);
652 static int ipcache_testname(void);
654 ! static ipcache_entry *ipcacheParse(const char *buf);
656 ! static ipcache_entry *ipcacheParse(rfc1035_rr *, int);
658 static ipcache_entry *ipcache_get(const char *);
659 static void ipcacheLockEntry(ipcache_entry *);
661 static int ipcacheExpiredEntry(ipcache_entry *);
662 static int ipcache_testname(void);
664 ! static ipcache_entry *ipcacheParse(ipcache_entry *, const char *buf);
666 ! static ipcache_entry *ipcacheParse(ipcache_entry *, rfc1035_rr *, int, const char *error);
668 static ipcache_entry *ipcache_get(const char *);
669 static void ipcacheLockEntry(ipcache_entry *);
673 ipcacheAddEntry(ipcache_entry * i)
675 ! hash_link *e = hash_lookup(ip_table, i->hash.key);
677 ! /* avoid colission */
678 ! ipcache_entry *q = (ipcache_entry *) e;
681 hash_join(ip_table, &i->hash);
682 dlinkAdd(i, &i->lru, &lru_list);
685 ipcacheAddEntry(ipcache_entry * i)
687 ! ipcache_entry *e = (ipcache_entry *) hash_lookup(ip_table, i->hash.key);
689 ! /* avoid collision */
690 ! if (i->flags.negcached && !e->flags.negcached && e->expires > squid_curtime) {
691 ! /* Don't waste good information */
692 ! ipcacheFreeEntry(i);
697 hash_join(ip_table, &i->hash);
698 dlinkAdd(i, &i->lru, &lru_list);
701 ipcacheUnlockEntry(i);
704 - static ipcache_entry *
706 ! ipcacheParse(const char *inbuf)
708 LOCAL_ARRAY(char, buf, DNS_INBUF_SZ);
710 ! static ipcache_entry i;
716 ! memset(&i, '\0', sizeof(i));
717 ! i.expires = squid_curtime;
718 ! i.flags.negcached = 1;
720 debug(14, 1) ("ipcacheParse: Got <NULL> reply\n");
721 ! i.error_message = xstrdup("Internal Squid Error");
724 xstrncpy(buf, inbuf, DNS_INBUF_SZ);
725 debug(14, 5) ("ipcacheParse: parsing: {%s}\n", buf);
726 token = strtok(buf, w_space);
728 ! debug(14, 1) ("ipcacheParse: Got <NULL>, expecting '$addr'\n");
731 if (0 == strcmp(token, "$fail")) {
732 - i.expires = squid_curtime + Config.negativeDnsTtl;
733 token = strtok(NULL, "\n");
734 assert(NULL != token);
735 ! i.error_message = xstrdup(token);
738 if (0 != strcmp(token, "$addr")) {
739 ! debug(14, 1) ("ipcacheParse: Got '%s', expecting '$addr'\n", token);
742 token = strtok(NULL, w_space);
744 ! debug(14, 1) ("ipcacheParse: Got <NULL>, expecting TTL\n");
747 ! i.flags.negcached = 0;
749 - if (ttl > 0 && ttl < Config.positiveDnsTtl)
750 - i.expires = squid_curtime + ttl;
752 - i.expires = squid_curtime + Config.positiveDnsTtl;
753 while (NULL != (token = strtok(NULL, w_space))) {
754 xstrncpy(A[ipcount], token, 16);
758 ! if (0 == ipcount) {
759 ! i.addrs.in_addrs = NULL;
760 ! i.addrs.bad_mask = NULL;
762 ! i.addrs.in_addrs = xcalloc(ipcount, sizeof(struct in_addr));
763 ! i.addrs.bad_mask = xcalloc(ipcount, sizeof(unsigned char));
765 ! for (j = 0, k = 0; k < ipcount; k++) {
766 ! if (safe_inet_addr(A[k], &i.addrs.in_addrs[j]))
769 ! debug(14, 1) ("ipcacheParse: Invalid IP address '%s'\n", A[k]);
771 ! i.addrs.count = (unsigned char) j;
775 ! ipcacheParse(rfc1035_rr * answers, int nr)
777 - static ipcache_entry i;
781 ! memset(&i, '\0', sizeof(i));
782 ! i.expires = squid_curtime + Config.negativeDnsTtl;
783 ! i.flags.negcached = 1;
785 ! debug(14, 3) ("ipcacheParse: Lookup failed (error %d)\n",
787 ! assert(rfc1035_error_message);
788 ! i.error_message = xstrdup(rfc1035_error_message);
792 ! debug(14, 3) ("ipcacheParse: No DNS records\n");
793 ! i.error_message = xstrdup("No DNS records");
797 for (j = 0, k = 0; k < nr; k++) {
799 ipcacheUnlockEntry(i);
803 ! static ipcache_entry *
804 ! ipcacheParse(ipcache_entry * i, const char *inbuf)
806 LOCAL_ARRAY(char, buf, DNS_INBUF_SZ);
813 ! const char *name = (const char *) i->hash.key;
814 ! i->expires = squid_curtime + Config.negativeDnsTtl;
815 ! i->flags.negcached = 1;
816 ! safe_free(i->addrs.in_addrs);
817 ! safe_free(i->addrs.bad_mask);
818 ! safe_free(i->error_message);
819 ! i->addrs.count = 0;
821 debug(14, 1) ("ipcacheParse: Got <NULL> reply\n");
822 ! i->error_message = xstrdup("Internal Squid Error");
825 xstrncpy(buf, inbuf, DNS_INBUF_SZ);
826 debug(14, 5) ("ipcacheParse: parsing: {%s}\n", buf);
827 token = strtok(buf, w_space);
829 ! debug(14, 1) ("ipcacheParse: expecting result, got '%s'\n", inbuf);
830 ! i->error_message = xstrdup("Internal Squid Error");
833 if (0 == strcmp(token, "$fail")) {
834 token = strtok(NULL, "\n");
835 assert(NULL != token);
836 ! i->error_message = xstrdup(token);
839 if (0 != strcmp(token, "$addr")) {
840 ! debug(14, 1) ("ipcacheParse: expecting '$addr', got '%s' in response to '%s'\n", inbuf, name);
841 ! i->error_message = xstrdup("Internal Squid Error");
844 token = strtok(NULL, w_space);
846 ! debug(14, 1) ("ipcacheParse: expecting data, got '%s' in response to '%s'\n", inbuf, name);
847 ! i->error_message = xstrdup("Internal Squid Error");
850 ! i->flags.negcached = 0;
852 while (NULL != (token = strtok(NULL, w_space))) {
853 xstrncpy(A[ipcount], token, 16);
857 ! if (ipcount <= 0) {
858 ! debug(14, 1) ("ipcacheParse: No addresses in response to '%s'\n", name);
860 ! i->addrs.in_addrs = xcalloc(ipcount, sizeof(struct in_addr));
861 ! i->addrs.bad_mask = xcalloc(ipcount, sizeof(unsigned char));
862 ! for (j = 0, k = 0; k < ipcount; k++) {
863 ! if (safe_inet_addr(A[k], &i->addrs.in_addrs[j]))
866 ! debug(14, 1) ("ipcacheParse: Invalid IP address '%s' in response to '%s'\n", A[k], name);
869 ! i->addrs.count = (unsigned char) j;
870 ! if (ttl == 0 || ttl > Config.positiveDnsTtl)
871 ! ttl = Config.positiveDnsTtl;
872 ! if (ttl < Config.negativeDnsTtl)
873 ! ttl = Config.negativeDnsTtl;
874 ! i->expires = squid_curtime + ttl;
878 ! static ipcache_entry *
879 ! ipcacheParse(ipcache_entry * i, rfc1035_rr * answers, int nr, const char *error_message)
885 ! const char *name = (const char *) i->hash.key;
886 ! i->expires = squid_curtime + Config.negativeDnsTtl;
887 ! i->flags.negcached = 1;
888 ! safe_free(i->addrs.in_addrs);
889 ! safe_free(i->addrs.bad_mask);
890 ! safe_free(i->error_message);
891 ! i->addrs.count = 0;
893 ! debug(14, 3) ("ipcacheParse: Lookup failed '%s' for '%s'\n",
894 ! error_message, (const char *) i->hash.key);
895 ! i->error_message = xstrdup(error_message);
899 ! debug(14, 3) ("ipcacheParse: No DNS records in response to '%s'\n", name);
900 ! i->error_message = xstrdup("No DNS records");
904 for (j = 0, k = 0; k < nr; k++) {
910 ! debug(14, 1) ("ipcacheParse: No Address records\n");
911 ! i.error_message = xstrdup("No Address records");
914 ! i.flags.negcached = 0;
915 ! i.addrs.in_addrs = xcalloc(na, sizeof(struct in_addr));
916 ! i.addrs.bad_mask = xcalloc(na, sizeof(unsigned char));
917 ! i.addrs.count = (unsigned char) na;
918 for (j = 0, k = 0; k < nr; k++) {
919 if (answers[k].type != RFC1035_TYPE_A)
921 if (answers[k].class != RFC1035_CLASS_IN)
924 ! if (answers[k].ttl < Config.positiveDnsTtl)
925 ! i.expires = squid_curtime + answers[k].ttl;
927 ! i.expires = squid_curtime + Config.positiveDnsTtl;
929 assert(answers[k].rdlength == 4);
930 ! xmemcpy(&i.addrs.in_addrs[j++], answers[k].rdata, 4);
931 debug(14, 3) ("ipcacheParse: #%d %s\n",
933 ! inet_ntoa(i.addrs.in_addrs[j - 1]));
944 ! debug(14, 1) ("ipcacheParse: No Address records in response to '%s'\n", name);
945 ! i->error_message = xstrdup("No Address records");
948 ! i->flags.negcached = 0;
949 ! i->addrs.in_addrs = xcalloc(na, sizeof(struct in_addr));
950 ! i->addrs.bad_mask = xcalloc(na, sizeof(unsigned char));
951 for (j = 0, k = 0; k < nr; k++) {
952 if (answers[k].type != RFC1035_TYPE_A)
954 if (answers[k].class != RFC1035_CLASS_IN)
956 ! if (ttl == 0 || ttl > answers[k].ttl)
957 ! ttl = answers[k].ttl;
958 assert(answers[k].rdlength == 4);
959 ! xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4);
960 debug(14, 3) ("ipcacheParse: #%d %s\n",
962 ! inet_ntoa(i->addrs.in_addrs[j - 1]));
964 + i->addrs.count = (unsigned char) na;
965 + if (ttl == 0 || ttl > Config.positiveDnsTtl)
966 + ttl = Config.positiveDnsTtl;
967 + if (ttl < Config.negativeDnsTtl)
968 + ttl = Config.negativeDnsTtl;
969 + i->expires = squid_curtime + ttl;
978 ipcacheHandleReply(void *data, char *reply)
980 ! ipcacheHandleReply(void *data, rfc1035_rr * answers, int na)
983 generic_cbdata *c = data;
984 ipcache_entry *i = c->data;
985 - ipcache_entry *x = NULL;
988 IpcacheStats.replies++;
989 statHistCount(&statCounter.dns.svc_time,
990 tvSubMsec(i->request_time, current_time));
992 ! x = ipcacheParse(reply);
994 ! x = ipcacheParse(answers, na);
997 - i->addrs = x->addrs;
998 - i->error_message = x->error_message;
999 - i->expires = x->expires;
1000 - i->flags = x->flags;
1006 ipcacheHandleReply(void *data, char *reply)
1008 ! ipcacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_message)
1011 generic_cbdata *c = data;
1012 ipcache_entry *i = c->data;
1015 IpcacheStats.replies++;
1016 statHistCount(&statCounter.dns.svc_time,
1017 tvSubMsec(i->request_time, current_time));
1019 ! ipcacheParse(i, reply);
1021 ! ipcacheParse(i, answers, na, error_message);
1026 Index: squid/src/structs.h
1027 diff -c squid/src/structs.h:1.408.2.16 squid/src/structs.h:1.408.2.17
1028 *** squid/src/structs.h:1.408.2.16 Sat Nov 29 11:53:00 2003
1029 --- squid/src/structs.h Sat Dec 6 10:19:38 2003
1038 time_t peer_connect;
1040 Index: squid/src/typedefs.h
1041 diff -c squid/src/typedefs.h:1.132.2.2 squid/src/typedefs.h:1.132.2.3
1042 *** squid/src/typedefs.h:1.132.2.2 Sun May 11 11:30:13 2003
1043 --- squid/src/typedefs.h Sat Dec 6 10:19:38 2003
1046 typedef int HLPSAVAIL(void *);
1047 typedef void HLPSONEQ(void *);
1048 typedef void HLPCMDOPTS(int *argc, char **argv);
1049 ! typedef void IDNSCB(void *, rfc1035_rr *, int);
1051 typedef void STINIT(SwapDir *);
1052 typedef void STNEWFS(SwapDir *);
1054 typedef int HLPSAVAIL(void *);
1055 typedef void HLPSONEQ(void *);
1056 typedef void HLPCMDOPTS(int *argc, char **argv);
1057 ! typedef void IDNSCB(void *, rfc1035_rr *, int, const char *);
1059 typedef void STINIT(SwapDir *);
1060 typedef void STNEWFS(SwapDir *);