void idnsInit(void) { static int init = 0; if (DnsSocket < 0) { DnsSocket = comm_open(SOCK_DGRAM, 0, Config.Addrs.udp_outgoing, 0, COMM_NONBLOCKING, "DNS Socket"); if (DnsSocket < 0) fatal("Could not create a DNS socket"); debug(78, 1) ("DNS Socket created on FD %d\n", DnsSocket); } assert(0 == nns); idnsParseNameservers(); if (0 == nns) idnsParseResolvConf(); if (0 == nns) fatal("Could not find any nameservers.\n" " Please check your /etc/resolv.conf file\n" " or use the 'dns_nameservers' option in squid.conf."); if (!init) { memDataInit(MEM_IDNS_QUERY, "idns_query", sizeof(idns_query), 0); cachemgrRegister("idns", "Internal DNS Statistics", idnsStats, 0, 1); memset(RcodeMatrix, '\0', sizeof(RcodeMatrix)); init++; } }
void idnsInit(void) { static int init = 0; CBDATA_INIT_TYPE(idns_query); if (DnsSocket < 0) { int port; struct in_addr addr; if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr) addr = Config.Addrs.udp_outgoing; else addr = Config.Addrs.udp_incoming; DnsSocket = comm_open(SOCK_DGRAM, IPPROTO_UDP, addr, 0, COMM_NONBLOCKING, "DNS Socket"); if (DnsSocket < 0) fatal("Could not create a DNS socket"); /* Ouch... we can't call functions using debug from a debug * statement. Doing so messes up the internal _db_level */ port = comm_local_port(DnsSocket); debug(78, 1) ("DNS Socket created at %s, port %d, FD %d\n", inet_ntoa(addr), port, DnsSocket); } assert(0 == nns); idnsParseNameservers(); #ifndef _SQUID_MSWIN_ if (0 == nns) idnsParseResolvConf(); #endif #ifdef _SQUID_WIN32_ if (0 == nns) idnsParseWIN32Registry(); #endif if (0 == nns) { debug(78, 1) ("Warning: Could not find any nameservers. Trying to use localhost\n"); #ifdef _SQUID_WIN32_ debug(78, 1) ("Please check your TCP-IP settings or /etc/resolv.conf file\n"); #else debug(78, 1) ("Please check your /etc/resolv.conf file\n"); #endif debug(78, 1) ("or use the 'dns_nameservers' option in squid.conf.\n"); idnsAddNameserver("127.0.0.1"); } if (!init) { memDataInit(MEM_IDNS_QUERY, "idns_query", sizeof(idns_query), 0); cachemgrRegister("idns", "Internal DNS Statistics", idnsStats, 0, 1); memset(RcodeMatrix, '\0', sizeof(RcodeMatrix)); idns_lookup_hash = hash_create((HASHCMP *) strcmp, 103, hash_string); init++; } }