#include "StatCounters.h"
#include "Store.h"
#include "util.h"
-#include "wordlist.h"
#if SQUID_SNMP
#include "snmp_core.h"
}
/**
- \ingroup FQDNCacheAPI
- *
* Adds a "static" entry from /etc/hosts.
- \par
- * The worldist is to be managed by the caller,
- * including pointed-to strings
*
\param addr FQDN name to be added.
- \param hostnames ??
+ \param hostnames list of hostnames for the addr
*/
void
-fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames)
+fqdncacheAddEntryFromHosts(char *addr, SBufList &hostnames)
{
- fqdncache_entry *fce;
- int j = 0;
-
- if ((fce = fqdncache_get(addr))) {
+ fqdncache_entry *fce= fqdncache_get(addr);
+ if (fce) {
if (1 == fce->flags.fromhosts) {
fqdncacheUnlockEntry(fce);
} else if (fce->locks > 0) {
- debugs(35, DBG_IMPORTANT, "fqdncacheAddEntryFromHosts: can't add static entry for locked address '" << addr << "'");
+ debugs(35, DBG_IMPORTANT, "WARNING: can't add static entry for locked address '" << addr << "'");
return;
} else {
fqdncacheRelease(fce);
fce = new fqdncache_entry(addr);
- while (hostnames) {
- fce->names[j] = xstrdup(hostnames->key);
+ int j = 0;
+ for (auto &h : hostnames) {
+ fce->names[j] = xstrdup(h.c_str());
Tolower(fce->names[j]);
++j;
- hostnames = hostnames->next;
if (j >= FQDN_MAX_NAMES)
break;
#define SQUID_FQDNCACHE_H_
#include "ip/Address.h"
+#include "sbuf/forward.h"
class StoreEntry;
-class wordlist;
namespace Dns
{
class LookupDetails;
void fqdncacheFreeMemory(void);
void fqdncache_restart(void);
void fqdncache_purgelru(void *);
-void fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames);
+void fqdncacheAddEntryFromHosts(char *addr, SBufList &hostnames);
const char *fqdncache_gethostbyaddr(const Ip::Address &, int flags);
void fqdncache_nbgethostbyaddr(const Ip::Address &, FQDNH *, void *);
if (!fp) {
int xerrno = errno;
- debugs(1, DBG_IMPORTANT, "parseEtcHosts: " << Config.etcHostsPath << ": " << xstrerr(xerrno));
+ debugs(1, DBG_IMPORTANT, "parseEtcHosts: '" << Config.etcHostsPath << "' : " << xstrerr(xerrno));
return;
}
#endif
while (fgets(buf, 1024, fp)) { /* for each line */
- wordlist *hosts = NULL;
- char *addr;
if (buf[0] == '#') /* MS-windows likes to add comments */
continue;
lt = buf;
- addr = buf;
+ char *addr = buf;
debugs(1, 5, "etc_hosts: line is '" << buf << "'");
lt = nt + 1;
+ SBufList hosts;
+
while ((nt = strpbrk(lt, w_space))) {
char *host = NULL;
if (ipcacheAddEntryFromHosts(host, addr) != 0) {
/* invalid address, continuing is useless */
- wordlistDestroy(&hosts);
- hosts = NULL;
+ hosts.clear();
break;
}
- wordlistAdd(&hosts, host);
+ hosts.emplace_back(SBuf(host));
lt = nt + 1;
}
- if (hosts) {
+ if (!hosts.empty())
fqdncacheAddEntryFromHosts(addr, hosts);
- wordlistDestroy(&hosts);
- }
}
fclose (fp);
--enable-leakfinder \
--enable-follow-x-forwarded-for \
--enable-ident-lookups \
- --enable-default-hostsfile \
+ --enable-default-hostsfile=/etc/hosts \
--enable-auth \
--enable-basic-auth-helpers \
--enable-ntlm-auth-helpers \