]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/dns.cc
3 * $Id: dns.cc,v 1.100 2007/04/28 22:26:37 hno Exp $
5 * DEBUG: section 34 Dnsserver interface
6 * AUTHOR: Harvest Derived
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
39 #include "SquidTime.h"
40 #include "CacheManager.h"
43 /* MS VisualStudio Projects are monolitich, so we need the following
44 #if to include the external DNS code in compile process when
49 static helper
*dnsservers
= NULL
;
52 dnsStats(StoreEntry
* sentry
)
54 storeAppendPrintf(sentry
, "Dnsserver Statistics:\n");
55 helperStats(sentry
, dnsservers
);
63 if (!Config
.Program
.dnsserver
)
66 if (dnsservers
== NULL
)
67 dnsservers
= helperCreate("dnsserver");
69 dnsservers
->n_to_start
= Config
.dnsChildren
;
71 dnsservers
->ipc_type
= IPC_STREAM
;
73 assert(dnsservers
->cmdline
== NULL
);
75 wordlistAdd(&dnsservers
->cmdline
, Config
.Program
.dnsserver
);
77 if (Config
.onoff
.res_defnames
)
78 wordlistAdd(&dnsservers
->cmdline
, "-D");
80 for (w
= Config
.dns_nameservers
; w
!= NULL
; w
= w
->next
) {
81 wordlistAdd(&dnsservers
->cmdline
, "-s");
82 wordlistAdd(&dnsservers
->cmdline
, w
->key
);
85 helperOpenServers(dnsservers
);
89 dnsRegisterWithCacheManager(CacheManager
& manager
)
91 manager
.registerAction("dns",
92 "Dnsserver Statistics",
102 helperShutdown(dnsservers
);
104 wordlistDestroy(&dnsservers
->cmdline
);
109 helperFree(dnsservers
);
115 dnsSubmit(const char *lookup
, HLPCB
* callback
, void *data
)
118 static time_t first_warn
= 0;
119 snprintf(buf
, 256, "%s\n", lookup
);
121 if (dnsservers
->stats
.queue_size
>= dnsservers
->n_running
* 2) {
123 first_warn
= squid_curtime
;
125 if (squid_curtime
- first_warn
> 3 * 60)
126 fatal("DNS servers not responding for 3 minutes");
128 debugs(34, 1, "dnsSubmit: queue overload, rejecting " << lookup
);
130 callback(data
, (char *)"$fail Temporary network problem, please retry later");
136 helperSubmit(dnsservers
, buf
, callback
, data
);
141 * The function to return the DNS via SNMP
144 snmp_netDnsFn(variable_list
* Var
, snint
* ErrP
)
146 variable_list
*Answer
= NULL
;
147 debugs(49, 5, "snmp_netDnsFn: Processing request: " << Var
->name
[LEN_SQ_NET
+ 1]);
148 snmpDebugOid(5, Var
->name
, Var
->name_length
);
149 *ErrP
= SNMP_ERR_NOERROR
;
151 switch (Var
->name
[LEN_SQ_NET
+ 1]) {
154 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
155 dnsservers
->stats
.requests
,
160 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
161 dnsservers
->stats
.replies
,
166 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
167 dnsservers
->n_running
,
172 *ErrP
= SNMP_ERR_NOSUCHNAME
;
179 #endif /*SQUID_SNMP */
180 #endif /* USE_DNSSERVERS */