]>
Commit | Line | Data |
---|---|---|
30a4f2a8 | 1 | /* |
eaa77841 | 2 | * $Id: cache_cf.cc,v 1.67 1996/07/27 07:07:41 wessels Exp $ |
30a4f2a8 | 3 | * |
4 | * DEBUG: section 3 Configuration File Parsing | |
5 | * AUTHOR: Harvest Derived | |
6 | * | |
7 | * SQUID Internet Object Cache http://www.nlanr.net/Squid/ | |
8 | * -------------------------------------------------------- | |
9 | * | |
10 | * Squid is the result of efforts by numerous individuals from the | |
11 | * Internet community. Development is led by Duane Wessels of the | |
12 | * National Laboratory for Applied Network Research and funded by | |
13 | * the National Science Foundation. | |
14 | * | |
15 | * This program is free software; you can redistribute it and/or modify | |
16 | * it under the terms of the GNU General Public License as published by | |
17 | * the Free Software Foundation; either version 2 of the License, or | |
18 | * (at your option) any later version. | |
19 | * | |
20 | * This program is distributed in the hope that it will be useful, | |
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | * GNU General Public License for more details. | |
24 | * | |
25 | * You should have received a copy of the GNU General Public License | |
26 | * along with this program; if not, write to the Free Software | |
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
28 | * | |
29 | */ | |
cf5fd929 | 30 | |
30a4f2a8 | 31 | /* |
32 | * Copyright (c) 1994, 1995. All rights reserved. | |
33 | * | |
34 | * The Harvest software was developed by the Internet Research Task | |
35 | * Force Research Group on Resource Discovery (IRTF-RD): | |
36 | * | |
37 | * Mic Bowman of Transarc Corporation. | |
38 | * Peter Danzig of the University of Southern California. | |
39 | * Darren R. Hardy of the University of Colorado at Boulder. | |
40 | * Udi Manber of the University of Arizona. | |
41 | * Michael F. Schwartz of the University of Colorado at Boulder. | |
42 | * Duane Wessels of the University of Colorado at Boulder. | |
43 | * | |
44 | * This copyright notice applies to software in the Harvest | |
45 | * ``src/'' directory only. Users should consult the individual | |
46 | * copyright notices in the ``components/'' subdirectories for | |
47 | * copyright information about other software bundled with the | |
48 | * Harvest source code distribution. | |
49 | * | |
50 | * TERMS OF USE | |
51 | * | |
52 | * The Harvest software may be used and re-distributed without | |
53 | * charge, provided that the software origin and research team are | |
54 | * cited in any use of the system. Most commonly this is | |
55 | * accomplished by including a link to the Harvest Home Page | |
56 | * (http://harvest.cs.colorado.edu/) from the query page of any | |
57 | * Broker you deploy, as well as in the query result pages. These | |
58 | * links are generated automatically by the standard Broker | |
59 | * software distribution. | |
60 | * | |
61 | * The Harvest software is provided ``as is'', without express or | |
62 | * implied warranty, and with no support nor obligation to assist | |
63 | * in its use, correction, modification or enhancement. We assume | |
64 | * no liability with respect to the infringement of copyrights, | |
65 | * trade secrets, or any patents, and are not responsible for | |
66 | * consequential damages. Proper use of the Harvest software is | |
67 | * entirely the responsibility of the user. | |
68 | * | |
69 | * DERIVATIVE WORKS | |
70 | * | |
71 | * Users may make derivative works from the Harvest software, subject | |
72 | * to the following constraints: | |
73 | * | |
74 | * - You must include the above copyright notice and these | |
75 | * accompanying paragraphs in all forms of derivative works, | |
76 | * and any documentation and other materials related to such | |
77 | * distribution and use acknowledge that the software was | |
78 | * developed at the above institutions. | |
79 | * | |
80 | * - You must notify IRTF-RD regarding your distribution of | |
81 | * the derivative work. | |
82 | * | |
83 | * - You must clearly notify users that your are distributing | |
84 | * a modified version and not the original Harvest software. | |
85 | * | |
86 | * - Any derivative product is also subject to these copyright | |
87 | * and use restrictions. | |
88 | * | |
89 | * Note that the Harvest software is NOT in the public domain. We | |
90 | * retain copyright, as specified above. | |
91 | * | |
92 | * HISTORY OF FREE SOFTWARE STATUS | |
93 | * | |
94 | * Originally we required sites to license the software in cases | |
95 | * where they were going to build commercial products/services | |
96 | * around Harvest. In June 1995 we changed this policy. We now | |
97 | * allow people to use the core Harvest software (the code found in | |
98 | * the Harvest ``src/'' directory) for free. We made this change | |
99 | * in the interest of encouraging the widest possible deployment of | |
100 | * the technology. The Harvest software is really a reference | |
101 | * implementation of a set of protocols and formats, some of which | |
102 | * we intend to standardize. We encourage commercial | |
103 | * re-implementations of code complying to this set of standards. | |
104 | */ | |
ed43818f | 105 | |
44a47c6e | 106 | #include "squid.h" |
090089c4 | 107 | |
b6f794d6 | 108 | struct SquidConfig Config; |
090089c4 | 109 | |
110 | #define DefaultMemMaxSize (16 << 20) /* 16 MB */ | |
7813c6d5 | 111 | #define DefaultMemHighWaterMark 90 /* 90% */ |
112 | #define DefaultMemLowWaterMark 75 /* 75% */ | |
090089c4 | 113 | #define DefaultSwapMaxSize (100 << 10) /* 100 MB (100*1024 kbytes) */ |
114 | #define DefaultSwapHighWaterMark 90 /* 90% */ | |
234967c9 | 115 | #define DefaultSwapLowWaterMark 75 /* 75% */ |
090089c4 | 116 | |
30a4f2a8 | 117 | #define DefaultFtpDefaultTtl (3 * 24 * 60 * 60) /* 3 days */ |
090089c4 | 118 | #define DefaultFtpMaxObjSize (4 << 20) /* 4 MB */ |
30a4f2a8 | 119 | #define DefaultGopherDefaultTtl (3 * 24 * 60 * 60) /* 3 days */ |
090089c4 | 120 | #define DefaultGopherMaxObjSize (4 << 20) /* 4 MB */ |
30a4f2a8 | 121 | #define DefaultHttpDefaultTtl (3 * 24 * 60 * 60) /* 3 days */ |
090089c4 | 122 | #define DefaultHttpMaxObjSize (4 << 20) /* 4 MB */ |
30a4f2a8 | 123 | #define DefaultWaisDefaultTtl (3 * 24 * 60 * 60) /* 3 days */ |
090089c4 | 124 | #define DefaultWaisMaxObjSize (4 << 20) /* 4 MB */ |
125 | #define DefaultWaisRelayHost (char *)NULL | |
30a4f2a8 | 126 | #define DefaultWaisRelayPort 0 |
090089c4 | 127 | |
128 | #define DefaultNegativeTtl (5 * 60) /* 5 min */ | |
61d6fc5c | 129 | #define DefaultNegativeDnsTtl (2 * 60) /* 2 min */ |
2639dac6 | 130 | #define DefaultPositiveDnsTtl (360 * 60) /* 6 hours */ |
090089c4 | 131 | #define DefaultReadTimeout (15 * 60) /* 15 min */ |
132 | #define DefaultLifetimeDefault (200 * 60) /* 3+ hours */ | |
234967c9 | 133 | #define DefaultLifetimeShutdown 30 /* 30 seconds */ |
090089c4 | 134 | #define DefaultConnectTimeout (2 * 60) /* 2 min */ |
135 | #define DefaultDefaultAgeMax (3600 * 24 * 30) /* 30 days */ | |
136 | #define DefaultCleanRate -1 /* disabled */ | |
d2af9477 | 137 | #define DefaultDnsChildren 5 /* 5 processes */ |
138 | #define DefaultRedirectChildren 5 /* 5 processes */ | |
234967c9 | 139 | #define DefaultMaxRequestSize (100 << 10) /* 100Kb */ |
090089c4 | 140 | #define DefaultHotVmFactor 0.0 /* disabled */ |
141 | ||
30a4f2a8 | 142 | #define DefaultHttpPortNum CACHE_HTTP_PORT |
143 | #define DefaultIcpPortNum CACHE_ICP_PORT | |
090089c4 | 144 | |
a26bdc75 | 145 | #define DefaultCacheLogFile DEFAULT_CACHE_LOG |
146 | #define DefaultAccessLogFile DEFAULT_ACCESS_LOG | |
d8b45066 | 147 | #define DefaultStoreLogFile DEFAULT_STORE_LOG |
090089c4 | 148 | #define DefaultLogRotateNumber 10 |
149 | #define DefaultAdminEmail "webmaster" | |
a26bdc75 | 150 | #define DefaultFtpgetProgram DEFAULT_FTPGET |
090089c4 | 151 | #define DefaultFtpgetOptions "" |
a26bdc75 | 152 | #define DefaultDnsserverProgram DEFAULT_DNSSERVER |
d2af9477 | 153 | #define DefaultRedirectProgram (char *)NULL /* default NONE */ |
090089c4 | 154 | #define DefaultEffectiveUser (char *)NULL /* default NONE */ |
155 | #define DefaultEffectiveGroup (char *)NULL /* default NONE */ | |
156 | #define DefaultAppendDomain (char *)NULL /* default NONE */ | |
157 | ||
ccff9601 | 158 | #define DefaultDebugOptions "ALL,1" /* All sections at level 1 */ |
090089c4 | 159 | #define DefaultAccelHost (char *)NULL /* default NONE */ |
160 | #define DefaultAccelPrefix (char *)NULL /* default NONE */ | |
161 | #define DefaultAccelPort 0 /* default off */ | |
162 | #define DefaultAccelWithProxy 0 /* default off */ | |
163 | #define DefaultSourcePing 0 /* default off */ | |
1ef4c6c1 | 164 | #define DefaultCommonLogFormat 0 /* default off */ |
c1c29eb6 | 165 | #define DefaultIdentLookup 0 /* default off */ |
090089c4 | 166 | #define DefaultQuickAbort 0 /* default off */ |
167 | #define DefaultNeighborTimeout 2 /* 2 seconds */ | |
234967c9 | 168 | #define DefaultStallDelay 1 /* 1 seconds */ |
090089c4 | 169 | #define DefaultSingleParentBypass 0 /* default off */ |
77ffc99f | 170 | #define DefaultPidFilename (char *)NULL /* default NONE */ |
cf5fd929 | 171 | #define DefaultVisibleHostname (char *)NULL /* default NONE */ |
b8de7ebe | 172 | #define DefaultFtpUser "squid@" /* Default without domain */ |
7d49daab | 173 | #define DefaultAnnounceHost "sd.cache.nlanr.net" |
174 | #define DefaultAnnouncePort 3131 | |
7ba794f4 | 175 | #define DefaultAnnounceFile (char *)NULL /* default NONE */ |
30a4f2a8 | 176 | #define DefaultAnnounceRate 0 /* Default off */ |
7813c6d5 | 177 | #define DefaultTcpRcvBufsz 0 /* use system default */ |
30a4f2a8 | 178 | #define DefaultTcpIncomingAddr INADDR_ANY |
179 | #define DefaultTcpOutgoingAddr INADDR_NONE | |
180 | #define DefaultUdpIncomingAddr INADDR_ANY | |
181 | #define DefaultUdpOutgoingAddr INADDR_NONE | |
844327e4 | 182 | #define DefaultClientNetmask 0xFFFFFFFF; |
98ffb7e4 | 183 | #define DefaultSslProxyPort 0 |
184 | #define DefaultSslProxyHost (char *)NULL | |
ccff9601 | 185 | |
090089c4 | 186 | int httpd_accel_mode = 0; /* for fast access */ |
f133a434 | 187 | char *DefaultSwapDir = DEFAULT_SWAP_DIR; |
00fac1f8 | 188 | char *DefaultConfigFile = DEFAULT_CONFIG_FILE; |
cbbad1ed | 189 | char *ConfigFile = NULL; /* the whole thing */ |
fe1c7f28 | 190 | char *cfg_filename = NULL; /* just the last part */ |
30a4f2a8 | 191 | char ForwardedBy[256]; |
090089c4 | 192 | |
12b9e9b1 | 193 | char w_space[] = " \t\n"; |
3003c0f3 | 194 | char config_input_line[BUFSIZ]; |
195 | int config_lineno = 0; | |
090089c4 | 196 | |
0ffd22bc | 197 | static void configSetFactoryDefaults _PARAMS((void)); |
198 | static void configFreeMemory _PARAMS((void)); | |
199 | static void configDoConfigure _PARAMS((void)); | |
30a4f2a8 | 200 | static char *safe_xstrdup _PARAMS((char *p)); |
c1c29eb6 | 201 | static void parseOnOff _PARAMS((int *)); |
7813c6d5 | 202 | static void parseIntegerValue _PARAMS((int *)); |
cf5fd929 | 203 | static char fatal_str[BUFSIZ]; |
090089c4 | 204 | |
3003c0f3 | 205 | void self_destruct() |
090089c4 | 206 | { |
b8de7ebe | 207 | sprintf(fatal_str, "Bungled %s line %d: %s", |
208 | cfg_filename, config_lineno, config_input_line); | |
090089c4 | 209 | fatal(fatal_str); |
210 | } | |
211 | ||
c8bd12b1 | 212 | int ip_acl_match(c, a) |
213 | struct in_addr c; | |
214 | ip_acl *a; | |
215 | { | |
216 | static struct in_addr h; | |
217 | ||
218 | h.s_addr = c.s_addr & a->mask.s_addr; | |
219 | if (h.s_addr == a->addr.s_addr) | |
220 | return 1; | |
221 | else | |
222 | return 0; | |
223 | } | |
224 | ||
225 | ||
c837641d | 226 | ip_access_type ip_access_check(address, list) |
c8bd12b1 | 227 | struct in_addr address; |
228 | ip_acl *list; | |
229 | { | |
c7f37efb | 230 | static int init = 0; |
231 | static struct in_addr localhost; | |
c837641d | 232 | ip_acl *p = NULL; |
c8bd12b1 | 233 | struct in_addr naddr; /* network byte-order IP addr */ |
c8bd12b1 | 234 | |
235 | if (!list) | |
236 | return IP_ALLOW; | |
237 | ||
c7f37efb | 238 | if (!init) { |
239 | memset((char *) &localhost, '\0', sizeof(struct in_addr)); | |
c8bd12b1 | 240 | localhost.s_addr = inet_addr("127.0.0.1"); |
c7f37efb | 241 | init = 1; |
242 | } | |
c8bd12b1 | 243 | naddr.s_addr = address.s_addr; |
244 | if (naddr.s_addr == localhost.s_addr) | |
245 | return IP_ALLOW; | |
246 | ||
a4f583ee | 247 | debug(3, 5, "ip_access_check: using %s\n", inet_ntoa(naddr)); |
c8bd12b1 | 248 | |
249 | for (p = list; p; p = p->next) { | |
a4f583ee | 250 | debug(3, 5, "ip_access_check: %s vs %s/%s\n", |
251 | inet_ntoa(naddr), | |
252 | inet_ntoa(p->addr), | |
253 | inet_ntoa(p->mask)); | |
c8bd12b1 | 254 | if (ip_acl_match(naddr, p)) |
255 | return p->access; | |
256 | } | |
257 | return IP_ALLOW; | |
258 | } | |
259 | ||
260 | ||
261 | void addToIPACL(list, ip_str, access) | |
262 | ip_acl **list; | |
263 | char *ip_str; | |
264 | ip_access_type access; | |
265 | { | |
266 | ip_acl *p, *q; | |
267 | int a1, a2, a3, a4; | |
268 | int m1, m2, m3, m4; | |
269 | struct in_addr lmask; | |
270 | int c; | |
271 | ||
272 | if (!ip_str) { | |
273 | return; | |
274 | } | |
275 | if (!(*list)) { | |
276 | /* empty list */ | |
30a4f2a8 | 277 | *list = xcalloc(1, sizeof(ip_acl)); |
c8bd12b1 | 278 | (*list)->next = NULL; |
279 | q = *list; | |
280 | } else { | |
281 | /* find end of list */ | |
282 | p = *list; | |
283 | while (p->next) | |
284 | p = p->next; | |
30a4f2a8 | 285 | q = xcalloc(1, sizeof(ip_acl)); |
c8bd12b1 | 286 | q->next = NULL; |
287 | p->next = q; | |
288 | } | |
289 | ||
290 | ||
291 | /* decode ip address */ | |
292 | if (!strcasecmp(ip_str, "all")) { | |
293 | a1 = a2 = a3 = a4 = 0; | |
294 | lmask.s_addr = 0; | |
295 | } else { | |
296 | a1 = a2 = a3 = a4 = 0; | |
297 | c = sscanf(ip_str, "%d.%d.%d.%d/%d.%d.%d.%d", &a1, &a2, &a3, &a4, | |
298 | &m1, &m2, &m3, &m4); | |
299 | ||
300 | switch (c) { | |
301 | case 4: | |
d3c1a245 | 302 | if (a1 == 0 && a2 == 0 && a3 == 0 && a4 == 0) /* world */ |
b2bc6f9e | 303 | lmask.s_addr = 0x00000000; |
d3c1a245 | 304 | else if (a2 == 0 && a3 == 0 && a4 == 0) /* class A */ |
b2bc6f9e | 305 | lmask.s_addr = htonl(0xff000000); |
d3c1a245 | 306 | else if (a3 == 0 && a4 == 0) /* class B */ |
b2bc6f9e | 307 | lmask.s_addr = htonl(0xffff0000); |
d3c1a245 | 308 | else if (a4 == 0) /* class C */ |
b2bc6f9e | 309 | lmask.s_addr = htonl(0xffffff00); |
c8bd12b1 | 310 | else |
311 | lmask.s_addr = 0xffffffff; | |
312 | break; | |
313 | ||
314 | case 5: | |
315 | if (m1 < 0 || m1 > 32) { | |
da00e850 | 316 | debug(3, 0, "addToIPACL: Ignoring invalid IP acl line '%s'\n", |
c8bd12b1 | 317 | ip_str); |
318 | return; | |
319 | } | |
320 | lmask.s_addr = htonl(0xffffffff << (32 - m1)); | |
321 | break; | |
322 | ||
323 | case 8: | |
324 | lmask.s_addr = htonl(m1 * 0x1000000 + m2 * 0x10000 + m3 * 0x100 + m4); | |
325 | break; | |
326 | ||
327 | default: | |
da00e850 | 328 | debug(3, 0, "addToIPACL: Ignoring invalid IP acl line '%s'\n", |
329 | ip_str); | |
c8bd12b1 | 330 | return; |
331 | } | |
332 | } | |
333 | ||
334 | q->access = access; | |
335 | q->addr.s_addr = htonl(a1 * 0x1000000 + a2 * 0x10000 + a3 * 0x100 + a4); | |
336 | q->mask.s_addr = lmask.s_addr; | |
337 | } | |
c837641d | 338 | |
92a6f4b1 | 339 | void wordlistDestroy(list) |
84c6cc9f | 340 | wordlist **list; |
0ffd22bc | 341 | { |
342 | wordlist *w = NULL; | |
343 | wordlist *n = NULL; | |
344 | ||
84c6cc9f | 345 | for (w = *list; w; w = n) { |
0ffd22bc | 346 | n = w->next; |
347 | safe_free(w->key); | |
348 | safe_free(w); | |
349 | } | |
350 | *list = NULL; | |
351 | } | |
352 | ||
353 | void wordlistAdd(list, key) | |
354 | wordlist **list; | |
090089c4 | 355 | char *key; |
356 | { | |
0ffd22bc | 357 | wordlist *p = NULL; |
358 | wordlist *q = NULL; | |
090089c4 | 359 | |
360 | if (!(*list)) { | |
361 | /* empty list */ | |
30a4f2a8 | 362 | *list = xcalloc(1, sizeof(wordlist)); |
090089c4 | 363 | (*list)->key = xstrdup(key); |
364 | (*list)->next = NULL; | |
365 | } else { | |
366 | p = *list; | |
367 | while (p->next) | |
368 | p = p->next; | |
30a4f2a8 | 369 | q = xcalloc(1, sizeof(wordlist)); |
090089c4 | 370 | q->key = xstrdup(key); |
371 | q->next = NULL; | |
372 | p->next = q; | |
373 | } | |
374 | } | |
375 | ||
92a6f4b1 | 376 | void intlistDestroy(list) |
377 | intlist **list; | |
378 | { | |
379 | intlist *w = NULL; | |
380 | intlist *n = NULL; | |
381 | ||
382 | for (w = *list; w; w = n) { | |
383 | n = w->next; | |
384 | safe_free(w); | |
385 | } | |
386 | *list = NULL; | |
387 | } | |
388 | ||
403279e0 | 389 | |
090089c4 | 390 | /* Use this #define in all the parse*() functions. Assumes |
3003c0f3 | 391 | * ** char *token is defined |
090089c4 | 392 | */ |
393 | ||
394 | #define GetInteger(var) \ | |
395 | token = strtok(NULL, w_space); \ | |
30a4f2a8 | 396 | if( token == NULL) \ |
3003c0f3 | 397 | self_destruct(); \ |
090089c4 | 398 | if (sscanf(token, "%d", &var) != 1) \ |
3003c0f3 | 399 | self_destruct(); |
090089c4 | 400 | |
401 | ||
3003c0f3 | 402 | static void parseCacheHostLine() |
090089c4 | 403 | { |
404 | char *type = NULL; | |
405 | char *hostname = NULL; | |
406 | char *token = NULL; | |
30a4f2a8 | 407 | u_short http_port = CACHE_HTTP_PORT; |
408 | u_short icp_port = CACHE_ICP_PORT; | |
409 | int options = 0; | |
fe113054 | 410 | int weight = 1; |
30a4f2a8 | 411 | int i; |
090089c4 | 412 | |
090089c4 | 413 | if (!(hostname = strtok(NULL, w_space))) |
3003c0f3 | 414 | self_destruct(); |
090089c4 | 415 | if (!(type = strtok(NULL, w_space))) |
3003c0f3 | 416 | self_destruct(); |
090089c4 | 417 | |
30a4f2a8 | 418 | GetInteger(i); |
419 | http_port = (u_short) i; | |
420 | GetInteger(i); | |
421 | icp_port = (u_short) i; | |
fe113054 | 422 | while ((token = strtok(NULL, w_space))) { |
423 | if (!strcasecmp(token, "proxy-only")) { | |
30a4f2a8 | 424 | options |= NEIGHBOR_PROXY_ONLY; |
425 | } else if (!strcasecmp(token, "no-query")) { | |
426 | options |= NEIGHBOR_NO_QUERY; | |
c06a5b15 | 427 | } else if (!strncasecmp(token, "weight=", 7)) { |
a0bbd6c8 | 428 | weight = atoi(token + 7); |
fe113054 | 429 | } else { |
01f2d250 | 430 | debug(3, 0, "parseCacheHostLine: token='%s'\n", token); |
a0bbd6c8 | 431 | self_destruct(); |
fe113054 | 432 | } |
090089c4 | 433 | } |
234967c9 | 434 | if (weight < 1) |
435 | weight = 1; | |
30a4f2a8 | 436 | neighbors_cf_add(hostname, type, http_port, icp_port, options, weight); |
090089c4 | 437 | } |
438 | ||
3003c0f3 | 439 | static void parseHostDomainLine() |
090089c4 | 440 | { |
441 | char *host = NULL; | |
442 | char *domain = NULL; | |
30a4f2a8 | 443 | if (!(host = strtok(NULL, w_space))) |
444 | self_destruct(); | |
445 | while ((domain = strtok(NULL, ", \t\n"))) | |
446 | neighbors_cf_domain(host, domain); | |
447 | } | |
090089c4 | 448 | |
30a4f2a8 | 449 | static void parseHostAclLine() |
450 | { | |
451 | char *host = NULL; | |
452 | char *aclname = NULL; | |
090089c4 | 453 | if (!(host = strtok(NULL, w_space))) |
3003c0f3 | 454 | self_destruct(); |
30a4f2a8 | 455 | while ((aclname = strtok(NULL, ", \t\n"))) |
456 | neighbors_cf_acl(host, aclname); | |
090089c4 | 457 | } |
458 | ||
090089c4 | 459 | |
3003c0f3 | 460 | static void parseMemLine() |
090089c4 | 461 | { |
462 | char *token; | |
463 | int i; | |
464 | GetInteger(i); | |
465 | Config.Mem.maxSize = i << 20; | |
466 | } | |
467 | ||
3003c0f3 | 468 | static void parseHotVmFactorLine() |
090089c4 | 469 | { |
470 | char *token = NULL; | |
471 | double d; | |
472 | ||
473 | token = strtok(NULL, w_space); | |
30a4f2a8 | 474 | if (token == NULL) |
3003c0f3 | 475 | self_destruct(); |
090089c4 | 476 | if (sscanf(token, "%lf", &d) != 1) |
3003c0f3 | 477 | self_destruct(); |
090089c4 | 478 | if (d < 0) |
3003c0f3 | 479 | self_destruct(); |
090089c4 | 480 | Config.hotVmFactor = d; |
481 | } | |
482 | ||
3003c0f3 | 483 | static void parseSwapLine() |
090089c4 | 484 | { |
485 | char *token; | |
486 | int i; | |
487 | GetInteger(i); | |
488 | Config.Swap.maxSize = i << 10; | |
489 | } | |
490 | ||
3003c0f3 | 491 | static void parseHttpLine() |
090089c4 | 492 | { |
493 | char *token; | |
494 | int i; | |
495 | GetInteger(i); | |
496 | Config.Http.maxObjSize = i << 20; | |
497 | GetInteger(i); | |
498 | Config.Http.defaultTtl = i * 60; | |
499 | } | |
500 | ||
3003c0f3 | 501 | static void parseGopherLine() |
090089c4 | 502 | { |
503 | char *token; | |
504 | int i; | |
505 | GetInteger(i); | |
506 | Config.Gopher.maxObjSize = i << 20; | |
507 | GetInteger(i); | |
508 | Config.Gopher.defaultTtl = i * 60; | |
509 | } | |
510 | ||
3003c0f3 | 511 | static void parseFtpLine() |
090089c4 | 512 | { |
513 | char *token; | |
514 | int i; | |
515 | GetInteger(i); | |
516 | Config.Ftp.maxObjSize = i << 20; | |
517 | GetInteger(i); | |
518 | Config.Ftp.defaultTtl = i * 60; | |
519 | } | |
520 | ||
3003c0f3 | 521 | static void parseTTLPattern() |
090089c4 | 522 | { |
523 | char *token; | |
524 | char *pattern; | |
525 | time_t abs_ttl = 0; | |
526 | int pct_age = 0; | |
527 | time_t age_max = Config.ageMaxDefault; | |
528 | int i; | |
529 | ||
530 | token = strtok(NULL, w_space); /* token: regex pattern */ | |
30a4f2a8 | 531 | if (token == NULL) |
3003c0f3 | 532 | self_destruct(); |
090089c4 | 533 | pattern = xstrdup(token); |
534 | ||
535 | GetInteger(i); /* token: abs_ttl */ | |
536 | abs_ttl = (time_t) (i * 60); /* convert minutes to seconds */ | |
537 | ||
538 | token = strtok(NULL, w_space); /* token: pct_age */ | |
539 | if (token != (char *) NULL) { /* pct_age is optional */ | |
540 | if (sscanf(token, "%d", &pct_age) != 1) | |
3003c0f3 | 541 | self_destruct(); |
090089c4 | 542 | } |
543 | token = strtok(NULL, w_space); /* token: age_max */ | |
544 | if (token != (char *) NULL) { /* age_max is optional */ | |
545 | if (sscanf(token, "%d", &i) != 1) | |
3003c0f3 | 546 | self_destruct(); |
090089c4 | 547 | age_max = (time_t) (i * 60); /* convert minutes to seconds */ |
548 | } | |
549 | ttlAddToList(pattern, abs_ttl, pct_age, age_max); | |
550 | ||
551 | safe_free(pattern); | |
552 | } | |
553 | ||
3003c0f3 | 554 | static void parseNegativeLine() |
090089c4 | 555 | { |
556 | char *token; | |
557 | int i; | |
558 | GetInteger(i); | |
559 | Config.negativeTtl = i * 60; | |
560 | } | |
561 | ||
3003c0f3 | 562 | static void parseNegativeDnsLine() |
61d6fc5c | 563 | { |
564 | char *token; | |
565 | int i; | |
566 | GetInteger(i); | |
567 | Config.negativeDnsTtl = i * 60; | |
568 | } | |
569 | ||
2639dac6 | 570 | static void parsePositiveDnsLine() |
571 | { | |
572 | char *token; | |
573 | int i; | |
574 | GetInteger(i); | |
575 | Config.positiveDnsTtl = i * 60; | |
576 | } | |
577 | ||
3003c0f3 | 578 | static void parseReadTimeoutLine() |
090089c4 | 579 | { |
580 | char *token; | |
581 | int i; | |
582 | GetInteger(i); | |
583 | Config.readTimeout = i * 60; | |
584 | } | |
585 | ||
3003c0f3 | 586 | static void parseLifetimeLine() |
090089c4 | 587 | { |
588 | char *token; | |
589 | int i; | |
590 | GetInteger(i); | |
591 | Config.lifetimeDefault = i * 60; | |
592 | } | |
593 | ||
3003c0f3 | 594 | static void parseCleanRateLine() |
090089c4 | 595 | { |
596 | char *token; | |
597 | int i; | |
598 | GetInteger(i); | |
599 | Config.cleanRate = i * 60; | |
600 | } | |
601 | ||
3003c0f3 | 602 | static void parseRequestSizeLine() |
fa966b74 | 603 | { |
604 | char *token; | |
605 | int i; | |
606 | GetInteger(i); | |
607 | Config.maxRequestSize = i * 1024; | |
608 | } | |
609 | ||
3003c0f3 | 610 | static void parseMgrLine() |
090089c4 | 611 | { |
612 | char *token; | |
613 | token = strtok(NULL, w_space); | |
30a4f2a8 | 614 | if (token == NULL) |
3003c0f3 | 615 | self_destruct(); |
090089c4 | 616 | safe_free(Config.adminEmail); |
617 | Config.adminEmail = xstrdup(token); | |
618 | } | |
619 | ||
3003c0f3 | 620 | static void parseDirLine() |
090089c4 | 621 | { |
622 | char *token; | |
623 | ||
624 | token = strtok(NULL, w_space); | |
30a4f2a8 | 625 | if (token == NULL) |
3003c0f3 | 626 | self_destruct(); |
0ffd22bc | 627 | wordlistAdd(&Config.cache_dirs, token); |
090089c4 | 628 | } |
629 | ||
3003c0f3 | 630 | static void parseHttpdAccelLine() |
090089c4 | 631 | { |
632 | char *token; | |
844327e4 | 633 | LOCAL_ARRAY(char, buf, BUFSIZ); |
090089c4 | 634 | int i; |
635 | ||
636 | token = strtok(NULL, w_space); | |
30a4f2a8 | 637 | if (token == NULL) |
3003c0f3 | 638 | self_destruct(); |
090089c4 | 639 | safe_free(Config.Accel.host); |
640 | Config.Accel.host = xstrdup(token); | |
641 | GetInteger(i); | |
642 | Config.Accel.port = i; | |
643 | safe_free(Config.Accel.prefix); | |
644 | sprintf(buf, "http://%s:%d", Config.Accel.host, Config.Accel.port); | |
645 | Config.Accel.prefix = xstrdup(buf); | |
646 | httpd_accel_mode = 1; | |
647 | } | |
648 | ||
3003c0f3 | 649 | static void parseEffectiveUserLine() |
090089c4 | 650 | { |
651 | char *token; | |
652 | ||
653 | token = strtok(NULL, w_space); | |
30a4f2a8 | 654 | if (token == NULL) |
3003c0f3 | 655 | self_destruct(); |
090089c4 | 656 | safe_free(Config.effectiveUser); |
657 | safe_free(Config.effectiveGroup); | |
658 | Config.effectiveUser = xstrdup(token); | |
659 | ||
660 | token = strtok(NULL, w_space); | |
30a4f2a8 | 661 | if (token == NULL) |
090089c4 | 662 | return; /* group is optional */ |
663 | Config.effectiveGroup = xstrdup(token); | |
664 | } | |
665 | ||
3003c0f3 | 666 | static void parseLogLine() |
090089c4 | 667 | { |
668 | char *token; | |
090089c4 | 669 | token = strtok(NULL, w_space); |
30a4f2a8 | 670 | if (token == NULL) |
3003c0f3 | 671 | self_destruct(); |
090089c4 | 672 | safe_free(Config.Log.log); |
673 | Config.Log.log = xstrdup(token); | |
090089c4 | 674 | } |
675 | ||
3003c0f3 | 676 | static void parseAccessLogLine() |
090089c4 | 677 | { |
678 | char *token; | |
679 | token = strtok(NULL, w_space); | |
30a4f2a8 | 680 | if (token == NULL) |
3003c0f3 | 681 | self_destruct(); |
090089c4 | 682 | safe_free(Config.Log.access); |
683 | Config.Log.access = xstrdup(token); | |
684 | } | |
685 | ||
d8b45066 | 686 | static void parseStoreLogLine() |
687 | { | |
688 | char *token; | |
689 | token = strtok(NULL, w_space); | |
30a4f2a8 | 690 | if (token == NULL) |
d8b45066 | 691 | self_destruct(); |
692 | safe_free(Config.Log.store); | |
693 | Config.Log.store = xstrdup(token); | |
694 | } | |
695 | ||
3003c0f3 | 696 | static void parseFtpProgramLine() |
090089c4 | 697 | { |
698 | char *token; | |
699 | token = strtok(NULL, w_space); | |
30a4f2a8 | 700 | if (token == NULL) |
3003c0f3 | 701 | self_destruct(); |
090089c4 | 702 | safe_free(Config.Program.ftpget); |
703 | Config.Program.ftpget = xstrdup(token); | |
704 | } | |
705 | ||
3003c0f3 | 706 | static void parseFtpOptionsLine() |
090089c4 | 707 | { |
708 | char *token; | |
709 | token = strtok(NULL, ""); /* Note "", don't separate these */ | |
30a4f2a8 | 710 | if (token == NULL) |
3003c0f3 | 711 | self_destruct(); |
090089c4 | 712 | safe_free(Config.Program.ftpget_opts); |
713 | Config.Program.ftpget_opts = xstrdup(token); | |
714 | } | |
715 | ||
3003c0f3 | 716 | static void parseDnsProgramLine() |
090089c4 | 717 | { |
718 | char *token; | |
719 | token = strtok(NULL, w_space); | |
30a4f2a8 | 720 | if (token == NULL) |
3003c0f3 | 721 | self_destruct(); |
090089c4 | 722 | safe_free(Config.Program.dnsserver); |
723 | Config.Program.dnsserver = xstrdup(token); | |
724 | } | |
725 | ||
d2af9477 | 726 | static void parseRedirectProgramLine() |
727 | { | |
728 | char *token; | |
729 | token = strtok(NULL, w_space); | |
730 | if (token == NULL) | |
731 | self_destruct(); | |
732 | safe_free(Config.Program.redirect); | |
733 | Config.Program.redirect = xstrdup(token); | |
734 | } | |
735 | ||
c1c29eb6 | 736 | static void parseOnOff(var) |
55bb9c51 | 737 | int *var; |
090089c4 | 738 | { |
739 | char *token; | |
740 | token = strtok(NULL, w_space); | |
30a4f2a8 | 741 | if (token == NULL) |
3003c0f3 | 742 | self_destruct(); |
090089c4 | 743 | if (!strcasecmp(token, "on") || !strcasecmp(token, "enable")) |
c1c29eb6 | 744 | *var = 1; |
090089c4 | 745 | else |
c1c29eb6 | 746 | *var = 0; |
090089c4 | 747 | } |
748 | ||
3003c0f3 | 749 | static void parseWAISRelayLine() |
090089c4 | 750 | { |
751 | char *token; | |
752 | int i; | |
753 | token = strtok(NULL, w_space); | |
30a4f2a8 | 754 | if (token == NULL) |
3003c0f3 | 755 | self_destruct(); |
090089c4 | 756 | safe_free(Config.Wais.relayHost); |
757 | Config.Wais.relayHost = xstrdup(token); | |
758 | GetInteger(i); | |
30a4f2a8 | 759 | Config.Wais.relayPort = (u_short) i; |
090089c4 | 760 | GetInteger(i); |
761 | Config.Wais.maxObjSize = i << 20; | |
762 | } | |
763 | ||
30a4f2a8 | 764 | static void parseIPLine(list) |
765 | ip_acl **list; | |
090089c4 | 766 | { |
767 | char *token; | |
768 | while ((token = strtok(NULL, w_space))) { | |
30a4f2a8 | 769 | addToIPACL(list, token, IP_DENY); |
090089c4 | 770 | } |
771 | } | |
772 | ||
30a4f2a8 | 773 | static void parseHierarchyStoplistLine() |
774 | { | |
775 | char *token; | |
776 | while ((token = strtok(NULL, w_space))) | |
777 | wordlistAdd(&Config.hierarchy_stoplist, token); | |
778 | } | |
090089c4 | 779 | |
3003c0f3 | 780 | static void parseAppendDomainLine() |
090089c4 | 781 | { |
782 | char *token; | |
783 | token = strtok(NULL, w_space); | |
30a4f2a8 | 784 | if (token == NULL) |
3003c0f3 | 785 | self_destruct(); |
090089c4 | 786 | if (*token != '.') |
3003c0f3 | 787 | self_destruct(); |
090089c4 | 788 | safe_free(Config.appendDomain); |
789 | Config.appendDomain = xstrdup(token); | |
790 | } | |
791 | ||
30a4f2a8 | 792 | static void parseAddressLine(addr) |
793 | struct in_addr *addr; | |
090089c4 | 794 | { |
795 | char *token; | |
30a4f2a8 | 796 | struct hostent *hp = NULL; |
090089c4 | 797 | token = strtok(NULL, w_space); |
30a4f2a8 | 798 | if (token == NULL) |
799 | self_destruct(); | |
800 | if (inet_addr(token) != INADDR_NONE) | |
801 | (*addr).s_addr = inet_addr(token); | |
802 | else if ((hp = gethostbyname(token))) | |
803 | xmemcpy(addr, hp->h_addr, hp->h_length); | |
804 | else | |
3003c0f3 | 805 | self_destruct(); |
090089c4 | 806 | } |
807 | ||
983061ed | 808 | static void parseLocalDomainFile(fname) |
809 | char *fname; | |
810 | { | |
844327e4 | 811 | LOCAL_ARRAY(char, tmp_line, BUFSIZ); |
983061ed | 812 | FILE *fp = NULL; |
813 | char *t = NULL; | |
814 | ||
815 | if ((fp = fopen(fname, "r")) == NULL) { | |
816 | debug(3, 1, "parseLocalDomainFile: %s: %s\n", fname, xstrerror()); | |
817 | return; | |
818 | } | |
819 | memset(tmp_line, '\0', BUFSIZ); | |
820 | while (fgets(tmp_line, BUFSIZ, fp)) { | |
821 | if (tmp_line[0] == '#') | |
822 | continue; | |
823 | if (tmp_line[0] == '\0') | |
824 | continue; | |
825 | if (tmp_line[0] == '\n') | |
826 | continue; | |
827 | for (t = strtok(tmp_line, w_space); t; t = strtok(NULL, w_space)) { | |
828 | debug(3, 1, "parseLocalDomainFileLine: adding %s\n", t); | |
829 | wordlistAdd(&Config.local_domain_list, t); | |
830 | } | |
831 | } | |
832 | fclose(fp); | |
833 | } | |
834 | ||
3003c0f3 | 835 | static void parseLocalDomainLine() |
090089c4 | 836 | { |
983061ed | 837 | char *token = NULL; |
838 | struct stat sb; | |
090089c4 | 839 | while ((token = strtok(NULL, w_space))) { |
983061ed | 840 | if (stat(token, &sb) < 0) { |
841 | wordlistAdd(&Config.local_domain_list, token); | |
842 | } else { | |
843 | parseLocalDomainFile(token); | |
844 | } | |
090089c4 | 845 | } |
846 | } | |
847 | ||
983061ed | 848 | |
3003c0f3 | 849 | static void parseInsideFirewallLine() |
090089c4 | 850 | { |
851 | char *token; | |
852 | while ((token = strtok(NULL, w_space))) { | |
0ffd22bc | 853 | wordlistAdd(&Config.inside_firewall_list, token); |
090089c4 | 854 | } |
855 | } | |
856 | ||
605ba5ca | 857 | static void parseDnsTestnameLine() |
858 | { | |
859 | char *token; | |
860 | while ((token = strtok(NULL, w_space))) { | |
861 | wordlistAdd(&Config.dns_testname_list, token); | |
862 | } | |
863 | } | |
864 | ||
30a4f2a8 | 865 | static void parseHttpPortLine() |
090089c4 | 866 | { |
867 | char *token; | |
868 | int i; | |
869 | GetInteger(i); | |
30a4f2a8 | 870 | if (i < 0) |
871 | i = 0; | |
872 | Config.Port.http = (u_short) i; | |
090089c4 | 873 | } |
874 | ||
30a4f2a8 | 875 | static void parseIcpPortLine() |
090089c4 | 876 | { |
877 | char *token; | |
878 | int i; | |
879 | GetInteger(i); | |
30a4f2a8 | 880 | if (i < 0) |
881 | i = 0; | |
882 | Config.Port.icp = (u_short) i; | |
090089c4 | 883 | } |
884 | ||
3003c0f3 | 885 | static void parseDebugOptionsLine() |
090089c4 | 886 | { |
12b9e9b1 | 887 | char *token; |
888 | token = strtok(NULL, ""); /* Note "", don't separate these */ | |
889 | safe_free(Config.debugOptions); | |
30a4f2a8 | 890 | if (token == NULL) { |
12b9e9b1 | 891 | Config.debugOptions = NULL; |
892 | return; | |
893 | } | |
894 | Config.debugOptions = xstrdup(token); | |
090089c4 | 895 | } |
896 | ||
3003c0f3 | 897 | static void parsePidFilenameLine() |
ccff9601 | 898 | { |
899 | char *token; | |
900 | token = strtok(NULL, w_space); | |
901 | safe_free(Config.pidFilename); | |
30a4f2a8 | 902 | if (token == NULL) |
3003c0f3 | 903 | self_destruct(); |
ccff9601 | 904 | Config.pidFilename = xstrdup(token); |
905 | } | |
906 | ||
3003c0f3 | 907 | static void parseVisibleHostnameLine() |
cf5fd929 | 908 | { |
909 | char *token; | |
910 | token = strtok(NULL, w_space); | |
911 | safe_free(Config.visibleHostname); | |
30a4f2a8 | 912 | if (token == NULL) |
3003c0f3 | 913 | self_destruct(); |
cf5fd929 | 914 | Config.visibleHostname = xstrdup(token); |
915 | } | |
916 | ||
3003c0f3 | 917 | static void parseFtpUserLine() |
fb263c4c | 918 | { |
919 | char *token; | |
920 | token = strtok(NULL, w_space); | |
30a4f2a8 | 921 | if (token == NULL) |
3003c0f3 | 922 | self_destruct(); |
7d49daab | 923 | safe_free(Config.ftpUser); |
fb263c4c | 924 | Config.ftpUser = xstrdup(token); |
925 | } | |
926 | ||
3003c0f3 | 927 | static void parseCacheAnnounceLine() |
7d49daab | 928 | { |
929 | char *token; | |
930 | int i; | |
931 | GetInteger(i); | |
932 | Config.Announce.rate = i * 3600; /* hours to seconds */ | |
933 | } | |
934 | ||
3003c0f3 | 935 | static void parseAnnounceToLine() |
7d49daab | 936 | { |
937 | char *token; | |
938 | int i; | |
939 | token = strtok(NULL, w_space); | |
30a4f2a8 | 940 | if (token == NULL) |
3003c0f3 | 941 | self_destruct(); |
7d49daab | 942 | safe_free(Config.Announce.host); |
943 | Config.Announce.host = xstrdup(token); | |
944 | if ((token = strchr(Config.Announce.host, ':'))) { | |
945 | *token++ = '\0'; | |
946 | if (sscanf(token, "%d", &i) != 1) | |
947 | Config.Announce.port = i; | |
948 | } | |
949 | token = strtok(NULL, w_space); | |
30a4f2a8 | 950 | if (token == NULL) |
7d49daab | 951 | return; |
952 | safe_free(Config.Announce.file); | |
953 | Config.Announce.file = xstrdup(token); | |
954 | } | |
955 | ||
98ffb7e4 | 956 | static void parseSslProxyLine() |
957 | { | |
958 | char *token; | |
959 | char *t; | |
960 | token = strtok(NULL, w_space); | |
961 | if (token == NULL) | |
962 | self_destruct(); | |
963 | safe_free(Config.sslProxy.host); | |
964 | Config.sslProxy.port = 0; | |
965 | if ((t = strchr(token, ':'))) { | |
966 | *t++ = '\0'; | |
967 | Config.sslProxy.port = atoi(t); | |
968 | } | |
969 | Config.sslProxy.host = xstrdup(token); | |
970 | } | |
971 | ||
7813c6d5 | 972 | static void parseIntegerValue(iptr) |
b6f794d6 | 973 | int *iptr; |
7813c6d5 | 974 | { |
975 | char *token; | |
976 | int i; | |
977 | GetInteger(i); | |
978 | *iptr = i; | |
979 | } | |
980 | ||
403279e0 | 981 | |
090089c4 | 982 | int parseConfigFile(file_name) |
983 | char *file_name; | |
984 | { | |
12b9e9b1 | 985 | FILE *fp = NULL; |
986 | char *token = NULL; | |
844327e4 | 987 | LOCAL_ARRAY(char, tmp_line, BUFSIZ); |
090089c4 | 988 | |
0ffd22bc | 989 | configFreeMemory(); |
090089c4 | 990 | configSetFactoryDefaults(); |
92a6f4b1 | 991 | aclDestroyAcls(); |
992 | aclDestroyAccessList(&HTTPAccessList); | |
993 | aclDestroyAccessList(&ICPAccessList); | |
090089c4 | 994 | |
12b9e9b1 | 995 | if ((fp = fopen(file_name, "r")) == NULL) { |
234967c9 | 996 | sprintf(fatal_str, "Unable to open configuration file: %s: %s", |
997 | file_name, xstrerror()); | |
090089c4 | 998 | fatal(fatal_str); |
999 | } | |
b8de7ebe | 1000 | cfg_filename = file_name; |
1001 | if ((token = strrchr(cfg_filename, '/'))) | |
4cd0ab45 | 1002 | cfg_filename = token + 1; |
3003c0f3 | 1003 | memset(config_input_line, '\0', BUFSIZ); |
1004 | config_lineno = 0; | |
1005 | while (fgets(config_input_line, BUFSIZ, fp)) { | |
1006 | config_lineno++; | |
1007 | if ((token = strchr(config_input_line, '\n'))) | |
540830c4 | 1008 | *token = '\0'; |
3003c0f3 | 1009 | if (config_input_line[0] == '#') |
540830c4 | 1010 | continue; |
3003c0f3 | 1011 | if (config_input_line[0] == '\0') |
090089c4 | 1012 | continue; |
3003c0f3 | 1013 | debug(3, 5, "Processing: '%s'\n", config_input_line); |
1014 | strcpy(tmp_line, config_input_line); | |
92a6f4b1 | 1015 | if ((token = strtok(tmp_line, w_space)) == NULL) |
090089c4 | 1016 | continue; |
1017 | ||
090089c4 | 1018 | if (!strcmp(token, "cache_host")) |
3003c0f3 | 1019 | parseCacheHostLine(); |
090089c4 | 1020 | |
090089c4 | 1021 | else if (!strcmp(token, "cache_host_domain")) |
3003c0f3 | 1022 | parseHostDomainLine(); |
30a4f2a8 | 1023 | else if (!strcmp(token, "cache_host_acl")) |
1024 | parseHostAclLine(); | |
090089c4 | 1025 | |
090089c4 | 1026 | else if (!strcmp(token, "neighbor_timeout")) |
7813c6d5 | 1027 | parseIntegerValue(&Config.neighborTimeout); |
090089c4 | 1028 | else if (!strcmp(token, "neighbour_timeout")) /* alternate spelling */ |
7813c6d5 | 1029 | parseIntegerValue(&Config.neighborTimeout); |
090089c4 | 1030 | |
090089c4 | 1031 | else if (!strcmp(token, "cache_dir")) |
3003c0f3 | 1032 | parseDirLine(); |
090089c4 | 1033 | |
090089c4 | 1034 | else if (!strcmp(token, "cache_log")) |
3003c0f3 | 1035 | parseLogLine(); |
090089c4 | 1036 | |
090089c4 | 1037 | else if (!strcmp(token, "cache_access_log")) |
3003c0f3 | 1038 | parseAccessLogLine(); |
090089c4 | 1039 | |
d8b45066 | 1040 | else if (!strcmp(token, "cache_store_log")) |
1041 | parseStoreLogLine(); | |
1042 | ||
090089c4 | 1043 | else if (!strcmp(token, "logfile_rotate")) |
7813c6d5 | 1044 | parseIntegerValue(&Config.Log.rotateNumber); |
090089c4 | 1045 | |
090089c4 | 1046 | else if (!strcmp(token, "httpd_accel_with_proxy")) |
c1c29eb6 | 1047 | parseOnOff(&Config.Accel.withProxy); |
090089c4 | 1048 | |
090089c4 | 1049 | else if (!strcmp(token, "httpd_accel")) |
3003c0f3 | 1050 | parseHttpdAccelLine(); |
090089c4 | 1051 | |
090089c4 | 1052 | else if (!strcmp(token, "cache_effective_user")) |
3003c0f3 | 1053 | parseEffectiveUserLine(); |
090089c4 | 1054 | |
090089c4 | 1055 | else if (!strcmp(token, "cache_swap_high")) |
7813c6d5 | 1056 | parseIntegerValue(&Config.Swap.highWaterMark); |
090089c4 | 1057 | |
090089c4 | 1058 | else if (!strcmp(token, "cache_swap_low")) |
7813c6d5 | 1059 | parseIntegerValue(&Config.Swap.highWaterMark); |
090089c4 | 1060 | |
090089c4 | 1061 | else if (!strcmp(token, "cache_mem_high")) |
7813c6d5 | 1062 | parseIntegerValue(&Config.Mem.highWaterMark); |
090089c4 | 1063 | |
090089c4 | 1064 | else if (!strcmp(token, "cache_mem_low")) |
7813c6d5 | 1065 | parseIntegerValue(&Config.Mem.lowWaterMark); |
090089c4 | 1066 | |
090089c4 | 1067 | else if (!strcmp(token, "cache_hot_vm_factor")) |
3003c0f3 | 1068 | parseHotVmFactorLine(); |
090089c4 | 1069 | |
090089c4 | 1070 | else if (!strcmp(token, "cache_mem")) |
3003c0f3 | 1071 | parseMemLine(); |
090089c4 | 1072 | |
090089c4 | 1073 | else if (!strcmp(token, "cache_swap")) |
3003c0f3 | 1074 | parseSwapLine(); |
090089c4 | 1075 | |
090089c4 | 1076 | else if (!strcmp(token, "cache_mgr")) |
3003c0f3 | 1077 | parseMgrLine(); |
090089c4 | 1078 | |
8213067d | 1079 | else if (!strcmp(token, "acl")) |
3003c0f3 | 1080 | aclParseAclLine(); |
8213067d | 1081 | |
92a6f4b1 | 1082 | else if (!strcmp(token, "http_access")) |
1083 | aclParseAccessLine(&HTTPAccessList); | |
1084 | ||
1085 | else if (!strcmp(token, "icp_access")) | |
1086 | aclParseAccessLine(&ICPAccessList); | |
8213067d | 1087 | |
30a4f2a8 | 1088 | else if (!strcmp(token, "hierarchy_stoplist")) |
1089 | parseHierarchyStoplistLine(); | |
1090 | ||
090089c4 | 1091 | else if (!strcmp(token, "gopher")) |
3003c0f3 | 1092 | parseGopherLine(); |
090089c4 | 1093 | |
090089c4 | 1094 | else if (!strcmp(token, "http")) |
3003c0f3 | 1095 | parseHttpLine(); |
090089c4 | 1096 | |
090089c4 | 1097 | else if (!strcmp(token, "ftp")) |
3003c0f3 | 1098 | parseFtpLine(); |
090089c4 | 1099 | |
1100 | else if (!strcmp(token, "ttl_pattern")) | |
3003c0f3 | 1101 | parseTTLPattern(); |
090089c4 | 1102 | |
090089c4 | 1103 | else if (!strcmp(token, "negative_ttl")) |
3003c0f3 | 1104 | parseNegativeLine(); |
090089c4 | 1105 | |
61d6fc5c | 1106 | else if (!strcmp(token, "negative_dns_ttl")) |
3003c0f3 | 1107 | parseNegativeDnsLine(); |
61d6fc5c | 1108 | |
2639dac6 | 1109 | else if (!strcmp(token, "positive_dns_ttl")) |
1110 | parsePositiveDnsLine(); | |
1111 | ||
090089c4 | 1112 | else if (!strcmp(token, "read_timeout")) |
3003c0f3 | 1113 | parseReadTimeoutLine(); |
090089c4 | 1114 | |
090089c4 | 1115 | else if (!strcmp(token, "clean_rate")) |
3003c0f3 | 1116 | parseCleanRateLine(); |
090089c4 | 1117 | |
090089c4 | 1118 | else if (!strcmp(token, "client_lifetime")) |
3003c0f3 | 1119 | parseLifetimeLine(); |
090089c4 | 1120 | |
605ba5ca | 1121 | else if (!strcmp(token, "shutdown_lifetime")) |
7813c6d5 | 1122 | parseIntegerValue(&Config.lifetimeShutdown); |
605ba5ca | 1123 | |
fa966b74 | 1124 | else if (!strcmp(token, "request_size")) |
3003c0f3 | 1125 | parseRequestSizeLine(); |
fa966b74 | 1126 | |
090089c4 | 1127 | else if (!strcmp(token, "connect_timeout")) |
7813c6d5 | 1128 | parseIntegerValue(&Config.connectTimeout); |
090089c4 | 1129 | |
090089c4 | 1130 | else if (!strcmp(token, "cache_ftp_program")) |
3003c0f3 | 1131 | parseFtpProgramLine(); |
090089c4 | 1132 | |
090089c4 | 1133 | else if (!strcmp(token, "cache_ftp_options")) |
3003c0f3 | 1134 | parseFtpOptionsLine(); |
090089c4 | 1135 | |
090089c4 | 1136 | else if (!strcmp(token, "cache_dns_program")) |
3003c0f3 | 1137 | parseDnsProgramLine(); |
090089c4 | 1138 | |
090089c4 | 1139 | else if (!strcmp(token, "dns_children")) |
7813c6d5 | 1140 | parseIntegerValue(&Config.dnsChildren); |
090089c4 | 1141 | |
d2af9477 | 1142 | else if (!strcmp(token, "redirect_program")) |
1143 | parseRedirectProgramLine(); | |
98ffb7e4 | 1144 | |
d2af9477 | 1145 | else if (!strcmp(token, "redirect_children")) |
7813c6d5 | 1146 | parseIntegerValue(&Config.redirectChildren); |
d2af9477 | 1147 | |
090089c4 | 1148 | else if (!strcmp(token, "source_ping")) |
c1c29eb6 | 1149 | parseOnOff(&Config.sourcePing); |
090089c4 | 1150 | |
090089c4 | 1151 | else if (!strcmp(token, "quick_abort")) |
c1c29eb6 | 1152 | parseOnOff(&Config.quickAbort); |
090089c4 | 1153 | |
090089c4 | 1154 | else if (!strcmp(token, "emulate_httpd_log")) |
c1c29eb6 | 1155 | parseOnOff(&Config.commonLogFormat); |
1156 | ||
7813c6d5 | 1157 | else if (!strcmp(token, "ident_lookup")) |
c1c29eb6 | 1158 | parseOnOff(&Config.identLookup); |
090089c4 | 1159 | |
1160 | else if (!strcmp(token, "append_domain")) | |
3003c0f3 | 1161 | parseAppendDomainLine(); |
090089c4 | 1162 | |
090089c4 | 1163 | else if (!strcmp(token, "wais_relay")) |
3003c0f3 | 1164 | parseWAISRelayLine(); |
090089c4 | 1165 | |
090089c4 | 1166 | else if (!strcmp(token, "local_ip")) |
b6f794d6 | 1167 | parseIPLine(&Config.local_ip_list); |
30a4f2a8 | 1168 | |
1169 | else if (!strcmp(token, "firewall_ip")) | |
b6f794d6 | 1170 | parseIPLine(&Config.firewall_ip_list); |
090089c4 | 1171 | |
090089c4 | 1172 | else if (!strcmp(token, "local_domain")) |
3003c0f3 | 1173 | parseLocalDomainLine(); |
090089c4 | 1174 | |
30a4f2a8 | 1175 | else if (!strcmp(token, "tcp_incoming_address")) |
1176 | parseAddressLine(&Config.Addrs.tcp_incoming); | |
1177 | ||
1178 | else if (!strcmp(token, "tcp_outgoing_address")) | |
1179 | parseAddressLine(&Config.Addrs.tcp_outgoing); | |
1180 | ||
1181 | else if (!strcmp(token, "udp_incoming_address")) | |
1182 | parseAddressLine(&Config.Addrs.udp_incoming); | |
1183 | ||
1184 | else if (!strcmp(token, "udp_outgoing_address")) | |
1185 | parseAddressLine(&Config.Addrs.udp_outgoing); | |
1186 | ||
844327e4 | 1187 | else if (!strcmp(token, "client_netmask")) |
1188 | parseAddressLine(&Config.Addrs.client_netmask); | |
1189 | ||
7813c6d5 | 1190 | else if (!strcmp(token, "tcp_recv_bufsize")) |
1191 | parseIntegerValue(&Config.tcpRcvBufsz); | |
1192 | ||
2c82dc1a | 1193 | else if (!strcmp(token, "log_fqdn")) |
1194 | parseOnOff(&Config.Log.log_fqdn); | |
1195 | ||
090089c4 | 1196 | else if (!strcmp(token, "bind_address")) |
30a4f2a8 | 1197 | parseAddressLine(&Config.Addrs.tcp_incoming); |
1198 | ||
1199 | else if (!strcmp(token, "outbound_address")) | |
1200 | parseAddressLine(&Config.Addrs.tcp_outgoing); | |
090089c4 | 1201 | |
30a4f2a8 | 1202 | else if (!strcmp(token, "http_port") || !strcmp(token, "ascii_port")) |
1203 | parseHttpPortLine(); | |
090089c4 | 1204 | |
30a4f2a8 | 1205 | else if (!strcmp(token, "icp_port") || !strcmp(token, "udp_port")) |
1206 | parseIcpPortLine(); | |
090089c4 | 1207 | |
1208 | else if (!strcmp(token, "inside_firewall")) | |
3003c0f3 | 1209 | parseInsideFirewallLine(); |
090089c4 | 1210 | |
605ba5ca | 1211 | else if (!strcmp(token, "dns_testnames")) |
1212 | parseDnsTestnameLine(); | |
1213 | ||
090089c4 | 1214 | else if (!strcmp(token, "single_parent_bypass")) |
c1c29eb6 | 1215 | parseOnOff(&Config.singleParentBypass); |
090089c4 | 1216 | |
12b9e9b1 | 1217 | else if (!strcmp(token, "debug_options")) |
3003c0f3 | 1218 | parseDebugOptionsLine(); |
12b9e9b1 | 1219 | |
ccff9601 | 1220 | else if (!strcmp(token, "pid_filename")) |
3003c0f3 | 1221 | parsePidFilenameLine(); |
ccff9601 | 1222 | |
cf5fd929 | 1223 | else if (!strcmp(token, "visible_hostname")) |
3003c0f3 | 1224 | parseVisibleHostnameLine(); |
cf5fd929 | 1225 | |
fb263c4c | 1226 | else if (!strcmp(token, "ftp_user")) |
3003c0f3 | 1227 | parseFtpUserLine(); |
fb263c4c | 1228 | |
7d49daab | 1229 | else if (!strcmp(token, "cache_announce")) |
3003c0f3 | 1230 | parseCacheAnnounceLine(); |
7d49daab | 1231 | |
1232 | else if (!strcmp(token, "announce_to")) | |
3003c0f3 | 1233 | parseAnnounceToLine(); |
7d49daab | 1234 | |
98ffb7e4 | 1235 | else if (!strcmp(token, "ssl_proxy")) |
1236 | parseSslProxyLine(); | |
1237 | ||
090089c4 | 1238 | else { |
540830c4 | 1239 | debug(3, 0, "parseConfigFile: line %d unrecognized: '%s'\n", |
92a6f4b1 | 1240 | config_lineno, |
1241 | config_input_line); | |
090089c4 | 1242 | } |
1243 | } | |
1244 | ||
090089c4 | 1245 | /* Sanity checks */ |
b6f794d6 | 1246 | if (Config.lifetimeDefault < Config.readTimeout) { |
090089c4 | 1247 | printf("WARNING: client_lifetime (%d seconds) is less than read_timeout (%d seconds).\n", |
b6f794d6 | 1248 | Config.lifetimeDefault, Config.readTimeout); |
090089c4 | 1249 | printf(" This may cause serious problems with your cache!!!\n"); |
b8de7ebe | 1250 | printf(" Change your configuration file.\n"); |
090089c4 | 1251 | fflush(stdout); /* print message */ |
1252 | } | |
b6f794d6 | 1253 | if (Config.Swap.maxSize < (Config.Mem.maxSize >> 10)) { |
1254 | printf("WARNING: cache_swap (%d kbytes) is less than cache_mem (%d bytes).\n", Config.Swap.maxSize, Config.Mem.maxSize); | |
090089c4 | 1255 | printf(" This will cause serious problems with your cache!!!\n"); |
b8de7ebe | 1256 | printf(" Change your configuration file.\n"); |
b6f794d6 | 1257 | Config.Swap.maxSize = Config.Mem.maxSize >> 10; |
1258 | printf(" For this run, however, %s will use %d kbytes for cache_swap.\n", appname, Config.Swap.maxSize); | |
090089c4 | 1259 | fflush(stdout); /* print message */ |
1260 | } | |
b6f794d6 | 1261 | if (Config.cleanRate > -1 && Config.cleanRate < 60) { |
090089c4 | 1262 | Config.cleanRate = (30 * 60); |
1263 | printf("WARNING: clean_rate is less than one minute.\n"); | |
1264 | printf(" This will cause serious problems with your cache!!!\n"); | |
b8de7ebe | 1265 | printf(" Change your configuration file.\n"); |
b6f794d6 | 1266 | printf(" For this run, however, %s will use %d minutes for clean_rate.\n", appname, (int) (Config.cleanRate / 60)); |
090089c4 | 1267 | fflush(stdout); /* print message */ |
1268 | } | |
b6f794d6 | 1269 | if (Config.dnsChildren < 1) { |
090089c4 | 1270 | printf("WARNING: dns_children was set to a bad value: %d\n", |
b6f794d6 | 1271 | Config.dnsChildren); |
d2af9477 | 1272 | Config.dnsChildren = DefaultDnsChildren; |
1273 | printf("Setting it to the default (%d).\n", DefaultDnsChildren); | |
b6f794d6 | 1274 | } else if (Config.dnsChildren > DefaultDnsChildrenMax) { |
090089c4 | 1275 | printf("WARNING: dns_children was set to a bad value: %d\n", |
b6f794d6 | 1276 | Config.dnsChildren); |
090089c4 | 1277 | printf("Setting it to the maximum (%d).\n", DefaultDnsChildrenMax); |
1278 | Config.dnsChildren = DefaultDnsChildrenMax; | |
1279 | } | |
b6f794d6 | 1280 | if (Config.redirectChildren < 1) { |
d2af9477 | 1281 | printf("WARNING: redirect_children was set to a bad value: %d\n", |
b6f794d6 | 1282 | Config.redirectChildren); |
d2af9477 | 1283 | Config.redirectChildren = DefaultRedirectChildren; |
1284 | printf("Setting it to the default (%d).\n", DefaultRedirectChildren); | |
b6f794d6 | 1285 | } else if (Config.redirectChildren > DefaultRedirectChildrenMax) { |
d2af9477 | 1286 | printf("WARNING: redirect_children was set to a bad value: %d\n", |
b6f794d6 | 1287 | Config.redirectChildren); |
d2af9477 | 1288 | printf("Setting it to the maximum (%d).\n", DefaultRedirectChildrenMax); |
1289 | Config.redirectChildren = DefaultRedirectChildrenMax; | |
1290 | } | |
090089c4 | 1291 | fclose(fp); |
1292 | ||
1293 | configDoConfigure(); | |
1294 | return 0; | |
1295 | } | |
1296 | ||
090089c4 | 1297 | int setCacheSwapMax(size) |
1298 | int size; | |
1299 | { | |
1300 | Config.Swap.maxSize = size; | |
1301 | return Config.Swap.maxSize; | |
1302 | } | |
30a4f2a8 | 1303 | u_short setHttpPortNum(port) |
1304 | u_short port; | |
090089c4 | 1305 | { |
30a4f2a8 | 1306 | return (Config.Port.http = port); |
090089c4 | 1307 | } |
30a4f2a8 | 1308 | u_short setIcpPortNum(port) |
1309 | u_short port; | |
1310 | { | |
1311 | return (Config.Port.icp = port); | |
1312 | } | |
1313 | ||
090089c4 | 1314 | |
30a4f2a8 | 1315 | static char *safe_xstrdup(p) |
090089c4 | 1316 | char *p; |
1317 | { | |
30a4f2a8 | 1318 | return p ? xstrdup(p) : p; |
090089c4 | 1319 | } |
1320 | ||
0ffd22bc | 1321 | static void configFreeMemory() |
1322 | { | |
1323 | safe_free(Config.Wais.relayHost); | |
1324 | safe_free(Config.Log.log); | |
1325 | safe_free(Config.Log.access); | |
983061ed | 1326 | safe_free(Config.Log.store); |
0ffd22bc | 1327 | safe_free(Config.adminEmail); |
1328 | safe_free(Config.effectiveUser); | |
1329 | safe_free(Config.effectiveGroup); | |
1330 | safe_free(Config.Program.ftpget); | |
1331 | safe_free(Config.Program.ftpget_opts); | |
1332 | safe_free(Config.Program.dnsserver); | |
d2af9477 | 1333 | safe_free(Config.Program.redirect); |
0ffd22bc | 1334 | safe_free(Config.Accel.host); |
1335 | safe_free(Config.Accel.prefix); | |
1336 | safe_free(Config.appendDomain); | |
1337 | safe_free(Config.debugOptions); | |
1338 | safe_free(Config.pidFilename); | |
1339 | safe_free(Config.visibleHostname); | |
1340 | safe_free(Config.ftpUser); | |
1341 | safe_free(Config.Announce.host); | |
1342 | safe_free(Config.Announce.file); | |
1343 | wordlistDestroy(&Config.cache_dirs); | |
30a4f2a8 | 1344 | wordlistDestroy(&Config.hierarchy_stoplist); |
0ffd22bc | 1345 | wordlistDestroy(&Config.local_domain_list); |
1346 | wordlistDestroy(&Config.inside_firewall_list); | |
605ba5ca | 1347 | wordlistDestroy(&Config.dns_testname_list); |
98ffb7e4 | 1348 | safe_free(Config.sslProxy.host); |
0ffd22bc | 1349 | } |
1350 | ||
090089c4 | 1351 | |
1352 | static void configSetFactoryDefaults() | |
1353 | { | |
1354 | Config.Mem.maxSize = DefaultMemMaxSize; | |
7813c6d5 | 1355 | Config.Mem.highWaterMark = DefaultMemHighWaterMark; |
1356 | Config.Mem.lowWaterMark = DefaultMemLowWaterMark; | |
090089c4 | 1357 | Config.Swap.maxSize = DefaultSwapMaxSize; |
7813c6d5 | 1358 | Config.Swap.highWaterMark = DefaultSwapHighWaterMark; |
090089c4 | 1359 | Config.Swap.lowWaterMark = DefaultSwapLowWaterMark; |
1360 | ||
1361 | Config.Ftp.defaultTtl = DefaultFtpDefaultTtl; | |
1362 | Config.Ftp.maxObjSize = DefaultFtpMaxObjSize; | |
1363 | Config.Gopher.defaultTtl = DefaultGopherDefaultTtl; | |
1364 | Config.Gopher.maxObjSize = DefaultGopherMaxObjSize; | |
1365 | Config.Http.defaultTtl = DefaultHttpDefaultTtl; | |
1366 | Config.Http.maxObjSize = DefaultHttpMaxObjSize; | |
090089c4 | 1367 | Config.Wais.defaultTtl = DefaultWaisDefaultTtl; |
1368 | Config.Wais.maxObjSize = DefaultWaisMaxObjSize; | |
1369 | Config.Wais.relayHost = safe_xstrdup(DefaultWaisRelayHost); | |
1370 | Config.Wais.relayPort = DefaultWaisRelayPort; | |
090089c4 | 1371 | |
1372 | Config.negativeTtl = DefaultNegativeTtl; | |
2639dac6 | 1373 | Config.negativeDnsTtl = DefaultNegativeDnsTtl; |
1374 | Config.positiveDnsTtl = DefaultPositiveDnsTtl; | |
090089c4 | 1375 | Config.readTimeout = DefaultReadTimeout; |
1376 | Config.lifetimeDefault = DefaultLifetimeDefault; | |
605ba5ca | 1377 | Config.lifetimeShutdown = DefaultLifetimeShutdown; |
fa966b74 | 1378 | Config.maxRequestSize = DefaultMaxRequestSize; |
090089c4 | 1379 | Config.connectTimeout = DefaultConnectTimeout; |
1380 | Config.ageMaxDefault = DefaultDefaultAgeMax; | |
1381 | Config.cleanRate = DefaultCleanRate; | |
1382 | Config.dnsChildren = DefaultDnsChildren; | |
d2af9477 | 1383 | Config.redirectChildren = DefaultRedirectChildren; |
090089c4 | 1384 | Config.hotVmFactor = DefaultHotVmFactor; |
1385 | Config.sourcePing = DefaultSourcePing; | |
1386 | Config.quickAbort = DefaultQuickAbort; | |
1387 | Config.commonLogFormat = DefaultCommonLogFormat; | |
12b9e9b1 | 1388 | Config.debugOptions = safe_xstrdup(DefaultDebugOptions); |
090089c4 | 1389 | Config.neighborTimeout = DefaultNeighborTimeout; |
e5c22962 | 1390 | Config.stallDelay = DefaultStallDelay; |
090089c4 | 1391 | Config.singleParentBypass = DefaultSingleParentBypass; |
1392 | Config.adminEmail = safe_xstrdup(DefaultAdminEmail); | |
1393 | Config.effectiveUser = safe_xstrdup(DefaultEffectiveUser); | |
1394 | Config.effectiveGroup = safe_xstrdup(DefaultEffectiveGroup); | |
1395 | Config.appendDomain = safe_xstrdup(DefaultAppendDomain); | |
1396 | ||
30a4f2a8 | 1397 | Config.Port.http = DefaultHttpPortNum; |
1398 | Config.Port.icp = DefaultIcpPortNum; | |
090089c4 | 1399 | Config.Log.log = safe_xstrdup(DefaultCacheLogFile); |
1400 | Config.Log.access = safe_xstrdup(DefaultAccessLogFile); | |
d8b45066 | 1401 | Config.Log.store = safe_xstrdup(DefaultStoreLogFile); |
090089c4 | 1402 | Config.Log.rotateNumber = DefaultLogRotateNumber; |
1403 | Config.Program.ftpget = safe_xstrdup(DefaultFtpgetProgram); | |
1404 | Config.Program.ftpget_opts = safe_xstrdup(DefaultFtpgetOptions); | |
1405 | Config.Program.dnsserver = safe_xstrdup(DefaultDnsserverProgram); | |
d2af9477 | 1406 | Config.Program.redirect = safe_xstrdup(DefaultRedirectProgram); |
090089c4 | 1407 | Config.Accel.host = safe_xstrdup(DefaultAccelHost); |
1408 | Config.Accel.prefix = safe_xstrdup(DefaultAccelPrefix); | |
1409 | Config.Accel.port = DefaultAccelPort; | |
1410 | Config.Accel.withProxy = DefaultAccelWithProxy; | |
ccff9601 | 1411 | Config.pidFilename = safe_xstrdup(DefaultPidFilename); |
cf5fd929 | 1412 | Config.visibleHostname = safe_xstrdup(DefaultVisibleHostname); |
fb263c4c | 1413 | Config.ftpUser = safe_xstrdup(DefaultFtpUser); |
7d49daab | 1414 | Config.Announce.host = safe_xstrdup(DefaultAnnounceHost); |
1415 | Config.Announce.port = DefaultAnnouncePort; | |
1416 | Config.Announce.file = safe_xstrdup(DefaultAnnounceFile); | |
1417 | Config.Announce.rate = DefaultAnnounceRate; | |
7813c6d5 | 1418 | Config.tcpRcvBufsz = DefaultTcpRcvBufsz; |
30a4f2a8 | 1419 | Config.Addrs.tcp_outgoing.s_addr = DefaultTcpOutgoingAddr; |
1420 | Config.Addrs.tcp_incoming.s_addr = DefaultTcpIncomingAddr; | |
1421 | Config.Addrs.udp_outgoing.s_addr = DefaultUdpOutgoingAddr; | |
1422 | Config.Addrs.udp_incoming.s_addr = DefaultUdpIncomingAddr; | |
844327e4 | 1423 | Config.Addrs.client_netmask.s_addr = DefaultClientNetmask; |
98ffb7e4 | 1424 | Config.sslProxy.port = DefaultSslProxyPort; |
1425 | Config.sslProxy.host = safe_xstrdup(DefaultSslProxyHost); | |
090089c4 | 1426 | } |
1427 | ||
1428 | static void configDoConfigure() | |
1429 | { | |
1430 | httpd_accel_mode = Config.Accel.prefix ? 1 : 0; | |
30a4f2a8 | 1431 | sprintf(ForwardedBy, "Forwarded: by http://%s:%d/", |
b6f794d6 | 1432 | getMyHostname(), Config.Port.http); |
090089c4 | 1433 | |
1434 | #if !ALLOW_HOT_CACHE | |
1435 | if (!httpd_accel_mode || Config.Accel.withProxy) { | |
1436 | /* Not running strict httpd_accel--force hot_vm_factor to be 0 */ | |
1437 | if (Config.hotVmFactor != 0.0) { | |
1438 | printf("WARNING: Non-zero hot_vm_factor not allowed unless running only\n"); | |
1439 | printf(" in httpd_accel mode. Setting hot_vm_factor to 0.\n"); | |
1440 | Config.hotVmFactor = 0.0; | |
1441 | } | |
1442 | } | |
1443 | #endif /* !ALLOW_HOT_CACHE */ | |
1444 | } |