/*
- * $Id: cache_cf.cc,v 1.63 1996/07/25 05:45:12 wessels Exp $
+ * $Id: cache_cf.cc,v 1.64 1996/07/25 07:10:27 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
#include "squid.h"
-static struct {
- struct {
- int maxSize;
- int highWaterMark;
- int lowWaterMark;
- } Mem , Swap;
- struct {
- int maxObjSize;
- int defaultTtl;
- } Gopher, Http, Ftp;
- struct {
- int maxObjSize;
- int defaultTtl;
- char *relayHost;
- u_short relayPort;
- } Wais;
- int negativeTtl;
- int negativeDnsTtl;
- int positiveDnsTtl;
- int readTimeout;
- int lifetimeDefault;
- int lifetimeShutdown;
- int connectTimeout;
- int ageMaxDefault;
- int cleanRate;
- int maxRequestSize;
- double hotVmFactor;
- struct {
- u_short http;
- u_short icp;
- } Port;
- struct {
- char *log;
- char *access;
- char *hierarchy;
- char *store;
- int rotateNumber;
- int log_fqdn;
- } Log;
- char *adminEmail;
- char *effectiveUser;
- char *effectiveGroup;
- struct {
- char *ftpget;
- char *ftpget_opts;
- char *dnsserver;
- char *redirect;
- } Program;
- int dnsChildren;
- int redirectChildren;
- int sourcePing;
- int quickAbort;
- int commonLogFormat;
- int identLookup;
- int neighborTimeout;
- int stallDelay;
- int singleParentBypass;
- struct {
- char *host;
- char *prefix;
- u_short port;
- int withProxy;
- } Accel;
- char *appendDomain;
- char *debugOptions;
- char *pidFilename;
- char *visibleHostname;
- char *ftpUser;
- struct {
- char *host;
- u_short port;
- char *file;
- int rate;
- } Announce;
- struct {
- struct in_addr tcp_incoming;
- struct in_addr tcp_outgoing;
- struct in_addr udp_incoming;
- struct in_addr udp_outgoing;
- struct in_addr client_netmask;
- } Addrs;
- int tcpRcvBufsz;
- wordlist *cache_dirs;
- wordlist *http_stoplist;
- wordlist *gopher_stoplist;
- wordlist *ftp_stoplist;
- wordlist *hierarchy_stoplist;
- wordlist *local_domain_list;
- wordlist *inside_firewall_list;
- wordlist *dns_testname_list;
-} Config;
+struct SquidConfig Config;
#define DefaultMemMaxSize (16 << 20) /* 16 MB */
#define DefaultMemHighWaterMark 90 /* 90% */
#define DefaultUdpOutgoingAddr INADDR_NONE
#define DefaultClientNetmask 0xFFFFFFFF;
-ip_acl *local_ip_list = NULL;
-ip_acl *firewall_ip_list = NULL;
-
-int zap_disk_store = 0; /* off, try to rebuild from disk */
int httpd_accel_mode = 0; /* for fast access */
-int emulate_httpd_log = DefaultCommonLogFormat; /* for fast access */
-int identLookup = DefaultIdentLookup; /* for fast access */
-time_t neighbor_timeout = DefaultNeighborTimeout; /* for fast access */
-int single_parent_bypass = 0;
-int DnsPositiveTtl = DefaultPositiveDnsTtl;
char *DefaultSwapDir = DEFAULT_SWAP_DIR;
char *DefaultConfigFile = DEFAULT_CONFIG_FILE;
char *ConfigFile = NULL; /* the whole thing */
}
static void parseIntegerValue(iptr)
- int *iptr;
+ int *iptr;
{
char *token;
int i;
parseWAISRelayLine();
else if (!strcmp(token, "local_ip"))
- parseIPLine(&local_ip_list);
+ parseIPLine(&Config.local_ip_list);
else if (!strcmp(token, "firewall_ip"))
- parseIPLine(&firewall_ip_list);
+ parseIPLine(&Config.firewall_ip_list);
/* Parse a local_domain line */
else if (!strcmp(token, "local_domain"))
}
/* Sanity checks */
- if (getClientLifetime() < getReadTimeout()) {
+ if (Config.lifetimeDefault < Config.readTimeout) {
printf("WARNING: client_lifetime (%d seconds) is less than read_timeout (%d seconds).\n",
- getClientLifetime(), getReadTimeout());
+ Config.lifetimeDefault, Config.readTimeout);
printf(" This may cause serious problems with your cache!!!\n");
printf(" Change your configuration file.\n");
fflush(stdout); /* print message */
}
- if (getCacheSwapMax() < (getCacheMemMax() >> 10)) {
- printf("WARNING: cache_swap (%d kbytes) is less than cache_mem (%d bytes).\n", getCacheSwapMax(), getCacheMemMax());
+ if (Config.Swap.maxSize < (Config.Mem.maxSize >> 10)) {
+ printf("WARNING: cache_swap (%d kbytes) is less than cache_mem (%d bytes).\n", Config.Swap.maxSize, Config.Mem.maxSize);
printf(" This will cause serious problems with your cache!!!\n");
printf(" Change your configuration file.\n");
- Config.Swap.maxSize = getCacheMemMax() >> 10;
- printf(" For this run, however, %s will use %d kbytes for cache_swap.\n", appname, getCacheSwapMax());
+ Config.Swap.maxSize = Config.Mem.maxSize >> 10;
+ printf(" For this run, however, %s will use %d kbytes for cache_swap.\n", appname, Config.Swap.maxSize);
fflush(stdout); /* print message */
}
- if (getCleanRate() > -1 && getCleanRate() < 60) {
+ if (Config.cleanRate > -1 && Config.cleanRate < 60) {
Config.cleanRate = (30 * 60);
printf("WARNING: clean_rate is less than one minute.\n");
printf(" This will cause serious problems with your cache!!!\n");
printf(" Change your configuration file.\n");
- printf(" For this run, however, %s will use %d minutes for clean_rate.\n", appname, (int) (getCleanRate() / 60));
+ printf(" For this run, however, %s will use %d minutes for clean_rate.\n", appname, (int) (Config.cleanRate / 60));
fflush(stdout); /* print message */
}
- if (getDnsChildren() < 1) {
+ if (Config.dnsChildren < 1) {
printf("WARNING: dns_children was set to a bad value: %d\n",
- getDnsChildren());
+ Config.dnsChildren);
Config.dnsChildren = DefaultDnsChildren;
printf("Setting it to the default (%d).\n", DefaultDnsChildren);
- } else if (getDnsChildren() > DefaultDnsChildrenMax) {
+ } else if (Config.dnsChildren > DefaultDnsChildrenMax) {
printf("WARNING: dns_children was set to a bad value: %d\n",
- getDnsChildren());
+ Config.dnsChildren);
printf("Setting it to the maximum (%d).\n", DefaultDnsChildrenMax);
Config.dnsChildren = DefaultDnsChildrenMax;
}
- if (getRedirectChildren() < 1) {
+ if (Config.redirectChildren < 1) {
printf("WARNING: redirect_children was set to a bad value: %d\n",
- getRedirectChildren());
+ Config.redirectChildren);
Config.redirectChildren = DefaultRedirectChildren;
printf("Setting it to the default (%d).\n", DefaultRedirectChildren);
- } else if (getRedirectChildren() > DefaultRedirectChildrenMax) {
+ } else if (Config.redirectChildren > DefaultRedirectChildrenMax) {
printf("WARNING: redirect_children was set to a bad value: %d\n",
- getRedirectChildren());
+ Config.redirectChildren);
printf("Setting it to the maximum (%d).\n", DefaultRedirectChildrenMax);
Config.redirectChildren = DefaultRedirectChildrenMax;
}
return 0;
}
-
-
-int getHttpMax()
-{
- return Config.Http.maxObjSize;
-}
-int getHttpTTL()
-{
- return Config.Http.defaultTtl;
-}
-int getGopherMax()
-{
- return Config.Gopher.maxObjSize;
-}
-int getGopherTTL()
-{
- return Config.Gopher.defaultTtl;
-}
-int getWAISMax()
-{
- return Config.Wais.maxObjSize;
-}
-char *getWaisRelayHost()
-{
- return Config.Wais.relayHost;
-}
-u_short getWaisRelayPort()
-{
- return Config.Wais.relayPort;
-}
-int getFtpMax()
-{
- return Config.Ftp.maxObjSize;
-}
-int getFtpTTL()
-{
- return Config.Ftp.defaultTtl;
-}
-int getNegativeTTL()
-{
- return Config.negativeTtl;
-}
-int getNegativeDNSTTL()
-{
- return Config.negativeDnsTtl;
-}
-int getCacheMemMax()
-{
- return Config.Mem.maxSize;
-}
-int getCacheMemHighWaterMark()
-{
- return Config.Mem.highWaterMark;
-}
-int getCacheMemLowWaterMark()
-{
- return Config.Mem.lowWaterMark;
-}
-double getCacheHotVmFactor()
-{
- return Config.hotVmFactor;
-}
-int getCacheSwapHighWaterMark()
-{
- return Config.Swap.highWaterMark;
-}
-int getCacheSwapLowWaterMark()
-{
- return Config.Swap.lowWaterMark;
-}
-int getCacheSwapMax()
-{
- return Config.Swap.maxSize;
-}
int setCacheSwapMax(size)
int size;
{
Config.Swap.maxSize = size;
return Config.Swap.maxSize;
}
-int getReadTimeout()
-{
- return Config.readTimeout;
-}
-int getClientLifetime()
-{
- return Config.lifetimeDefault;
-}
-int getShutdownLifetime()
-{
- return Config.lifetimeShutdown;
-}
-int getMaxRequestSize()
-{
- return Config.maxRequestSize;
-}
-int getConnectTimeout()
-{
- return Config.connectTimeout;
-}
-int getCleanRate()
-{
- return Config.cleanRate;
-}
-int getSourcePing()
-{
- return Config.sourcePing;
-}
-int getDnsChildren()
-{
- return Config.dnsChildren;
-}
-int getRedirectChildren()
-{
- return Config.redirectChildren;
-}
-int getQuickAbort()
-{
- return Config.quickAbort;
-}
-char *getAccelPrefix()
-{
- return Config.Accel.prefix;
-}
-u_short getAccelPort()
-{
- return Config.Accel.port;
-}
-int getAccelWithProxy()
-{
- return Config.Accel.withProxy;
-}
-char *getAccessLogFile()
-{
- return Config.Log.access;
-}
-char *getHierarchyLogFile()
-{
- return Config.Log.hierarchy;
-}
-char *getStoreLogFile()
-{
- return Config.Log.store;
-}
-int getLogfileRotateNumber()
-{
- return Config.Log.rotateNumber;
-}
-char *getCacheLogFile()
-{
- return Config.Log.log;
-}
-u_short getHttpPortNum()
-{
- return Config.Port.http;
-}
-u_short getIcpPortNum()
-{
- return Config.Port.icp;
-}
-char *getDnsProgram()
-{
- return Config.Program.dnsserver;
-}
-char *getRedirectProgram()
-{
- return Config.Program.redirect;
-}
-char *getFtpProgram()
-{
- return Config.Program.ftpget;
-}
-char *getFtpOptions()
-{
- return Config.Program.ftpget_opts;
-}
-char *getAdminEmail()
-{
- return Config.adminEmail;
-}
-char *getDebugOptions()
-{
- return Config.debugOptions;
-}
-int getStallDelay()
-{
- return Config.stallDelay;
-}
-char *getAppendDomain()
-{
- return Config.appendDomain;
-}
-char *getEffectiveUser()
-{
- return Config.effectiveUser;
-}
-char *getEffectiveGroup()
-{
- return Config.effectiveGroup;
-}
-char *getPidFilename()
-{
- return Config.pidFilename;
-}
-char *getVisibleHostname()
-{
- return Config.visibleHostname;
-}
-char *getFtpUser()
-{
- return Config.ftpUser;
-}
-char *getAnnounceHost()
-{
- return Config.Announce.host;
-}
-u_short getAnnouncePort()
-{
- return Config.Announce.port;
-}
-char *getAnnounceFile()
-{
- return Config.Announce.file;
-}
-int getAnnounceRate()
-{
- return Config.Announce.rate;
-}
-wordlist *getHttpStoplist()
-{
- return Config.http_stoplist;
-}
-wordlist *getFtpStoplist()
-{
- return Config.ftp_stoplist;
-}
-wordlist *getHierarchyStoplist()
-{
- return Config.hierarchy_stoplist;
-}
-wordlist *getGopherStoplist()
-{
- return Config.gopher_stoplist;
-}
-wordlist *getLocalDomainList()
-{
- return Config.local_domain_list;
-}
-wordlist *getCacheDirs()
-{
- return Config.cache_dirs;
-}
-wordlist *getInsideFirewallList()
-{
- return Config.inside_firewall_list;
-}
-wordlist *getDnsTestnameList()
-{
- return Config.dns_testname_list;
-}
-int getTcpRcvBufsz()
-{
- return Config.tcpRcvBufsz;
-}
-struct in_addr getTcpIncomingAddr()
-{
- return Config.Addrs.tcp_incoming;
-}
-struct in_addr getTcpOutgoingAddr()
-{
- return Config.Addrs.tcp_outgoing;
-}
-struct in_addr getUdpIncomingAddr()
-{
- return Config.Addrs.udp_incoming;
-}
-struct in_addr getUdpOutgoingAddr()
-{
- return Config.Addrs.udp_outgoing;
-}
-struct in_addr getClientNetmask()
-{
- return Config.Addrs.client_netmask;
-}
-
u_short setHttpPortNum(port)
u_short port;
{
static void configDoConfigure()
{
httpd_accel_mode = Config.Accel.prefix ? 1 : 0;
- emulate_httpd_log = Config.commonLogFormat;
- neighbor_timeout = (time_t) Config.neighborTimeout;
- single_parent_bypass = Config.singleParentBypass;
- DnsPositiveTtl = Config.positiveDnsTtl;
sprintf(ForwardedBy, "Forwarded: by http://%s:%d/",
- getMyHostname(), getHttpPortNum());
- do_redirect = getRedirectProgram()? 1 : 0;
- opt_log_fqdn = Config.Log.log_fqdn;
-
+ getMyHostname(), Config.Port.http);
#if !ALLOW_HOT_CACHE
if (!httpd_accel_mode || Config.Accel.withProxy) {
+
/*
- * $Id: cachemgr.cc,v 1.12 1996/07/22 17:20:15 wessels Exp $
+ * $Id: cachemgr.cc,v 1.13 1996/07/25 07:10:29 wessels Exp $
*
* DEBUG: Section 0 CGI Cache Manager
* AUTHOR: Harvest Derived
}
ch = icpState->aclChecklist;
icpState->aclHandler = handler;
- if (httpd_accel_mode && !getAccelWithProxy() && r->protocol != PROTO_CACHEOBJ) {
+ if (httpd_accel_mode && !Config.Accel.withProxy && r->protocol != PROTO_CACHEOBJ) {
/* this cache is an httpd accelerator ONLY */
if (!BIT_TEST(icpState->flags, REQ_ACCEL))
answer = 0;
/*
- * $Id: comm.cc,v 1.46 1996/07/25 05:45:46 wessels Exp $
+ * $Id: comm.cc,v 1.47 1996/07/25 07:10:30 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
int new_socket;
FD_ENTRY *conn = NULL;
int sock_type = io_type & COMM_DGRAM ? SOCK_DGRAM : SOCK_STREAM;
- int tcp_rcv_bufsz = getTcpRcvBufsz();
+ int tcp_rcv_bufsz = Config.tcpRcvBufsz;
/* Create socket for accepting new connections. */
if ((new_socket = socket(AF_INET, sock_type, 0)) < 0) {
conn->remote_port = ntohs(address->sin_port);
/* set the lifetime for this client */
if (status == COMM_OK) {
- lft = comm_set_fd_lifetime(sock, getClientLifetime());
+ lft = comm_set_fd_lifetime(sock, Config.lifetimeDefault);
debug(5, 10, "comm_connect_addr: FD %d connected to %s:%d, lifetime %d.\n",
sock, conn->ipaddr, conn->remote_port, lft);
} else if (status == EINPROGRESS) {
- lft = comm_set_fd_lifetime(sock, getConnectTimeout());
+ lft = comm_set_fd_lifetime(sock, Config.connectTimeout);
debug(5, 10, "comm_connect_addr: FD %d connection pending, lifetime %d\n",
sock, lft);
}
{
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *) &size, sizeof(size)) < 0)
debug(5, 1, "commSetTcpRcvbuf: FD %d, SIZE %d: %s\n",
- fd, size, xstrerror());
+ fd, size, xstrerror());
}
/*
- * $Id: debug.cc,v 1.19 1996/07/18 20:27:00 wessels Exp $
+ * $Id: debug.cc,v 1.20 1996/07/25 07:10:30 wessels Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
return;
/* Rotate numbers 0 through N up one */
- for (i = getLogfileRotateNumber(); i > 1;) {
+ for (i = Config.Log.rotateNumber; i > 1;) {
i--;
sprintf(from, "%s.%d", debug_log_file, i - 1);
sprintf(to, "%s.%d", debug_log_file, i);
rename(from, to);
}
/* Rotate the current log to .0 */
- if (getLogfileRotateNumber() > 0) {
+ if (Config.Log.rotateNumber > 0) {
sprintf(to, "%s.%d", debug_log_file, 0);
rename(debug_log_file, to);
}
/* Close and reopen the log. It may have been renamed "manually"
* before HUP'ing us. */
if (debug_log != stderr)
- debugOpenLog(getCacheLogFile());
+ debugOpenLog(Config.Log.log);
}
/*
- * $Id: dns.cc,v 1.1 1996/07/22 16:40:22 wessels Exp $
+ * $Id: dns.cc,v 1.2 1996/07/25 07:10:31 wessels Exp $
*
* DEBUG: section 34 Dnsserver interface
* AUTHOR: Harvest Derived
void dnsOpenServers()
{
- int N = getDnsChildren();
- char *prg = getDnsProgram();
+ int N = Config.dnsChildren;
+ char *prg = Config.Program.dnsserver;
int k;
int dnssocket;
LOCAL_ARRAY(char, fd_note_buf, FD_ASCII_NOTE_SZ);
/*
- * $Id: dnsserver.cc,v 1.10 1996/07/25 05:49:14 wessels Exp $
+ * $Id: dnsserver.cc,v 1.11 1996/07/25 07:10:32 wessels Exp $
*
* DEBUG: section 0 DNS Resolver
* AUTHOR: Harvest Derived
* Squid creates UNIX domain sockets named dns.PID.NN, e.g. dns.19215.11
*
* In ipcache_init():
- * . dnssocket = ipcache_opensocket(getDnsProgram())
+ * . dnssocket = ipcache_opensocket(Config.Program.dnsserver)
* . dns_child_table[i]->inpipe = dnssocket
* . dns_child_table[i]->outpipe = dnssocket
*
#endif
addrbuf = inet_addr(request);
for (;;) {
- result = gethostbyaddr((char *)&addrbuf, 4, AF_INET);
+ result = gethostbyaddr((char *) &addrbuf, 4, AF_INET);
if (result || h_errno != TRY_AGAIN)
break;
if (++retry_count == 2)
/*
- * $Id: errorpage.cc,v 1.27 1996/07/19 17:34:08 wessels Exp $
+ * $Id: errorpage.cc,v 1.28 1996/07/25 07:10:32 wessels Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
\n",
code,
url,
- getAdminEmail(),
+ Config.adminEmail,
appname,
version_string,
getMyHostname());
request->login,
request->host,
request->urlpath,
- getAdminEmail(),
+ Config.adminEmail,
appname,
version_string,
getMyHostname());
mk_mime_hdr(tbuf,
- (time_t) getNegativeTTL(),
+ (time_t) Config.negativeTtl,
strlen(auth_msg),
0,
"text/html");
/*
- * $Id: fqdncache.cc,v 1.3 1996/07/25 05:49:15 wessels Exp $
+ * $Id: fqdncache.cc,v 1.4 1996/07/25 07:10:33 wessels Exp $
*
* DEBUG: section 34 FQDN Cache
* AUTHOR: Harvest Derived
}
f->lastref = f->timestamp = squid_curtime;
f->status = FQDN_CACHED;
- f->ttl = DnsPositiveTtl;
+ f->ttl = Config.positiveDnsTtl;
} else {
f->lastref = f->timestamp = squid_curtime;
f->status = FQDN_NEGATIVE_CACHED;
- f->ttl = getNegativeDNSTTL();
+ f->ttl = Config.negativeDnsTtl;
}
fqdncache_add_to_hash(f);
}
line_cur = line_head->next;
f = dnsData->data;
f->lastref = f->timestamp = squid_curtime;
- f->ttl = getNegativeDNSTTL();
+ f->ttl = Config.negativeDnsTtl;
f->status = FQDN_NEGATIVE_CACHED;
if (line_cur && !strncmp(line_cur->line, "$message", 8))
f->error_message = xstrdup(line_cur->line + 8);
debug(34, 0, "fqdncache_parsebuffer: DNS record already resolved.\n");
} else {
f->lastref = f->timestamp = squid_curtime;
- f->ttl = DnsPositiveTtl;
+ f->ttl = Config.positiveDnsTtl;
f->status = FQDN_CACHED;
line_cur = line_head->next;
/*
- * $Id: ftp.cc,v 1.47 1996/07/20 04:22:24 wessels Exp $
+ * $Id: ftp.cc,v 1.48 1996/07/25 07:10:34 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
if (!*user && !*password) {
strcpy(user, "anonymous");
- strcpy(password, getFtpUser());
+ strcpy(password, Config.ftpUser);
}
}
wordlist *p = NULL;
/* scan stop list */
- for (p = getFtpStoplist(); p; p = p->next) {
+ for (p = Config.ftp_stoplist; p; p = p->next) {
if (strstr(url, p->key))
return 0;
}
break;
default:
/* These can be negative cached, make key public */
- entry->expires = squid_curtime + getNegativeTTL();
+ entry->expires = squid_curtime + Config.negativeTtl;
if (BIT_TEST(entry->flag, CACHABLE))
storeSetPublicKey(entry);
break;
(void *) data);
/* NOTE there is no read timeout handler to disable */
/* dont try reading again for a while */
- comm_set_stall(fd, getStallDelay());
+ comm_set_stall(fd, Config.stallDelay);
return 0;
}
errno = 0;
* failed and arrange so the object gets ejected and
* never gets to disk. */
debug(9, 1, "ftpReadReply: Purging '%s'\n", entry->url);
- entry->expires = squid_curtime + getNegativeTTL();
+ entry->expires = squid_curtime + Config.negativeTtl;
BIT_RESET(entry->flag, CACHABLE);
storeReleaseRequest(entry);
} else if (!(entry->flag & DELETE_BEHIND)) {
/* update fdstat and fdtable */
storeComplete(entry);
comm_close(fd);
- } else if (((entry->mem_obj->e_current_len + len) > getFtpMax()) &&
+ } else if (((entry->mem_obj->e_current_len + len) > Config.Ftp.maxObjSize) &&
!(entry->flag & DELETE_BEHIND)) {
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
COMM_SELECT_TIMEOUT,
(PF) ftpLifetimeExpire,
(void *) data,
- getReadTimeout());
+ Config.readTimeout);
}
return 0;
}
comm_set_select_handler_plus_timeout(ftpState->ftp_fd,
COMM_SELECT_TIMEOUT,
(PF) ftpLifetimeExpire,
- (void *) ftpState, getReadTimeout());
+ (void *) ftpState, Config.readTimeout);
}
}
mode = ftpTransferMode(path);
/* Start building the buffer ... */
- strcat(buf, getFtpProgram());
+ strcat(buf, Config.Program.ftpget);
strcat(buf, space);
- strncpy(opts, getFtpOptions(), BUFSIZ);
+ strncpy(opts, Config.Program.ftpget_opts, BUFSIZ);
for (s = strtok(opts, w_space); s; s = strtok(NULL, w_space)) {
strcat(buf, s);
strcat(buf, space);
got_negttl = 1;
}
if (!got_timeout) {
- sprintf(tbuf, "-t %d ", getReadTimeout());
+ sprintf(tbuf, "-t %d ", Config.readTimeout);
strcat(buf, tbuf);
}
if (!got_negttl) {
- sprintf(tbuf, "-n %d ", getNegativeTTL());
+ sprintf(tbuf, "-n %d ", Config.negativeTtl);
strcat(buf, tbuf);
}
if (data->request->port) {
sprintf(tbuf, "-P %d ", data->request->port);
strcat(buf, tbuf);
}
- if ((s = getVisibleHostname())) {
+ if ((s = Config.visibleHostname)) {
sprintf(tbuf, "-H %s ", s);
strcat(buf, tbuf);
}
(PF) ftpSendRequest,
(void *) data);
comm_set_fd_lifetime(data->ftp_fd,
- getClientLifetime());
+ Config.lifetimeDefault);
comm_set_select_handler(data->ftp_fd,
COMM_SELECT_LIFETIME,
(PF) ftpLifetimeExpire,
int squid_to_ftpget[2];
int ftpget_to_squid[2];
LOCAL_ARRAY(char, pbuf, 128);
- char *ftpget = getFtpProgram();
+ char *ftpget = Config.Program.ftpget;
struct sockaddr_in S;
int len;
/*
- * $Id: gopher.cc,v 1.36 1996/07/25 05:47:33 wessels Exp $
+ * $Id: gopher.cc,v 1.37 1996/07/25 07:10:34 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
int cachable = 1;
/* scan stop list */
- for (p = getGopherStoplist(); p; p = p->next)
+ for (p = Config.gopher_stoplist; p; p = p->next)
if (strstr(url, p->key))
return 0;
(PF) NULL,
(void *) NULL,
(time_t) 0);
- comm_set_stall(fd, getStallDelay()); /* dont try reading again for a while */
+ comm_set_stall(fd, Config.stallDelay); /* dont try reading again for a while */
return 0;
}
} else {
comm_set_select_handler(fd, COMM_SELECT_READ,
(PF) gopherReadReply, (void *) data);
comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
- (PF) gopherReadReplyTimeout, (void *) data, getReadTimeout());
+ (PF) gopherReadReplyTimeout, (void *) data, Config.readTimeout);
} else {
BIT_RESET(entry->flag, CACHABLE);
storeReleaseRequest(entry);
BIT_RESET(entry->flag, DELAY_SENDING);
storeComplete(entry);
comm_close(fd);
- } else if (((entry->mem_obj->e_current_len + len) > getGopherMax()) &&
+ } else if (((entry->mem_obj->e_current_len + len) > Config.Gopher.maxObjSize) &&
!(entry->flag & DELETE_BEHIND)) {
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) data,
- getReadTimeout());
+ Config.readTimeout);
} else if (entry->flag & CLIENT_ABORT_REQUEST) {
/* append the last bit of info we got */
if (data->conversion != NORMAL) {
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) data,
- getReadTimeout());
+ Config.readTimeout);
}
put_free_4k_page(buf);
return 0;
COMM_SELECT_TIMEOUT,
(PF) gopherReadReplyTimeout,
(void *) gopherState,
- getReadTimeout());
+ Config.readTimeout);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
if (buf)
return COMM_ERROR;
}
/* Create socket. */
- sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url);
+ sock = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, url);
if (sock == COMM_ERROR) {
debug(10, 4, "gopherStart: Failed because we're out of sockets.\n");
squid_error_entry(entry, ERR_NO_FDS, xstrerror());
/*
- * $Id: http.cc,v 1.65 1996/07/20 04:22:25 wessels Exp $
+ * $Id: http.cc,v 1.66 1996/07/25 07:10:35 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
return 0;
/* scan stop list */
- for (p = getHttpStoplist(); p; p = p->next) {
+ for (p = Config.http_stoplist; p; p = p->next) {
if (strstr(url, p->key))
return 0;
}
static void httpCacheNegatively(entry)
StoreEntry *entry;
{
- entry->expires = squid_curtime + getNegativeTTL();
+ entry->expires = squid_curtime + Config.negativeTtl;
if (BIT_TEST(entry->flag, CACHABLE))
storeSetPublicKey(entry);
/* XXX: mark object "not to store on disk"? */
(time_t) 0);
comm_set_fd_lifetime(fd, 3600); /* limit during deferring */
/* dont try reading again for a while */
- comm_set_stall(fd, getStallDelay());
+ comm_set_stall(fd, Config.stallDelay);
return;
}
errno = 0;
comm_set_select_handler(fd, COMM_SELECT_READ,
(PF) httpReadReply, (void *) httpState);
comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
- (PF) httpReadReplyTimeout, (void *) httpState, getReadTimeout());
+ (PF) httpReadReplyTimeout, (void *) httpState, Config.readTimeout);
} else {
BIT_RESET(entry->flag, CACHABLE);
storeReleaseRequest(entry);
/* Connection closed; retrieval done. */
storeComplete(entry);
comm_close(fd);
- } else if ((entry->mem_obj->e_current_len + len) > getHttpMax() &&
+ } else if ((entry->mem_obj->e_current_len + len) > Config.Http.maxObjSize &&
!(entry->flag & DELETE_BEHIND)) {
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
comm_set_select_handler_plus_timeout(fd,
COMM_SELECT_TIMEOUT,
(PF) httpReadReplyTimeout,
- (void *) httpState, getReadTimeout());
+ (void *) httpState, Config.readTimeout);
} else if (entry->flag & CLIENT_ABORT_REQUEST) {
/* append the last bit of info we get */
storeAppend(entry, buf, len);
COMM_SELECT_TIMEOUT,
(PF) httpReadReplyTimeout,
(void *) httpState,
- getReadTimeout());
+ Config.readTimeout);
}
}
COMM_SELECT_TIMEOUT,
(PF) httpReadReplyTimeout,
(void *) httpState,
- getReadTimeout());
+ Config.readTimeout);
comm_set_fd_lifetime(fd, 86400); /* extend lifetime */
}
}
storeStartDeleteBehind(entry);
/* Create socket. */
- sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url);
+ sock = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, url);
if (sock == COMM_ERROR) {
debug(11, 4, "proxyhttpStart: Failed because we're out of sockets.\n");
squid_error_entry(entry, ERR_NO_FDS, xstrerror());
debug(11, 10, "httpStart: req_hdr '%s'\n", req_hdr);
/* Create socket. */
- sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url);
+ sock = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, url);
if (sock == COMM_ERROR) {
debug(11, 4, "httpStart: Failed because we're out of sockets.\n");
squid_error_entry(entry, ERR_NO_FDS, xstrerror());
/*
- * $Id: ident.cc,v 1.6 1996/07/20 03:16:52 wessels Exp $
+ * $Id: ident.cc,v 1.7 1996/07/25 07:10:36 wessels Exp $
*
* DEBUG: section 31 Ident (RFC 931)
* AUTHOR: Duane Wessels
port = ntohs(icpState->peer.sin_port);
if (sock < 0) {
- sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, "ident");
+ sock = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, "ident");
if (sock == COMM_ERROR)
return;
}
/*
- * $Id: ipcache.cc,v 1.37 1996/07/25 05:49:16 wessels Exp $
+ * $Id: ipcache.cc,v 1.38 1996/07/25 07:10:37 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
{
wordlist *w = NULL;
debug(14, 1, "Performing DNS Tests...\n");
- if ((w = getDnsTestnameList()) == NULL)
+ if ((w = Config.dns_testname_list) == NULL)
return 1;
for (; w; w = w->next) {
IpcacheStats.ghbn_calls++;
i->entry.h_name = xstrdup(hp->h_name);
i->lastref = i->timestamp = squid_curtime;
i->status = IP_CACHED;
- i->ttl = DnsPositiveTtl;
+ i->ttl = Config.positiveDnsTtl;
} else {
i->lastref = i->timestamp = squid_curtime;
i->status = IP_NEGATIVE_CACHED;
- i->ttl = getNegativeDNSTTL();
+ i->ttl = Config.negativeDnsTtl;
}
ipcache_add_to_hash(i);
}
line_cur = line_head->next;
i = dnsData->data;
i->lastref = i->timestamp = squid_curtime;
- i->ttl = getNegativeDNSTTL();
+ i->ttl = Config.negativeDnsTtl;
i->status = IP_NEGATIVE_CACHED;
if (line_cur && !strncmp(line_cur->line, "$message", 8))
i->error_message = xstrdup(line_cur->line + 8);
debug(14, 0, "ipcache_parsebuffer: DNS record already resolved.\n");
} else {
i->lastref = i->timestamp = squid_curtime;
- i->ttl = DnsPositiveTtl;
+ i->ttl = Config.positiveDnsTtl;
i->status = IP_CACHED;
line_cur = line_head->next;
/*
- * $Id: main.cc,v 1.54 1996/07/22 17:19:51 wessels Exp $
+ * $Id: main.cc,v 1.55 1996/07/25 07:10:38 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
int catch_signals = 1;
int opt_dns_tests = 1;
int opt_foreground_rebuild = 0;
+int opt_zap_disk_store = 0;
int vhost_mode = 0;
int unbuffered_logs = 1; /* debug and hierarhcy unbuffered by default */
int shutdown_pending = 0; /* set by SIGTERM handler (shut_down()) */
char appname[] = "squid";
char localhost[] = "127.0.0.1";
struct in_addr local_addr;
-int opt_log_fqdn = 1;
/* for error reporting from xmalloc and friends */
extern void (*failure_notify) _PARAMS((char *));
exit(0);
/* NOTREACHED */
case 'z':
- zap_disk_store = 1;
+ opt_zap_disk_store = 1;
break;
case '?':
default:
{
debug(21, 1, "reconfigure: SIGHUP received\n");
debug(21, 1, "Waiting %d seconds for active connections to finish\n",
- getShutdownLifetime());
+ Config.lifetimeShutdown);
reread_pending = 1;
#if !HAVE_SIGACTION
signal(sig, reconfigure);
debug(21, 1, "Preparing for shutdown after %d connections\n",
ntcpconn + nudpconn);
debug(21, 1, "Waiting %d seconds for active connections to finish\n",
- getShutdownLifetime());
+ Config.lifetimeShutdown);
shutdown_pending = 1;
}
/* Open server ports */
enter_suid();
theHttpConnection = comm_open(COMM_NONBLOCKING,
- getTcpIncomingAddr(),
- getHttpPortNum(),
+ Config.Addrs.tcp_incoming,
+ Config.Port.http,
"HTTP Port");
leave_suid();
if (theHttpConnection < 0) {
debug(1, 1, "Accepting HTTP connections on FD %d.\n",
theHttpConnection);
- if (!httpd_accel_mode || getAccelWithProxy()) {
- if ((port = getIcpPortNum()) > 0) {
+ if (!httpd_accel_mode || Config.Accel.withProxy) {
+ if ((port = Config.Port.icp) > 0) {
theInIcpConnection = comm_open(COMM_NONBLOCKING | COMM_DGRAM,
- getUdpIncomingAddr(),
+ Config.Addrs.udp_incoming,
port,
"ICP Port");
if (theInIcpConnection < 0)
debug(1, 1, "Accepting ICP connections on FD %d.\n",
theInIcpConnection);
- if ((addr = getUdpOutgoingAddr()).s_addr != INADDR_NONE) {
+ if ((addr = Config.Addrs.udp_outgoing).s_addr != INADDR_NONE) {
theOutIcpConnection = comm_open(COMM_NONBLOCKING | COMM_DGRAM,
addr,
port,
neighborsDestroy();
parseConfigFile(ConfigFile);
- _db_init(getCacheLogFile(), getDebugOptions());
+ _db_init(Config.Log.log, Config.debugOptions);
neighbors_init();
dnsOpenServers();
redirectOpenServers();
serverConnectionsOpen();
(void) ftpInitialize();
- if (theOutIcpConnection >= 0 && (!httpd_accel_mode || getAccelWithProxy()))
+ if (theOutIcpConnection >= 0 && (!httpd_accel_mode || Config.Accel.withProxy))
neighbors_open(theOutIcpConnection);
debug(1, 0, "Ready to serve requests.\n");
}
if (icpPortNumOverride != 1)
setIcpPortNum((u_short) icpPortNumOverride);
- _db_init(getCacheLogFile(), getDebugOptions());
+ _db_init(Config.Log.log, Config.debugOptions);
fdstat_open(fileno(debug_log), FD_LOG);
- fd_note(fileno(debug_log), getCacheLogFile());
+ fd_note(fileno(debug_log), Config.Log.log);
debug(1, 0, "Starting Squid Cache version %s for %s...\n",
version_string,
first_time = 0;
/* module initialization */
urlInitialize();
- stat_init(&CacheInfo, getAccessLogFile());
+ stat_init(&CacheInfo, Config.Log.access);
storeInit();
- if (getEffectiveUser()) {
+ if (Config.effectiveUser) {
/* we were probably started as root, so cd to a swap
* directory in case we dump core */
if (chdir(swappath(0)) < 0) {
do_mallinfo = 1;
}
serverConnectionsOpen();
- if (theOutIcpConnection >= 0 && (!httpd_accel_mode || getAccelWithProxy()))
+ if (theOutIcpConnection >= 0 && (!httpd_accel_mode || Config.Accel.withProxy))
neighbors_open(theOutIcpConnection);
squid_signal(SIGUSR1, rotate_logs, SA_RESTART);
mainInitialize();
/* main loop */
- if (getCleanRate() > 0)
- next_cleaning = time(NULL) + getCleanRate();
+ if (Config.cleanRate > 0)
+ next_cleaning = time(NULL) + Config.cleanRate;
for (;;) {
loop_delay = (time_t) 10;
/* maintain cache storage */
fatal_dump("Select Loop failed!");
break;
case COMM_TIMEOUT:
- if (getCleanRate() > 0 && squid_curtime >= next_cleaning) {
+ if (Config.cleanRate > 0 && squid_curtime >= next_cleaning) {
debug(1, 1, "Performing a garbage collection...\n");
n = storePurgeOld();
debug(1, 1, "Garbage collection done, %d objects removed\n", n);
- next_cleaning = squid_curtime + getCleanRate();
+ next_cleaning = squid_curtime + Config.cleanRate;
}
- if ((n = getAnnounceRate()) > 0) {
+ if ((n = Config.Announce.rate) > 0) {
if (squid_curtime > last_announce + n)
send_announce();
last_announce = squid_curtime;
/*
- * $Id: neighbors.cc,v 1.35 1996/07/25 05:46:38 wessels Exp $
+ * $Id: neighbors.cc,v 1.36 1996/07/25 07:10:38 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
if (mem && cache_host)
mem->hierarchy_host = xstrdup(cache_host);
- if (emulate_httpd_log) {
+ if (Config.commonLogFormat) {
if (squid_curtime != last_time) {
s = mkhttpdlogtime(&squid_curtime);
strcpy(time_str, s);
storeAppend(entry, data, data_sz);
storeComplete(entry);
hierarchy_log_append(entry,
- e->type==EDGE_PARENT ? HIER_PARENT_UDP_HIT_OBJ : HIER_SIBLING_UDP_HIT_OBJ,
+ e->type == EDGE_PARENT ? HIER_PARENT_UDP_HIT_OBJ : HIER_SIBLING_UDP_HIT_OBJ,
0,
e->host);
if (httpState->reply_hdr)
if (friends == NULL)
friends = xcalloc(1, sizeof(neighbors));
- if ((fname = getHierarchyLogFile()))
+ if ((fname = Config.Log.hierarchy))
neighborsOpenLog(fname);
for (t = Neighbor_cf; t; t = next) {
next = t->next;
- if (!strcmp(t->host, me) && t->http_port == getHttpPortNum()) {
+ if (!strcmp(t->host, me) && t->http_port == Config.Port.http) {
debug(15, 0, "neighbors_init: skipping cache_host %s %s %d %d\n",
t->type, t->host, t->http_port, t->icp_port);
continue;
LOCAL_ARRAY(char, from, MAXPATHLEN);
LOCAL_ARRAY(char, to, MAXPATHLEN);
- if ((fname = getHierarchyLogFile()) == NULL)
+ if ((fname = Config.Log.hierarchy) == NULL)
return;
debug(15, 1, "neighbors_rotate_log: Rotating.\n");
/* Rotate numbers 0 through N up one */
- for (i = getLogfileRotateNumber(); i > 1;) {
+ for (i = Config.Log.rotateNumber; i > 1;) {
i--;
sprintf(from, "%s.%d", fname, i - 1);
sprintf(to, "%s.%d", fname, i);
rename(from, to);
}
/* Rotate the current log to .0 */
- if (getLogfileRotateNumber() > 0) {
+ if (Config.Log.rotateNumber > 0) {
sprintf(to, "%s.%d", fname, 0);
rename(fname, to);
}
/*
- * $Id: redirect.cc,v 1.6 1996/07/20 03:16:54 wessels Exp $
+ * $Id: redirect.cc,v 1.7 1996/07/25 07:10:40 wessels Exp $
*
* DEBUG: section 29 Redirector
* AUTHOR: Duane Wessels
redirectStateData *redirectState;
};
-/* GLOBALS */
-int do_redirect = 0;
-
static redirector_t *GetFirstAvailable _PARAMS((void));
static int redirectCreateRedirector _PARAMS((char *command));
static int redirectHandleRead _PARAMS((int, redirector_t *));
redirector_t *redirector = NULL;
if (!handler)
fatal_dump("redirectStart: NULL handler");
- if (!do_redirect) {
+ if (Config.Program.redirect == NULL) {
(*handler) (data, NULL);
return;
}
void redirectOpenServers()
{
- char *prg = getRedirectProgram();
+ char *prg = Config.Program.redirect;
int k;
int redirectsocket;
LOCAL_ARRAY(char, fd_note_buf, FD_ASCII_NOTE_SZ);
static int first_time = 0;
- if (!do_redirect)
+ if (Config.Program.redirect == NULL)
return;
/* free old structures if present */
if (redirect_child_table) {
safe_free(redirect_child_table[k]);
safe_free(redirect_child_table);
}
- NRedirectors = NRedirectorsOpen = getRedirectChildren();
+ NRedirectors = NRedirectorsOpen = Config.redirectChildren;
redirect_child_table = xcalloc(NRedirectors, sizeof(redirector_t *));
debug(29, 1, "redirectOpenServers: Starting %d '%s' processes\n",
NRedirectors, prg);
{
redirector_t *redirect = NULL;
int k;
- if (!do_redirect)
+ if (Config.Program.redirect == NULL)
return;
for (k = 0; k < NRedirectors; k++) {
redirect = *(redirect_child_table + k);
struct redirectQueueData *rq = NULL;
int k;
int n = 0;
- if (!do_redirect)
+ if (Config.Program.redirect == NULL)
return 0;
debug(29, 3, "redirectUnregister: FD %d '%s'\n", fd, url);
for (k = 0; k < NRedirectors; k++) {
/*
- * $Id: send-announce.cc,v 1.15 1996/07/18 20:27:08 wessels Exp $
+ * $Id: send-announce.cc,v 1.16 1996/07/25 07:10:40 wessels Exp $
*
* DEBUG: section 27 Cache Announcer
* AUTHOR: Duane Wessels
int l;
int n;
- host = getAnnounceHost();
- port = getAnnouncePort();
+ host = Config.Announce.host;
+ port = Config.Announce.port;
if ((hp = ipcache_gethostbyname(host, IP_BLOCKING_LOOKUP)) == NULL) {
debug(27, 1, "send_announce: Unknown host '%s'\n", host);
strcat(sndbuf, tbuf);
sprintf(tbuf, "Running on %s %d %d\n",
getMyHostname(),
- getHttpPortNum(),
- getIcpPortNum());
+ Config.Port.http,
+ Config.Port.icp);
strcat(sndbuf, tbuf);
- if (getAdminEmail()) {
- sprintf(tbuf, "cache_admin: %s\n", getAdminEmail());
+ if (Config.adminEmail) {
+ sprintf(tbuf, "cache_admin: %s\n", Config.adminEmail);
strcat(sndbuf, tbuf);
}
sprintf(tbuf, "generated %d [%s]\n",
strcat(sndbuf, tbuf);
l = strlen(sndbuf);
- if ((file = getAnnounceFile())) {
+ if ((file = Config.Announce.file)) {
fd = file_open(file, NULL, O_RDONLY);
if (fd > -1 && (n = read(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) {
l += n;
/*
- * $Id: squid.h,v 1.33 1996/07/23 04:11:05 wessels Exp $
+ * $Id: squid.h,v 1.34 1996/07/25 07:10:41 wessels Exp $
*
* AUTHOR: Duane Wessels
*
extern int opt_reload_hit_only; /* main.c */
extern int opt_dns_tests; /* main.c */
extern int opt_foreground_rebuild; /* main.c */
-extern int opt_log_fqdn; /* main.c */
+extern int opt_zap_disk_store; /* main.c */
extern int vhost_mode; /* main.c */
extern char version_string[]; /* main.c */
extern char appname[]; /* main.c */
extern char localhost[];
extern struct in_addr any_addr; /* comm.c */
extern struct in_addr no_addr; /* comm.c */
-extern int do_redirect; /* redirect.c */
-
/* Prototypes and definitions which don't really deserve a seaprate
* include file */
/*
- * $Id: ssl.cc,v 1.8 1996/07/20 04:22:27 wessels Exp $
+ * $Id: ssl.cc,v 1.9 1996/07/25 07:10:41 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
RequestMethodStr[request->method], url);
/* Create socket. */
- sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url);
+ sock = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, url);
if (sock == COMM_ERROR) {
debug(26, 4, "sslStart: Failed because we're out of sockets.\n");
buf = squid_error_url(url,
sslState->url = xstrdup(url);
sslState->request = requestLink(request);
sslState->mime_hdr = mime_hdr;
- sslState->timeout = getReadTimeout();
+ sslState->timeout = Config.readTimeout;
sslState->size_ptr = size_ptr;
sslState->client.fd = fd;
sslState->server.fd = sock;
/*
- * $Id: stat.cc,v 1.47 1996/07/25 05:48:40 wessels Exp $
+ * $Id: stat.cc,v 1.48 1996/07/25 07:10:42 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
#include "squid.h"
-extern int emulate_httpd_log;
-
#define MAX_LINELEN (4096)
#define max(a,b) ((a)>(b)? (a): (b))
RESERVED_FD);
storeAppendPrintf(sentry, "{Stop List:}\n");
- if ((p = getHttpStoplist())) {
+ if ((p = Config.http_stoplist)) {
storeAppendPrintf(sentry, "{\tHTTP:}\n");
while (p) {
storeAppendPrintf(sentry, "{\t\t%s}\n", p->key);
p = p->next;
}
}
- if ((p = getGopherStoplist())) {
+ if ((p = Config.gopher_stoplist)) {
storeAppendPrintf(sentry, "{\tGOPHER:}\n");
while (p) {
storeAppendPrintf(sentry, "{\t\t%s}\n", p->key);
p = p->next;
}
}
- if ((p = getFtpStoplist())) {
+ if ((p = Config.ftp_stoplist)) {
storeAppendPrintf(sentry, "{\tFTP:}\n");
while (p) {
storeAppendPrintf(sentry, "{\t\t%s}\n", p->key);
storeAppendPrintf(sentry, open_bracket);
storeAppendPrintf(sentry,
"{VM-Max %d \"# Maximum hot-vm cache (MB)\"}\n",
- getCacheMemMax() / (1 << 20));
+ Config.Mem.maxSize / (1 << 20));
storeAppendPrintf(sentry,
"{VM-High %d \"# High water mark hot-vm cache (%%)\"}\n",
- getCacheMemHighWaterMark());
+ Config.Mem.highWaterMark);
storeAppendPrintf(sentry,
"{VM-Low %d \"# Low water-mark hot-vm cache (%%)\"}\n",
- getCacheMemLowWaterMark());
+ Config.Mem.lowWaterMark);
storeAppendPrintf(sentry,
"{Swap-Max %d \"# Maximum disk cache (MB)\"}\n",
- getCacheSwapMax() / (1 << 10));
+ Config.Swap.maxSize / (1 << 10));
storeAppendPrintf(sentry,
"{Swap-High %d \"# High Water mark disk cache (%%)\"}\n",
- getCacheSwapHighWaterMark());
+ Config.Swap.highWaterMark);
storeAppendPrintf(sentry,
"{Swap-Low %d \"# Low water mark disk cache (%%)\"}\n",
- getCacheSwapLowWaterMark());
+ Config.Swap.lowWaterMark);
storeAppendPrintf(sentry,
"{HTTP-Max %d\"# Maximum size HTTP objects (KB)\"}\n",
- getHttpMax() / (1 << 10));
+ Config.Http.maxObjSize / (1 << 10));
storeAppendPrintf(sentry,
"{HTTP-TTL %d \"# Http object default TTL (hrs)\"}\n",
- getHttpTTL() / 3600);
+ Config.Http.defaultTtl / 3600);
storeAppendPrintf(sentry,
"{Gopher-Max %d \"# Maximum size gopher objects (KB)\"}\n",
- getGopherMax() / (1 << 10));
+ Config.Gopher.maxObjSize / (1 << 10));
storeAppendPrintf(sentry,
"{Gopher-TTL %d \"# TTL for gopher objects (hrs)\"}\n",
- getGopherTTL() / 3600);
+ Config.Gopher.defaultTtl / 3600);
storeAppendPrintf(sentry,
"{FTP-Max %d \"# Maximum size FTP objects (KB)\"}\n",
- getFtpMax() / (1 << 10));
+ Config.Ftp.maxObjSize / (1 << 10));
storeAppendPrintf(sentry,
"{FTP-TTL %d \"# TTL for FTP objects (hrs)\"}\n",
- getFtpTTL() / 3600);
+ Config.Ftp.defaultTtl / 3600);
storeAppendPrintf(sentry,
"{Neg-TTL %d \"# TTL for negative cache (s)\"}\n",
- getNegativeTTL());
+ Config.negativeTtl);
storeAppendPrintf(sentry,
"{ReadTimeout %d \"# Maximum idle connection (s)\"}\n",
- getReadTimeout());
+ Config.readTimeout);
storeAppendPrintf(sentry,
"{ClientLifetime %d \"# Lifetime for incoming HTTP requests\"}\n",
- getClientLifetime());
+ Config.lifetimeDefault);
storeAppendPrintf(sentry,
"{CleanRate %d \"# Rate for periodic object expiring\"}\n",
- getCleanRate());
+ Config.cleanRate);
/* Cachemgr.cgi expects an integer in the second field of the string */
storeAppendPrintf(sentry,
"{HttpAccelMode %d \"# Is operating as an HTTP accelerator\"}\n",
static char *dash = "-";
char *client = NULL;
- if (opt_log_fqdn)
+ if (Config.Log.log_fqdn)
client = fqdncache_gethostbyaddr(caddr, 0);
if (client == NULL)
client = inet_ntoa(caddr);
neighbor = dash;
if (obj->logfile_status == LOG_ENABLE) {
- if (emulate_httpd_log)
+ if (Config.commonLogFormat)
sprintf(tmp, "%s %s - [%s] \"%s %s\" %s %d\n",
client,
ident,
debug(18, 1, "stat_rotate_log: Rotating\n");
/* Rotate numbers 0 through N up one */
- for (i = getLogfileRotateNumber(); i > 1;) {
+ for (i = Config.Log.rotateNumber; i > 1;) {
i--;
sprintf(from, "%s.%d", fname, i - 1);
sprintf(to, "%s.%d", fname, i);
rename(from, to);
}
/* Rotate the current log to .0 */
- if (getLogfileRotateNumber() > 0) {
+ if (Config.Log.rotateNumber > 0) {
sprintf(to, "%s.%d", fname, 0);
rename(fname, to);
}
/*
- * $Id: stmem.cc,v 1.15 1996/07/25 05:49:17 wessels Exp $
+ * $Id: stmem.cc,v 1.16 1996/07/25 07:10:43 wessels Exp $
*
* DEBUG: section 19 Memory Primitives
* AUTHOR: Harvest Derived
sm_stats.total_pages_allocated = 0;
sm_stats.n_pages_free = 0;
sm_stats.n_pages_in_use = 0;
- sm_stats.max_pages = (getCacheMemMax() / SM_PAGE_SIZE) >> 1;
+ sm_stats.max_pages = (Config.Mem.maxSize / SM_PAGE_SIZE) >> 1;
disk_stats.page_size = DISK_PAGE_SIZE;
disk_stats.total_pages_allocated = 0;
/*
- * $Id: store.cc,v 1.74 1996/07/25 05:49:18 wessels Exp $
+ * $Id: store.cc,v 1.75 1996/07/25 07:10:43 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
*/
static int storeHashDelete(e)
- StoreEntry *e;
+ StoreEntry *e;
{
hash_link *hptr = NULL;
if (e->mem_status == IN_MEMORY && e->key) {
if (flag == DISK_NO_SPACE_LEFT) {
/* reduce the swap_size limit to the current size. */
setCacheSwapMax(store_swap_size);
- store_swap_high = (long) (((float) getCacheSwapMax() *
- (float) getCacheSwapHighWaterMark()) / (float) 100);
- store_swap_low = (long) (((float) getCacheSwapMax() *
- (float) getCacheSwapLowWaterMark()) / (float) 100);
+ store_swap_high = (long) (((float) Config.Swap.maxSize *
+ (float) Config.Swap.highWaterMark) / (float) 100);
+ store_swap_low = (long) (((float) Config.Swap.maxSize *
+ (float) Config.Swap.lowWaterMark) / (float) 100);
}
return;
}
LOCAL_ARRAY(char, abort_msg, 2000);
debug(20, 6, "storeAbort: '%s'\n", e->key);
- e->expires = squid_curtime + getNegativeTTL();
+ e->expires = squid_curtime + Config.negativeTtl;
e->store_status = STORE_ABORTED;
storeSetMemStatus(e, IN_MEMORY);
/* No DISK swap for negative cached object */
e->mem_obj->request->protocol,
e->mem_obj->e_current_len);
mk_mime_hdr(mime_hdr,
- (time_t) getNegativeTTL(),
+ (time_t) Config.negativeTtl,
6 + strlen(msg),
squid_curtime,
"text/html");
debug(20, 2, "storeGetMemSpace: Done.\n");
return 0;
}
- if ((store_mem_size + size) < getCacheMemMax()) {
+ if ((store_mem_size + size) < Config.Mem.maxSize) {
/* We're over high water mark here, but still under absolute max */
if (!over_highwater) {
/* print only once when the condition occur until it clears. */
wordlist *w = NULL;
char *fname = NULL;
- if (strcmp((fname = getStoreLogFile()), "none") == 0)
+ if (strcmp((fname = Config.Log.store), "none") == 0)
storelog_fd = -1;
else
storelog_fd = file_open(fname, NULL, O_WRONLY | O_CREAT);
if (storelog_fd < 0)
debug(20, 1, "Store logging disabled\n");
- for (w = getCacheDirs(); w; w = w->next)
+ for (w = Config.cache_dirs; w; w = w->next)
storeAddSwapDisk(w->key);
storeSanityCheck();
file_map_create(MAX_SWAP_FILE);
- dir_created = storeVerifySwapDirs(zap_disk_store);
+ dir_created = storeVerifySwapDirs(opt_zap_disk_store);
storeCreateHashTable(urlcmp);
sprintf(swaplog_file, "%s/log", swappath(0));
}
swaplog_lock = file_write_lock(swaplog_fd);
- if (!zap_disk_store)
+ if (!opt_zap_disk_store)
storeStartRebuildFromDisk();
else
store_rebuilding = STORE_NOT_REBUILDING;
- if (dir_created || zap_disk_store)
+ if (dir_created || opt_zap_disk_store)
storeCreateSwapSubDirs();
- store_mem_high = (long) (getCacheMemMax() / 100) *
- getCacheMemHighWaterMark();
- store_mem_low = (long) (getCacheMemMax() / 100) *
- getCacheMemLowWaterMark();
+ store_mem_high = (long) (Config.Mem.maxSize / 100) *
+ Config.Mem.highWaterMark;
+ store_mem_low = (long) (Config.Mem.maxSize / 100) *
+ Config.Mem.lowWaterMark;
- store_hotobj_high = (int) (getCacheHotVmFactor() *
+ store_hotobj_high = (int) (Config.hotVmFactor *
store_mem_high / (1 << 20));
- store_hotobj_low = (int) (getCacheHotVmFactor() *
+ store_hotobj_low = (int) (Config.hotVmFactor *
store_mem_low / (1 << 20));
/* check for validity */
if (store_hotobj_low > store_hotobj_high)
store_hotobj_low = store_hotobj_high;
- store_swap_high = (long) (getCacheSwapMax() / 100) *
- getCacheSwapHighWaterMark();
- store_swap_low = (long) (getCacheSwapMax() / 100) *
- getCacheSwapLowWaterMark();
+ store_swap_high = (long) (Config.Swap.maxSize / 100) *
+ Config.Swap.highWaterMark;
+ store_swap_low = (long) (Config.Swap.maxSize / 100) *
+ Config.Swap.lowWaterMark;
return 0;
}
name);
debug(20, 0, "Forcing a *full restart* (e.g., %s -z)...\n",
appname);
- zap_disk_store = 1;
+ opt_zap_disk_store = 1;
return;
}
}
file_close(storelog_fd);
storelog_fd = -1;
}
- if ((fname = getStoreLogFile()) == NULL)
+ if ((fname = Config.Log.store) == NULL)
return;
if (strcmp(fname, "none") == 0)
debug(20, 1, "storeRotateLog: Rotating.\n");
/* Rotate numbers 0 through N up one */
- for (i = getLogfileRotateNumber(); i > 1;) {
+ for (i = Config.Log.rotateNumber; i > 1;) {
i--;
sprintf(from, "%s.%d", fname, i - 1);
sprintf(to, "%s.%d", fname, i);
rename(from, to);
}
/* Rotate the current log to .0 */
- if (getLogfileRotateNumber() > 0) {
+ if (Config.Log.rotateNumber > 0) {
sprintf(to, "%s.%d", fname, 0);
rename(fname, to);
}
/*
- * $Id: tools.cc,v 1.45 1996/07/18 20:27:12 wessels Exp $
+ * $Id: tools.cc,v 1.46 1996/07/25 07:10:44 wessels Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
fp = fopen(filename, "w");
if (fp != NULL) {
fprintf(fp, "From: %s\n", appname);
- fprintf(fp, "To: %s\n", getAdminEmail());
+ fprintf(fp, "To: %s\n", Config.adminEmail);
fprintf(fp, "Subject: %s\n", dead_msg());
fclose(fp);
- sprintf(command, "mail %s < %s", getAdminEmail(), filename);
+ sprintf(command, "mail %s < %s", Config.adminEmail, filename);
system(command); /* XXX should avoid system(3) */
unlink(filename);
}
void print_warranty()
{
- if (getAdminEmail())
+ if (Config.adminEmail)
mail_warranty();
else
puts(dead_msg());
static int state = 0;
debug(21, 1, "sigusr2_handle: SIGUSR2 received.\n");
if (state == 0) {
- _db_init(getCacheLogFile(), "ALL,10");
+ _db_init(Config.Log.log, "ALL,10");
state = 1;
} else {
- _db_init(getCacheLogFile(), getDebugOptions());
+ _db_init(Config.Log.log, Config.debugOptions);
state = 0;
}
#if !HAVE_SIGACTION
void setSocketShutdownLifetimes()
{
FD_ENTRY *f = NULL;
- int lft = getShutdownLifetime();
+ int lft = Config.lifetimeShutdown;
int cur;
int i;
for (i = fdstat_biggest_fd(); i >= 0; i--) {
void normal_shutdown()
{
debug(21, 1, "Shutting down...\n");
- if (getPidFilename()) {
+ if (Config.pidFilename) {
enter_suid();
- safeunlink(getPidFilename(), 0);
+ safeunlink(Config.pidFilename, 0);
leave_suid();
}
storeWriteCleanLog();
struct hostent *h = NULL;
char *t = NULL;
- if ((t = getVisibleHostname()))
+ if ((t = Config.visibleHostname))
return t;
/* Get the host name and store it in host to return */
if (geteuid() != 0)
return;
/* Started as a root, check suid option */
- if (getEffectiveUser() == NULL)
+ if (Config.effectiveUser == NULL)
return;
- if ((pwd = getpwnam(getEffectiveUser())) == NULL)
+ if ((pwd = getpwnam(Config.effectiveUser)) == NULL)
return;
- if (getEffectiveGroup() && (grp = getgrnam(getEffectiveGroup()))) {
+ if (Config.effectiveGroup && (grp = getgrnam(Config.effectiveGroup))) {
setgid(grp->gr_gid);
} else {
setgid(pwd->pw_gid);
FILE *pid_fp = NULL;
char *f = NULL;
- if ((f = getPidFilename()) == NULL)
+ if ((f = Config.pidFilename) == NULL)
return;
enter_suid();
pid_fp = fopen(f, "w");
/*
- * $Id: tunnel.cc,v 1.8 1996/07/20 04:22:27 wessels Exp $
+ * $Id: tunnel.cc,v 1.9 1996/07/25 07:10:41 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
RequestMethodStr[request->method], url);
/* Create socket. */
- sock = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url);
+ sock = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, url);
if (sock == COMM_ERROR) {
debug(26, 4, "sslStart: Failed because we're out of sockets.\n");
buf = squid_error_url(url,
sslState->url = xstrdup(url);
sslState->request = requestLink(request);
sslState->mime_hdr = mime_hdr;
- sslState->timeout = getReadTimeout();
+ sslState->timeout = Config.readTimeout;
sslState->size_ptr = size_ptr;
sslState->client.fd = fd;
sslState->server.fd = sock;
/*
- * $Id: wais.cc,v 1.34 1996/07/20 03:16:58 wessels Exp $
+ * $Id: wais.cc,v 1.35 1996/07/25 07:10:45 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
(void *) NULL,
(time_t) 0);
/* dont try reading again for a while */
- comm_set_stall(fd, getStallDelay());
+ comm_set_stall(fd, Config.stallDelay);
return;
}
} else {
comm_set_select_handler(fd, COMM_SELECT_READ,
(PF) waisReadReply, (void *) waisState);
comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
- (PF) waisReadReplyTimeout, (void *) waisState, getReadTimeout());
+ (PF) waisReadReplyTimeout, (void *) waisState, Config.readTimeout);
} else {
BIT_RESET(entry->flag, CACHABLE);
storeReleaseRequest(entry);
entry->expires = squid_curtime;
storeComplete(entry);
comm_close(fd);
- } else if (((entry->mem_obj->e_current_len + len) > getWAISMax()) &&
+ } else if (((entry->mem_obj->e_current_len + len) > Config.Wais.maxObjSize) &&
!(entry->flag & DELETE_BEHIND)) {
/* accept data, but start to delete behind it */
storeStartDeleteBehind(entry);
COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout,
(void *) waisState,
- getReadTimeout());
+ Config.readTimeout);
} else {
storeAppend(entry, buf, len);
comm_set_select_handler(fd,
COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout,
(void *) waisState,
- getReadTimeout());
+ Config.readTimeout);
}
}
COMM_SELECT_TIMEOUT,
(PF) waisReadReplyTimeout,
(void *) waisState,
- getReadTimeout());
+ Config.readTimeout);
}
}
debug(24, 3, "waisStart: \"%s %s\"\n", RequestMethodStr[method], url);
debug(24, 4, " header: %s\n", mime_hdr);
- if (!getWaisRelayHost()) {
+ if (!Config.Wais.relayHost) {
debug(24, 0, "waisStart: Failed because no relay host defined!\n");
squid_error_entry(entry, ERR_NO_RELAY, NULL);
return COMM_ERROR;
}
- fd = comm_open(COMM_NONBLOCKING, getTcpOutgoingAddr(), 0, url);
+ fd = comm_open(COMM_NONBLOCKING, Config.Addrs.tcp_outgoing, 0, url);
if (fd == COMM_ERROR) {
debug(24, 4, "waisStart: Failed because we're out of sockets.\n");
squid_error_entry(entry, ERR_NO_FDS, xstrerror());
waisState = xcalloc(1, sizeof(WaisStateData));
storeLockObject(waisState->entry = entry, NULL, NULL);
waisState->method = method;
- waisState->relayhost = getWaisRelayHost();
- waisState->relayport = getWaisRelayPort();
+ waisState->relayhost = Config.Wais.relayHost;
+ waisState->relayport = Config.Wais.relayPort;
waisState->mime_hdr = mime_hdr;
waisState->fd = fd;
strncpy(waisState->request, url, MAX_URL);