]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/dns.cc
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
);
59 dnsRegisterWithCacheManager(void)
61 CacheManager::GetInstance()->
62 registerAction("dns", "Dnsserver Statistics", dnsStats
, 0, 1);
70 dnsRegisterWithCacheManager();
72 if (!Config
.Program
.dnsserver
)
75 if (dnsservers
== NULL
)
76 dnsservers
= helperCreate("dnsserver");
78 dnsservers
->n_to_start
= Config
.dnsChildren
;
80 dnsservers
->ipc_type
= IPC_STREAM
;
82 assert(dnsservers
->cmdline
== NULL
);
84 wordlistAdd(&dnsservers
->cmdline
, Config
.Program
.dnsserver
);
86 if (Config
.onoff
.res_defnames
)
87 wordlistAdd(&dnsservers
->cmdline
, "-D");
89 for (w
= Config
.dns_nameservers
; w
!= NULL
; w
= w
->next
) {
90 wordlistAdd(&dnsservers
->cmdline
, "-s");
91 wordlistAdd(&dnsservers
->cmdline
, w
->key
);
94 helperOpenServers(dnsservers
);
103 helperShutdown(dnsservers
);
105 wordlistDestroy(&dnsservers
->cmdline
);
110 helperFree(dnsservers
);
116 dnsSubmit(const char *lookup
, HLPCB
* callback
, void *data
)
119 static time_t first_warn
= 0;
120 snprintf(buf
, 256, "%s\n", lookup
);
122 if (dnsservers
->stats
.queue_size
>= dnsservers
->n_running
* 2) {
124 first_warn
= squid_curtime
;
126 if (squid_curtime
- first_warn
> 3 * 60)
127 fatal("DNS servers not responding for 3 minutes");
129 debugs(34, 1, "dnsSubmit: queue overload, rejecting " << lookup
);
131 callback(data
, (char *)"$fail Temporary network problem, please retry later");
137 helperSubmit(dnsservers
, buf
, callback
, data
);
142 * The function to return the DNS via SNMP
145 snmp_netDnsFn(variable_list
* Var
, snint
* ErrP
)
147 variable_list
*Answer
= NULL
;
148 debugs(49, 5, "snmp_netDnsFn: Processing request: " << Var
->name
[LEN_SQ_NET
+ 1]);
149 snmpDebugOid(5, Var
->name
, Var
->name_length
);
150 *ErrP
= SNMP_ERR_NOERROR
;
152 switch (Var
->name
[LEN_SQ_NET
+ 1]) {
155 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
156 dnsservers
->stats
.requests
,
161 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
162 dnsservers
->stats
.replies
,
167 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
168 dnsservers
->n_running
,
173 *ErrP
= SNMP_ERR_NOSUCHNAME
;
180 #endif /*SQUID_SNMP */
181 #endif /* USE_DNSSERVERS */