/*
- * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "base/RunnersRegistry.h"
#include "cache_cf.h"
#include "CachePeer.h"
+#include "CachePeers.h"
#include "ConfigOption.h"
#include "ConfigParser.h"
#include "CpuAffinityMap.h"
char* file = strwordtok(files, &saveptr);
while (file != NULL) {
error_count += parseOneConfigFile(file, depth);
- file = strwordtok(NULL, &saveptr);
+ file = strwordtok(nullptr, &saveptr);
}
#endif /* HAVE_GLOB */
return error_count;
int err_count = 0;
int is_pipe = 0;
- debugs(3, DBG_IMPORTANT, "Processing Configuration File: " << file_name << " (depth " << depth << ")");
+ debugs(3, Important(68), "Processing Configuration File: " << file_name << " (depth " << depth << ")");
if (depth > 16) {
fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name);
return 1;
if (Config.max_filedescriptors > 0) {
debugs(0, DBG_IMPORTANT, "WARNING: max_filedescriptors disabled. Operating System setrlimit(RLIMIT_NOFILE) is missing.");
}
-#elif USE_SELECT || USE_SELECT_WIN32
+#elif USE_SELECT
if (Config.max_filedescriptors > FD_SETSIZE) {
debugs(0, DBG_IMPORTANT, "WARNING: max_filedescriptors limited to " << FD_SETSIZE << " by select() algorithm.");
}
#endif
if (Security::ProxyOutgoingConfig.encryptTransport) {
- debugs(3, DBG_IMPORTANT, "Initializing https:// proxy context");
+ debugs(3, 2, "initializing https:// proxy context");
Config.ssl_client.sslContext = Security::ProxyOutgoingConfig.createClientContext(false);
if (!Config.ssl_client.sslContext) {
#if USE_OPENSSL
#endif
}
- for (CachePeer *p = Config.peers; p != nullptr; p = p->next) {
+ for (const auto &p: CurrentCachePeers()) {
// default value for ssldomain= is the peer host/IP
if (p->secure.sslDomain.isEmpty())
p->secure.sslDomain = p->host;
if (p->secure.encryptTransport) {
- debugs(3, DBG_IMPORTANT, "Initializing TLS context for cache_peer " << *p);
+ debugs(3, 2, "initializing TLS context for cache_peer " << *p);
p->sslContext = p->secure.createClientContext(true);
if (!p->sslContext) {
debugs(3, DBG_CRITICAL, "ERROR: Could not initialize TLS context for cache_peer " << *p);
for (AnyP::PortCfgPointer s = HttpPortList; s != nullptr; s = s->next) {
if (!s->secure.encryptTransport)
continue;
- debugs(3, DBG_IMPORTANT, "Initializing " << AnyP::UriScheme(s->transport.protocol) << "_port " << s->s << " TLS contexts");
+ debugs(3, 2, "initializing " << AnyP::UriScheme(s->transport.protocol) << "_port " << s->s << " TLS contexts");
s->secure.initServerContexts(*s);
}
}
static void
-dump_peer(StoreEntry * entry, const char *name, CachePeer * p)
+dump_peer(StoreEntry * entry, const char *name, const CachePeers *peers)
{
+ if (!peers)
+ return;
+
NeighborTypeDomainList *t;
LOCAL_ARRAY(char, xname, 128);
- while (p != nullptr) {
+ for (const auto &peer: *peers) {
+ const auto p = peer.get();
storeAppendPrintf(entry, "%s %s %s %d %d name=%s",
name,
p->host,
peer_type_str(t->type),
t->domain);
}
-
- p = p->next;
}
}
}
static void
-parse_peer(CachePeer ** head)
+parse_peer(CachePeers **peers)
{
char *host_str = ConfigParser::NextToken();
if (!host_str) {
#if USE_CACHE_DIGESTS
if (!p->options.no_digest)
- peerDigestCreate(p);
+ p->digest = new PeerDigest(p);
#endif
if (p->secure.encryptTransport)
p->secure.parseOptions();
- p->index = ++Config.npeers;
+ if (!*peers)
+ *peers = new CachePeers;
- while (*head != nullptr)
- head = &(*head)->next;
+ (*peers)->add(p);
- *head = p;
+ p->index = (*peers)->size();
peerClearRRStart();
}
static void
-free_peer(CachePeer ** P)
+free_peer(CachePeers ** const peers)
{
- delete *P;
- *P = nullptr;
- Config.npeers = 0;
+ delete *peers;
+ *peers = nullptr;
}
static void
storeAppendPrintf(e, " ssl-bump");
#endif
- s->secure.dumpCfg(e, "tls-");
+ PackableStream os(*e);
+ s->secure.dumpCfg(os, "tls-");
}
static void
public:
static Ssl::BumpMode lastDeprecatedRule;
/* RegisteredRunner API */
- virtual void finalizeConfig();
+ void finalizeConfig() override;
};
Ssl::BumpMode sslBumpCfgRr::lastDeprecatedRule = Ssl::bumpEnd;
-RunnerRegistrationEntry(sslBumpCfgRr);
+DefineRunnerRegistrator(sslBumpCfgRr);
void
sslBumpCfgRr::finalizeConfig()