--------------------- PatchSet 5308 Date: 2002/10/09 00:41:22 Author: rbcollins Branch: rbcollins_cxxtest Tag: (none) Log: dnsserver specifiics Members: src/Makefile.am:1.29.2.16->1.29.2.17 src/dns.c:1.7->1.7.20.1(DEAD) src/dns.cc:1.1->1.1.2.1 src/dnsserver.cc:1.1.2.1->1.1.2.2 src/icp_v3.c:1.5.10.1->1.5.10.2(DEAD) src/ipcache.cc:1.1.2.1->1.1.2.2 Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.29.2.16 retrieving revision 1.29.2.17 diff -u -r1.29.2.16 -r1.29.2.17 --- squid/src/Makefile.am 9 Oct 2002 00:23:15 -0000 1.29.2.16 +++ squid/src/Makefile.am 9 Oct 2002 00:41:22 -0000 1.29.2.17 @@ -7,7 +7,7 @@ # if USE_DNSSERVER -DNSSOURCE = dns.c +DNSSOURCE = dns.cc DNSSERVER = dnsserver else DNSSOURCE = dns_internal.c @@ -103,7 +103,7 @@ EXTRA_squid_SOURCES = \ delay_pools.c \ - dns.c \ + dns.cc \ dnsserver.cc \ dns_internal.c \ htcp.cc \ --- squid/src/dns.c Wed Feb 14 01:07:37 2007 +++ /dev/null Wed Feb 14 01:07:22 2007 @@ -1,140 +0,0 @@ - -/* - * $Id: dns.c,v 1.7 2002/04/06 11:34:50 squidadm Exp $ - * - * DEBUG: section 34 Dnsserver interface - * AUTHOR: Harvest Derived - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - */ - -#include "squid.h" - -static helper *dnsservers = NULL; - -static void -dnsStats(StoreEntry * sentry) -{ - storeAppendPrintf(sentry, "Dnsserver Statistics:\n"); - helperStats(sentry, dnsservers); -} - -void -dnsInit(void) -{ - static int init = 0; - wordlist *w; - if (!Config.Program.dnsserver) - return; - if (dnsservers == NULL) - dnsservers = helperCreate("dnsserver"); - dnsservers->n_to_start = Config.dnsChildren; - dnsservers->ipc_type = IPC_STREAM; - assert(dnsservers->cmdline == NULL); - wordlistAdd(&dnsservers->cmdline, Config.Program.dnsserver); - if (Config.onoff.res_defnames) - wordlistAdd(&dnsservers->cmdline, "-D"); - for (w = Config.dns_nameservers; w != NULL; w = w->next) { - wordlistAdd(&dnsservers->cmdline, "-s"); - wordlistAdd(&dnsservers->cmdline, w->key); - } - helperOpenServers(dnsservers); - if (!init) { - cachemgrRegister("dns", - "Dnsserver Statistics", - dnsStats, 0, 1); - init = 1; - } -} - -void -dnsShutdown(void) -{ - if (!dnsservers) - return; - helperShutdown(dnsservers); - wordlistDestroy(&dnsservers->cmdline); - if (!shutting_down) - return; - helperFree(dnsservers); - dnsservers = NULL; -} - -void -dnsSubmit(const char *lookup, HLPCB * callback, void *data) -{ - char buf[256]; - static time_t first_warn = 0; - snprintf(buf, 256, "%s\n", lookup); - if (dnsservers->stats.queue_size >= dnsservers->n_running * 2) { - if (first_warn == 0) - first_warn = squid_curtime; - if (squid_curtime - first_warn > 3 * 60) - fatal("DNS servers not responding for 3 minutes"); - debug(34, 1) ("dnsSubmit: queue overload, rejecting %s\n", lookup); - callback(data, "$fail temporary network problem, pleas retry later"); - return; - } - first_warn = 0; - helperSubmit(dnsservers, buf, callback, data); -} - -#ifdef SQUID_SNMP -/* - * The function to return the DNS via SNMP - */ -variable_list * -snmp_netDnsFn(variable_list * Var, snint * ErrP) -{ - variable_list *Answer = NULL; - debug(49, 5) ("snmp_netDnsFn: Processing request:\n", Var->name[LEN_SQ_NET + 1]); - snmpDebugOid(5, Var->name, Var->name_length); - *ErrP = SNMP_ERR_NOERROR; - switch (Var->name[LEN_SQ_NET + 1]) { - case DNS_REQ: - Answer = snmp_var_new_integer(Var->name, Var->name_length, - dnsservers->stats.requests, - SMI_COUNTER32); - break; - case DNS_REP: - Answer = snmp_var_new_integer(Var->name, Var->name_length, - dnsservers->stats.replies, - SMI_COUNTER32); - break; - case DNS_SERVERS: - Answer = snmp_var_new_integer(Var->name, Var->name_length, - dnsservers->n_running, - SMI_COUNTER32); - break; - default: - *ErrP = SNMP_ERR_NOSUCHNAME; - break; - } - return Answer; -} -#endif /*SQUID_SNMP */ --- /dev/null Wed Feb 14 01:07:22 2007 +++ squid/src/dns.cc Wed Feb 14 01:07:37 2007 @@ -0,0 +1,141 @@ + +/* + * $Id: dns.cc,v 1.1.2.1 2002/10/09 00:41:22 rbcollins Exp $ + * + * DEBUG: section 34 Dnsserver interface + * AUTHOR: Harvest Derived + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" +#include "Store.h" + +static helper *dnsservers = NULL; + +static void +dnsStats(StoreEntry * sentry) +{ + storeAppendPrintf(sentry, "Dnsserver Statistics:\n"); + helperStats(sentry, dnsservers); +} + +void +dnsInit(void) +{ + static int init = 0; + wordlist *w; + if (!Config.Program.dnsserver) + return; + if (dnsservers == NULL) + dnsservers = helperCreate("dnsserver"); + dnsservers->n_to_start = Config.dnsChildren; + dnsservers->ipc_type = IPC_STREAM; + assert(dnsservers->cmdline == NULL); + wordlistAdd(&dnsservers->cmdline, Config.Program.dnsserver); + if (Config.onoff.res_defnames) + wordlistAdd(&dnsservers->cmdline, "-D"); + for (w = Config.dns_nameservers; w != NULL; w = w->next) { + wordlistAdd(&dnsservers->cmdline, "-s"); + wordlistAdd(&dnsservers->cmdline, w->key); + } + helperOpenServers(dnsservers); + if (!init) { + cachemgrRegister("dns", + "Dnsserver Statistics", + dnsStats, 0, 1); + init = 1; + } +} + +void +dnsShutdown(void) +{ + if (!dnsservers) + return; + helperShutdown(dnsservers); + wordlistDestroy(&dnsservers->cmdline); + if (!shutting_down) + return; + helperFree(dnsservers); + dnsservers = NULL; +} + +void +dnsSubmit(const char *lookup, HLPCB * callback, void *data) +{ + char buf[256]; + static time_t first_warn = 0; + snprintf(buf, 256, "%s\n", lookup); + if (dnsservers->stats.queue_size >= dnsservers->n_running * 2) { + if (first_warn == 0) + first_warn = squid_curtime; + if (squid_curtime - first_warn > 3 * 60) + fatal("DNS servers not responding for 3 minutes"); + debug(34, 1) ("dnsSubmit: queue overload, rejecting %s\n", lookup); + callback(data, "$fail temporary network problem, pleas retry later"); + return; + } + first_warn = 0; + helperSubmit(dnsservers, buf, callback, data); +} + +#ifdef SQUID_SNMP +/* + * The function to return the DNS via SNMP + */ +variable_list * +snmp_netDnsFn(variable_list * Var, snint * ErrP) +{ + variable_list *Answer = NULL; + debug(49, 5) ("snmp_netDnsFn: Processing request:\n", Var->name[LEN_SQ_NET + 1]); + snmpDebugOid(5, Var->name, Var->name_length); + *ErrP = SNMP_ERR_NOERROR; + switch (Var->name[LEN_SQ_NET + 1]) { + case DNS_REQ: + Answer = snmp_var_new_integer(Var->name, Var->name_length, + dnsservers->stats.requests, + SMI_COUNTER32); + break; + case DNS_REP: + Answer = snmp_var_new_integer(Var->name, Var->name_length, + dnsservers->stats.replies, + SMI_COUNTER32); + break; + case DNS_SERVERS: + Answer = snmp_var_new_integer(Var->name, Var->name_length, + dnsservers->n_running, + SMI_COUNTER32); + break; + default: + *ErrP = SNMP_ERR_NOSUCHNAME; + break; + } + return Answer; +} +#endif /*SQUID_SNMP */ Index: squid/src/dnsserver.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/dnsserver.cc,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/dnsserver.cc 9 Oct 2002 00:23:16 -0000 1.1.2.1 +++ squid/src/dnsserver.cc 9 Oct 2002 00:41:22 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: dnsserver.cc,v 1.1.2.1 2002/10/09 00:23:16 rbcollins Exp $ + * $Id: dnsserver.cc,v 1.1.2.2 2002/10/09 00:41:22 rbcollins Exp $ * * DEBUG: section 0 DNS Resolver * AUTHOR: Harvest Derived @@ -262,8 +262,12 @@ char request[512]; char *t = NULL; int c; +#if HAVE_RES_INIT int opt_s = 0; +#if HAVE_RES_NSADDR_LIST || HAVE_RES_NS_LIST extern char *optarg; +#endif +#endif safe_inet_addr("255.255.255.255", &no_addr); --- squid/src/icp_v3.c Wed Feb 14 01:07:37 2007 +++ /dev/null Wed Feb 14 01:07:22 2007 @@ -1,158 +0,0 @@ - -/* - * $Id: icp_v3.c,v 1.5.10.1 2002/10/04 07:07:26 rbcollins Exp $ - * - * DEBUG: section 12 Internet Cache Protocol - * AUTHOR: Duane Wessels - * - * SQUID Web Proxy Cache http://www.squid-cache.org/ - * ---------------------------------------------------------- - * - * Squid is the result of efforts by numerous individuals from - * the Internet community; see the CONTRIBUTORS file for full - * details. Many organizations have provided support for Squid's - * development; see the SPONSORS file for full details. Squid is - * Copyrighted (C) 2001 by the Regents of the University of - * California; see the COPYRIGHT file for full details. Squid - * incorporates software developed and/or copyrighted by other - * sources; see the CREDITS file for full details. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. - * - */ - -#include "squid.h" -#include "Store.h" - -/* Currently Harvest cached-2.x uses ICP_VERSION_3 */ -void -icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) -{ - icp_common_t header; - icp_common_t *reply; - StoreEntry *entry = NULL; - char *url = NULL; - const cache_key *key; - request_t *icp_request = NULL; - int allow = 0; - aclCheck_t checklist; - xmemcpy(&header, buf, sizeof(icp_common_t)); - /* - * Only these fields need to be converted - */ - header.length = ntohs(header.length); - header.reqnum = ntohl(header.reqnum); - header.flags = ntohl(header.flags); - header.pad = ntohl(header.pad); - /* - * Length field should match the number of bytes read - */ - if (len != header.length) { - debug(12, 3) ("icpHandleIcpV3: ICP message is too small\n"); - return; - } - switch (header.opcode) { - case ICP_QUERY: - /* We have a valid packet */ - url = buf + sizeof(icp_common_t) + sizeof(u_int32_t); - if (strpbrk(url, w_space)) { - url = rfc1738_escape(url); - reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, 0); - break; - } - if ((icp_request = urlParse(METHOD_GET, url)) == NULL) { - reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, 0); - break; - } - memset(&checklist, '\0', sizeof(checklist)); - checklist.src_addr = from.sin_addr; - checklist.my_addr = no_addr; - checklist.request = icp_request; - allow = aclCheckFast(Config.accessList.icp, &checklist); - if (!allow) { - debug(12, 2) ("icpHandleIcpV3: Access Denied for %s by %s.\n", - inet_ntoa(from.sin_addr), AclMatchedName); - if (clientdbCutoffDenied(from.sin_addr)) { - /* - * count this DENIED query in the clientdb, even though - * we're not sending an ICP reply... - */ - clientdbUpdate(from.sin_addr, LOG_UDP_DENIED, PROTO_ICP, 0); - } else { - reply = icpCreateMessage(ICP_DENIED, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_DENIED, 0); - } - break; - } - /* The peer is allowed to use this cache */ - entry = storeGetPublic(url, METHOD_GET); - debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n", - icp_opcode_str[header.opcode]); - if (icpCheckUdpHit(entry, icp_request)) { - reply = icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0); - break; - } - /* if store is rebuilding, return a UDP_HIT, but not a MISS */ - if (opt_reload_hit_only && store_dirs_rebuilding) { - reply = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0); - } else if (hit_only_mode_until > squid_curtime) { - reply = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0); - } else { - reply = icpCreateMessage(ICP_MISS, 0, url, header.reqnum, 0); - icpUdpSend(fd, &from, reply, LOG_UDP_MISS, 0); - } - break; - - case ICP_HIT: -#if ALLOW_SOURCE_PING - case ICP_SECHO: -#endif - case ICP_DECHO: - case ICP_MISS: - case ICP_DENIED: - case ICP_MISS_NOFETCH: - if (neighbors_do_private_keys && header.reqnum == 0) { - debug(12, 0) ("icpHandleIcpV3: Neighbor %s returned reqnum = 0\n", - inet_ntoa(from.sin_addr)); - debug(12, 0) ("icpHandleIcpV3: Disabling use of private keys\n"); - neighbors_do_private_keys = 0; - } - url = buf + sizeof(icp_common_t); - debug(12, 3) ("icpHandleIcpV3: %s from %s for '%s'\n", - icp_opcode_str[header.opcode], - inet_ntoa(from.sin_addr), - url); - key = icpGetCacheKey(url, (int) header.reqnum); - /* call neighborsUdpAck even if ping_status != PING_WAITING */ - neighborsUdpAck(key, &header, &from); - break; - - case ICP_INVALID: - case ICP_ERR: - break; - - default: - debug(12, 0) ("icpHandleIcpV3: UNKNOWN OPCODE: %d from %s\n", - header.opcode, inet_ntoa(from.sin_addr)); - break; - } - if (icp_request) - requestDestroy(icp_request); -} Index: squid/src/ipcache.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/ipcache.cc,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/ipcache.cc 9 Oct 2002 00:23:16 -0000 1.1.2.1 +++ squid/src/ipcache.cc 9 Oct 2002 00:41:22 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.1.2.1 2002/10/09 00:23:16 rbcollins Exp $ + * $Id: ipcache.cc,v 1.1.2.2 2002/10/09 00:41:22 rbcollins Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -288,8 +288,8 @@ i.addrs.in_addrs = NULL; i.addrs.bad_mask = NULL; } else { - i.addrs.in_addrs = xcalloc(ipcount, sizeof(struct in_addr)); - i.addrs.bad_mask = xcalloc(ipcount, sizeof(unsigned char)); + i.addrs.in_addrs = (struct in_addr *)xcalloc(ipcount, sizeof(struct in_addr)); + i.addrs.bad_mask = (unsigned char *)xcalloc(ipcount, sizeof(unsigned char)); } for (j = 0, k = 0; k < ipcount; k++) { if (safe_inet_addr(A[k], &i.addrs.in_addrs[j]))