4 * DEBUG: section 03 Configuration File Parsing
5 * AUTHOR: Harvest Derived
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
38 #include "acl/Gadgets.h"
39 #include "acl/MethodData.h"
41 #include "adaptation/Config.h"
44 #include "adaptation/icap/Config.h"
47 #include "adaptation/ecap/Config.h"
49 #include "auth/Config.h"
50 #include "auth/Scheme.h"
51 #include "CacheManager.h"
52 #include "ConfigParser.h"
53 #include "eui/Config.h"
55 #include "esi/Parser.h"
57 #include "HttpRequestMethod.h"
58 #include "ident/Config.h"
59 #include "ip/Intercept.h"
60 #include "ip/QosConfig.h"
61 #include "log/Config.h"
64 #include "ProtoPort.h"
70 #include "StoreFileSystem.h"
79 static void parse_adaptation_service_set_type();
80 static void parse_adaptation_service_chain_type();
81 static void parse_adaptation_access_type();
85 static void parse_icap_service_type(Adaptation::Icap::Config
*);
86 static void dump_icap_service_type(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
87 static void free_icap_service_type(Adaptation::Icap::Config
*);
88 static void parse_icap_class_type();
89 static void parse_icap_access_type();
91 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*);
92 static void dump_icap_service_failure_limit(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
93 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*);
97 static void parse_ecap_service_type(Adaptation::Ecap::Config
*);
98 static void dump_ecap_service_type(StoreEntry
*, const char *, const Adaptation::Ecap::Config
&);
99 static void free_ecap_service_type(Adaptation::Ecap::Config
*);
104 static const char *const T_SECOND_STR
= "second";
105 static const char *const T_MINUTE_STR
= "minute";
106 static const char *const T_HOUR_STR
= "hour";
107 static const char *const T_DAY_STR
= "day";
108 static const char *const T_WEEK_STR
= "week";
109 static const char *const T_FORTNIGHT_STR
= "fortnight";
110 static const char *const T_MONTH_STR
= "month";
111 static const char *const T_YEAR_STR
= "year";
112 static const char *const T_DECADE_STR
= "decade";
114 static const char *const B_BYTES_STR
= "bytes";
115 static const char *const B_KBYTES_STR
= "KB";
116 static const char *const B_MBYTES_STR
= "MB";
117 static const char *const B_GBYTES_STR
= "GB";
119 static const char *const list_sep
= ", \t\n\r";
121 static void parse_logformat(logformat
** logformat_definitions
);
122 static void parse_access_log(customlog
** customlog_definitions
);
123 static int check_null_access_log(customlog
*customlog_definitions
);
125 static void dump_logformat(StoreEntry
* entry
, const char *name
, logformat
* definitions
);
126 static void dump_access_log(StoreEntry
* entry
, const char *name
, customlog
* definitions
);
127 static void free_logformat(logformat
** definitions
);
128 static void free_access_log(customlog
** definitions
);
130 static void update_maxobjsize(void);
131 static void configDoConfigure(void);
132 static void parse_refreshpattern(refresh_t
**);
133 static int parseTimeUnits(const char *unit
);
134 static void parseTimeLine(time_t * tptr
, const char *units
);
135 static void parse_ushort(u_short
* var
);
136 static void parse_string(char **);
137 static void default_all(void);
138 static void defaults_if_none(void);
139 static int parse_line(char *);
140 static void parseBytesLine(size_t * bptr
, const char *units
);
141 static size_t parseBytesUnits(const char *unit
);
142 static void free_all(void);
143 void requirePathnameExists(const char *name
, const char *path
);
144 static OBJH dump_config
;
146 static void dump_http_header_access(StoreEntry
* entry
, const char *name
, header_mangler header
[]);
147 static void parse_http_header_access(header_mangler header
[]);
148 static void free_http_header_access(header_mangler header
[]);
149 static void dump_http_header_replace(StoreEntry
* entry
, const char *name
, header_mangler header
[]);
150 static void parse_http_header_replace(header_mangler
* header
);
151 static void free_http_header_replace(header_mangler
* header
);
153 static void parse_denyinfo(acl_deny_info_list
** var
);
154 static void dump_denyinfo(StoreEntry
* entry
, const char *name
, acl_deny_info_list
* var
);
155 static void free_denyinfo(acl_deny_info_list
** var
);
158 static void parse_IpAddress_list(Ip::Address_list
**);
159 static void dump_IpAddress_list(StoreEntry
*, const char *, const Ip::Address_list
*);
160 static void free_IpAddress_list(Ip::Address_list
**);
162 static int check_null_IpAddress_list(const Ip::Address_list
*);
163 #endif /* CURRENTLY_UNUSED */
164 #endif /* USE_WCCPv2 */
166 static void parse_http_port_list(http_port_list
**);
167 static void dump_http_port_list(StoreEntry
*, const char *, const http_port_list
*);
168 static void free_http_port_list(http_port_list
**);
171 static void parse_https_port_list(https_port_list
**);
172 static void dump_https_port_list(StoreEntry
*, const char *, const https_port_list
*);
173 static void free_https_port_list(https_port_list
**);
175 static int check_null_https_port_list(const https_port_list
*);
179 static void parse_b_size_t(size_t * var
);
180 static void parse_b_int64_t(int64_t * var
);
182 static int parseOneConfigFile(const char *file_name
, unsigned int depth
);
185 * LegacyParser is a parser for legacy code that uses the global
186 * approach. This is static so that it is only exposed to cache_cf.
187 * Other modules needing access to a ConfigParser should have it
188 * provided to them in their parserFOO methods.
190 static ConfigParser LegacyParser
= ConfigParser();
195 LegacyParser
.destruct();
199 update_maxobjsize(void)
204 for (i
= 0; i
< Config
.cacheSwap
.n_configured
; i
++) {
205 assert (Config
.cacheSwap
.swapDirs
[i
].getRaw());
207 if (dynamic_cast<SwapDir
*>(Config
.cacheSwap
.swapDirs
[i
].getRaw())->
209 ms
= dynamic_cast<SwapDir
*>(Config
.cacheSwap
.swapDirs
[i
].getRaw())->max_objsize
;
211 store_maxobjsize
= ms
;
215 SetConfigFilename(char const *file_name
, bool is_pipe
)
217 cfg_filename
= file_name
;
222 cfg_filename
= file_name
+ 1;
223 else if ((token
= strrchr(cfg_filename
, '/')))
224 cfg_filename
= token
+ 1;
228 skip_ws(const char* s
)
237 parseManyConfigFiles(char* files
, int depth
)
240 char* saveptr
= NULL
;
245 memset(&globbuf
, 0, sizeof(globbuf
));
246 for (path
= strwordtok(files
, &saveptr
); path
; path
= strwordtok(NULL
, &saveptr
)) {
247 if (glob(path
, globbuf
.gl_pathc
? GLOB_APPEND
: 0, NULL
, &globbuf
) != 0) {
248 fatalf("Unable to find configuration file: %s: %s",
252 for (i
= 0; i
< (int)globbuf
.gl_pathc
; i
++) {
253 error_count
+= parseOneConfigFile(globbuf
.gl_pathv
[i
], depth
);
257 char* file
= strwordtok(files
, &saveptr
);
258 while (file
!= NULL
) {
259 error_count
+= parseOneConfigFile(file
, depth
);
260 file
= strwordtok(NULL
, &saveptr
);
262 #endif /* HAVE_GLOB */
267 parseOneConfigFile(const char *file_name
, unsigned int depth
)
270 const char *orig_cfg_filename
= cfg_filename
;
271 const int orig_config_lineno
= config_lineno
;
273 char *tmp_line
= NULL
;
274 int tmp_line_len
= 0;
278 debugs(3, 1, "Processing Configuration File: " << file_name
<< " (depth " << depth
<< ")");
280 fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name
);
284 if (file_name
[0] == '!' || file_name
[0] == '|') {
285 fp
= popen(file_name
+ 1, "r");
288 fp
= fopen(file_name
, "r");
292 fatalf("Unable to open configuration file: %s: %s", file_name
, xstrerror());
296 setmode(fileno(fp
), O_TEXT
);
300 SetConfigFilename(file_name
, bool(is_pipe
));
302 memset(config_input_line
, '\0', BUFSIZ
);
306 while (fgets(config_input_line
, BUFSIZ
, fp
)) {
309 if ((token
= strchr(config_input_line
, '\n')))
312 if ((token
= strchr(config_input_line
, '\r')))
315 if (strncmp(config_input_line
, "#line ", 6) == 0) {
316 static char new_file_name
[1024];
318 static char new_lineno
;
319 token
= config_input_line
+ 6;
320 new_lineno
= strtol(token
, &file
, 0) - 1;
323 continue; /* Not a valid #line directive, may be a comment */
325 while (*file
&& xisspace((unsigned char) *file
))
330 continue; /* Not a valid #line directive, may be a comment */
332 xstrncpy(new_file_name
, file
+ 1, sizeof(new_file_name
));
334 if ((token
= strchr(new_file_name
, '"')))
337 cfg_filename
= new_file_name
;
340 config_lineno
= new_lineno
;
343 if (config_input_line
[0] == '#')
346 if (config_input_line
[0] == '\0')
349 const char* append
= tmp_line_len
? skip_ws(config_input_line
) : config_input_line
;
351 size_t append_len
= strlen(append
);
353 tmp_line
= (char*)xrealloc(tmp_line
, tmp_line_len
+ append_len
+ 1);
355 strcpy(tmp_line
+ tmp_line_len
, append
);
357 tmp_line_len
+= append_len
;
359 if (tmp_line
[tmp_line_len
-1] == '\\') {
360 debugs(3, 5, "parseConfigFile: tmp_line='" << tmp_line
<< "'");
361 tmp_line
[--tmp_line_len
] = '\0';
365 debugs(3, 5, "Processing: '" << tmp_line
<< "'");
367 /* Handle includes here */
368 if (tmp_line_len
>= 9 && strncmp(tmp_line
, "include", 7) == 0 && xisspace(tmp_line
[7])) {
369 err_count
+= parseManyConfigFiles(tmp_line
+ 8, depth
+ 1);
370 } else if (!parse_line(tmp_line
)) {
371 debugs(3, 0, HERE
<< cfg_filename
<< ":" << config_lineno
<< " unrecognized: '" << tmp_line
<< "'");
381 int ret
= pclose(fp
);
384 fatalf("parseConfigFile: '%s' failed with exit code %d\n", file_name
, ret
);
389 cfg_filename
= orig_cfg_filename
;
390 config_lineno
= orig_config_lineno
;
396 parseConfigFile(const char *file_name
)
399 CacheManager
*manager
=CacheManager::GetInstance();
405 ACLMethodData::ThePurgeCount
= 0;
408 err_count
= parseOneConfigFile(file_name
, 0);
413 * We must call configDoConfigure() before leave_suid() because
414 * configDoConfigure() is where we turn username strings into
419 if (!Config
.chroot_dir
) {
421 setUmask(Config
.umask
);
422 _db_init(Debug::cache_log
, Debug::debugOptions
);
426 if (opt_send_signal
== -1) {
427 manager
->registerAction("config",
428 "Current Squid Configuration",
438 configDoConfigure(void)
440 memset(&Config2
, '\0', sizeof(SquidConfig2
));
441 /* init memory as early as possible */
445 if (Config
.cacheSwap
.swapDirs
== NULL
) {
446 /* Memory-only cache probably in effect. */
447 /* turn off the cache rebuild delays... */
448 StoreController::store_dirs_rebuilding
= 0;
451 if (Debug::rotateNumber
< 0) {
452 Debug::rotateNumber
= Config
.Log
.rotateNumber
;
455 #if SIZEOF_OFF_T <= 4
456 if (Config
.Store
.maxObjectSize
> 0x7FFF0000) {
457 debugs(3, 0, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB");
458 Config
.Store
.maxObjectSize
= 0x7FFF0000;
461 if (0 == Store::Root().maxSize())
462 /* people might want a zero-sized cache on purpose */
464 else if (Store::Root().maxSize() < (Config
.memMaxSize
>> 10))
465 /* This is bogus. folk with NULL caches will want this */
466 debugs(3, 0, "WARNING cache_mem is larger than total disk cache space!");
468 if (Config
.Announce
.period
> 0) {
469 Config
.onoff
.announce
= 1;
470 } else if (Config
.Announce
.period
< 1) {
471 Config
.Announce
.period
= 86400 * 365; /* one year */
472 Config
.onoff
.announce
= 0;
475 if (Config
.onoff
.httpd_suppress_version_string
)
476 visible_appname_string
= (char *)appname_string
;
478 visible_appname_string
= (char const *)APP_FULLNAME
;
482 if (Config
.dnsChildren
.n_max
< 1)
483 fatal("No dnsservers allocated");
487 if (Config
.Program
.redirect
) {
488 if (Config
.redirectChildren
.n_max
< 1) {
489 Config
.redirectChildren
.n_max
= 0;
490 wordlistDestroy(&Config
.Program
.redirect
);
494 if (Config
.appendDomain
)
495 if (*Config
.appendDomain
!= '.')
496 fatal("append_domain must begin with a '.'");
498 if (Config
.errHtmlText
== NULL
)
499 Config
.errHtmlText
= xstrdup(null_string
);
503 snprintf(ThisCache
, sizeof(ThisCache
), "%s (%s)",
505 visible_appname_string
);
508 * the extra space is for loop detection in client_side.c -- we search
509 * for substrings in the Via header.
511 snprintf(ThisCache2
, sizeof(ThisCache
), " %s (%s)",
513 visible_appname_string
);
515 /* Use visible_hostname as default surrogate_id */
516 if (!Config
.Accel
.surrogate_id
) {
517 const char *t
= getMyHostname();
518 Config
.Accel
.surrogate_id
= xstrdup( (t
?t
:"unset-id") );
521 if (!Config
.udpMaxHitObjsz
|| Config
.udpMaxHitObjsz
> SQUID_UDP_SO_SNDBUF
)
522 Config
.udpMaxHitObjsz
= SQUID_UDP_SO_SNDBUF
;
524 if (Config
.appendDomain
)
525 Config
.appendDomainLen
= strlen(Config
.appendDomain
);
527 Config
.appendDomainLen
= 0;
529 if (Config
.retry
.maxtries
> 10)
530 fatal("maximum_single_addr_tries cannot be larger than 10");
532 if (Config
.retry
.maxtries
< 1) {
533 debugs(3, 0, "WARNING: resetting 'maximum_single_addr_tries to 1");
534 Config
.retry
.maxtries
= 1;
537 requirePathnameExists("MIME Config Table", Config
.mimeTablePathname
);
540 requirePathnameExists("cache_dns_program", Config
.Program
.dnsserver
);
544 requirePathnameExists("unlinkd_program", Config
.Program
.unlinkd
);
546 requirePathnameExists("logfile_daemon", Log::TheConfig
.logfile_daemon
);
547 if (Config
.Program
.redirect
)
548 requirePathnameExists("redirect_program", Config
.Program
.redirect
->key
);
550 requirePathnameExists("Icon Directory", Config
.icons
.directory
);
552 if (Config
.errorDirectory
)
553 requirePathnameExists("Error Directory", Config
.errorDirectory
);
560 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
561 if (!R
->flags
.override_expire
)
564 debugs(22, 1, "WARNING: use of 'override-expire' in 'refresh_pattern' violates HTTP");
569 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
570 if (!R
->flags
.override_lastmod
)
573 debugs(22, 1, "WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP");
578 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
579 if (!R
->flags
.reload_into_ims
)
582 debugs(22, 1, "WARNING: use of 'reload-into-ims' in 'refresh_pattern' violates HTTP");
587 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
588 if (!R
->flags
.ignore_reload
)
591 debugs(22, 1, "WARNING: use of 'ignore-reload' in 'refresh_pattern' violates HTTP");
596 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
597 if (!R
->flags
.ignore_no_cache
)
600 debugs(22, 1, "WARNING: use of 'ignore-no-cache' in 'refresh_pattern' violates HTTP");
605 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
606 if (!R
->flags
.ignore_no_store
)
609 debugs(22, 1, "WARNING: use of 'ignore-no-store' in 'refresh_pattern' violates HTTP");
614 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
615 if (!R
->flags
.ignore_must_revalidate
)
617 debugs(22, 1, "WARNING: use of 'ignore-must-revalidate' in 'refresh_pattern' violates HTTP");
621 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
622 if (!R
->flags
.ignore_private
)
625 debugs(22, 1, "WARNING: use of 'ignore-private' in 'refresh_pattern' violates HTTP");
630 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
631 if (!R
->flags
.ignore_auth
)
634 debugs(22, 1, "WARNING: use of 'ignore-auth' in 'refresh_pattern' violates HTTP");
642 Config
.onoff
.via
= 1;
645 if (!Config
.onoff
.via
)
646 debugs(22, 1, "WARNING: HTTP requires the use of Via");
650 // we enable runtime PURGE checks if there is at least one PURGE method ACL
651 // TODO: replace with a dedicated "purge" ACL option?
652 Config2
.onoff
.enable_purge
= (ACLMethodData::ThePurgeCount
> 0);
654 Config2
.onoff
.mangle_request_headers
= httpReqHdrManglersConfigured();
656 if (geteuid() == 0) {
657 if (NULL
!= Config
.effectiveUser
) {
659 struct passwd
*pwd
= getpwnam(Config
.effectiveUser
);
663 * Andres Kroonmaa <andre@online.ee>:
664 * Some getpwnam() implementations (Solaris?) require
665 * an available FD < 256 for opening a FILE* to the
668 * This should be safe at startup, but might still fail
669 * during reconfigure.
671 fatalf("getpwnam failed to find userid for effective user '%s'",
672 Config
.effectiveUser
);
676 Config2
.effectiveUserID
= pwd
->pw_uid
;
678 Config2
.effectiveGroupID
= pwd
->pw_gid
;
682 if (pwd
->pw_dir
&& *pwd
->pw_dir
) {
684 char *env_str
= (char *)xcalloc((len
= strlen(pwd
->pw_dir
) + 6), 1);
685 snprintf(env_str
, len
, "HOME=%s", pwd
->pw_dir
);
693 Config2
.effectiveUserID
= geteuid();
694 Config2
.effectiveGroupID
= getegid();
697 if (NULL
!= Config
.effectiveGroup
) {
699 struct group
*grp
= getgrnam(Config
.effectiveGroup
);
702 fatalf("getgrnam failed to find groupid for effective group '%s'",
703 Config
.effectiveGroup
);
707 Config2
.effectiveGroupID
= grp
->gr_gid
;
710 HttpRequestMethod::Configure(Config
);
713 debugs(3, 1, "Initializing https proxy context");
715 Config
.ssl_client
.sslContext
= sslCreateClientContext(Config
.ssl_client
.cert
, Config
.ssl_client
.key
, Config
.ssl_client
.version
, Config
.ssl_client
.cipher
, Config
.ssl_client
.options
, Config
.ssl_client
.flags
, Config
.ssl_client
.cafile
, Config
.ssl_client
.capath
, Config
.ssl_client
.crlfile
);
721 for (p
= Config
.peers
; p
!= NULL
; p
= p
->next
) {
723 debugs(3, 1, "Initializing cache_peer " << p
->name
<< " SSL context");
724 p
->sslContext
= sslCreateClientContext(p
->sslcert
, p
->sslkey
, p
->sslversion
, p
->sslcipher
, p
->ssloptions
, p
->sslflags
, p
->sslcafile
, p
->sslcapath
, p
->sslcrlfile
);
733 for (s
= Config
.Sockaddr
.http
; s
!= NULL
; s
= (http_port_list
*) s
->next
) {
734 if (!s
->cert
&& !s
->key
)
737 debugs(3, 1, "Initializing http_port " << s
->http
.s
<< " SSL context");
739 s
->sslContext
= sslCreateServerContext(s
->cert
, s
->key
, s
->version
, s
->cipher
, s
->options
, s
->sslflags
, s
->clientca
, s
->cafile
, s
->capath
, s
->crlfile
, s
->dhfile
, s
->sslcontext
);
747 for (s
= Config
.Sockaddr
.https
; s
!= NULL
; s
= (https_port_list
*) s
->http
.next
) {
748 debugs(3, 1, "Initializing https_port " << s
->http
.s
<< " SSL context");
750 s
->sslContext
= sslCreateServerContext(s
->cert
, s
->key
, s
->version
, s
->cipher
, s
->options
, s
->sslflags
, s
->clientca
, s
->cafile
, s
->capath
, s
->crlfile
, s
->dhfile
, s
->sslcontext
);
757 /* Parse a time specification from the config file. Store the
758 * result in 'tptr', after converting it to 'units' */
760 parseTimeLine(time_t * tptr
, const char *units
)
767 if ((u
= parseTimeUnits(units
)) == 0)
770 if ((token
= strtok(NULL
, w_space
)) == NULL
)
775 m
= u
; /* default to 'units' if none specified */
779 else if ((token
= strtok(NULL
, w_space
)) == NULL
)
780 debugs(3, 0, "WARNING: No units on '" <<
781 config_input_line
<< "', assuming " <<
783 else if ((m
= parseTimeUnits(token
)) == 0)
786 *tptr
= static_cast<time_t> (m
* d
/ u
);
790 parseTimeUnits(const char *unit
)
792 if (!strncasecmp(unit
, T_SECOND_STR
, strlen(T_SECOND_STR
)))
795 if (!strncasecmp(unit
, T_MINUTE_STR
, strlen(T_MINUTE_STR
)))
798 if (!strncasecmp(unit
, T_HOUR_STR
, strlen(T_HOUR_STR
)))
801 if (!strncasecmp(unit
, T_DAY_STR
, strlen(T_DAY_STR
)))
804 if (!strncasecmp(unit
, T_WEEK_STR
, strlen(T_WEEK_STR
)))
807 if (!strncasecmp(unit
, T_FORTNIGHT_STR
, strlen(T_FORTNIGHT_STR
)))
810 if (!strncasecmp(unit
, T_MONTH_STR
, strlen(T_MONTH_STR
)))
813 if (!strncasecmp(unit
, T_YEAR_STR
, strlen(T_YEAR_STR
)))
814 return static_cast<int>(86400 * 365.2522);
816 if (!strncasecmp(unit
, T_DECADE_STR
, strlen(T_DECADE_STR
)))
817 return static_cast<int>(86400 * 365.2522 * 10);
819 debugs(3, 1, "parseTimeUnits: unknown time unit '" << unit
<< "'");
825 parseBytesLine64(int64_t * bptr
, const char *units
)
832 if ((u
= parseBytesUnits(units
)) == 0) {
837 if ((token
= strtok(NULL
, w_space
)) == NULL
) {
842 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
849 m
= u
; /* default to 'units' if none specified */
853 else if ((token
= strtok(NULL
, w_space
)) == NULL
)
854 debugs(3, 0, "WARNING: No units on '" <<
855 config_input_line
<< "', assuming " <<
857 else if ((m
= parseBytesUnits(token
)) == 0) {
862 *bptr
= static_cast<int64_t>(m
* d
/ u
);
864 if (static_cast<double>(*bptr
) * 2 != m
* d
/ u
* 2)
870 parseBytesLine(size_t * bptr
, const char *units
)
877 if ((u
= parseBytesUnits(units
)) == 0) {
882 if ((token
= strtok(NULL
, w_space
)) == NULL
) {
887 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
888 *bptr
= static_cast<size_t>(-1);
894 m
= u
; /* default to 'units' if none specified */
898 else if ((token
= strtok(NULL
, w_space
)) == NULL
)
899 debugs(3, 0, "WARNING: No units on '" <<
900 config_input_line
<< "', assuming " <<
902 else if ((m
= parseBytesUnits(token
)) == 0) {
907 *bptr
= static_cast<size_t>(m
* d
/ u
);
909 if (static_cast<double>(*bptr
) * 2 != m
* d
/ u
* 2)
914 parseBytesUnits(const char *unit
)
916 if (!strncasecmp(unit
, B_BYTES_STR
, strlen(B_BYTES_STR
)))
919 if (!strncasecmp(unit
, B_KBYTES_STR
, strlen(B_KBYTES_STR
)))
922 if (!strncasecmp(unit
, B_MBYTES_STR
, strlen(B_MBYTES_STR
)))
925 if (!strncasecmp(unit
, B_GBYTES_STR
, strlen(B_GBYTES_STR
)))
928 debugs(3, DBG_CRITICAL
, "WARNING: Unknown bytes unit '" << unit
<< "'");
933 /*****************************************************************************
935 *****************************************************************************/
938 dump_acl(StoreEntry
* entry
, const char *name
, ACL
* ae
)
944 debugs(3, 3, "dump_acl: " << name
<< " " << ae
->name
);
945 storeAppendPrintf(entry
, "%s %s %s ",
952 debugs(3, 3, "dump_acl: " << name
<< " " << ae
->name
<< " " << v
->key
);
953 storeAppendPrintf(entry
, "%s ", v
->key
);
957 storeAppendPrintf(entry
, "\n");
966 ACL::ParseAclLine(LegacyParser
, ae
);
976 dump_acl_list(StoreEntry
* entry
, ACLList
* head
)
980 for (l
= head
; l
; l
= l
->next
) {
981 storeAppendPrintf(entry
, " %s%s",
982 l
->op
? null_string
: "!",
988 dump_acl_access(StoreEntry
* entry
, const char *name
, acl_access
* head
)
992 for (l
= head
; l
; l
= l
->next
) {
993 storeAppendPrintf(entry
, "%s %s",
995 l
->allow
? "Allow" : "Deny");
996 dump_acl_list(entry
, l
->aclList
);
997 storeAppendPrintf(entry
, "\n");
1002 parse_acl_access(acl_access
** head
)
1004 aclParseAccessLine(LegacyParser
, head
);
1008 free_acl_access(acl_access
** head
)
1010 aclDestroyAccessList(head
);
1014 dump_address(StoreEntry
* entry
, const char *name
, Ip::Address
&addr
)
1016 char buf
[MAX_IPSTRLEN
];
1017 storeAppendPrintf(entry
, "%s %s\n", name
, addr
.NtoA(buf
,MAX_IPSTRLEN
) );
1021 parse_address(Ip::Address
*addr
)
1023 char *token
= strtok(NULL
, w_space
);
1030 if (!strcmp(token
,"any_addr")) {
1033 } else if ( (!strcmp(token
,"no_addr")) || (!strcmp(token
,"full_mask")) ) {
1041 free_address(Ip::Address
*addr
)
1046 CBDATA_TYPE(acl_address
);
1049 dump_acl_address(StoreEntry
* entry
, const char *name
, acl_address
* head
)
1051 char buf
[MAX_IPSTRLEN
];
1054 for (l
= head
; l
; l
= l
->next
) {
1055 if (!l
->addr
.IsAnyAddr())
1056 storeAppendPrintf(entry
, "%s %s", name
, l
->addr
.NtoA(buf
,MAX_IPSTRLEN
));
1058 storeAppendPrintf(entry
, "%s autoselect", name
);
1060 dump_acl_list(entry
, l
->aclList
);
1062 storeAppendPrintf(entry
, "\n");
1067 freed_acl_address(void *data
)
1069 acl_address
*l
= static_cast<acl_address
*>(data
);
1070 aclDestroyAclList(&l
->aclList
);
1074 parse_acl_address(acl_address
** head
)
1077 acl_address
**tail
= head
; /* sane name below */
1078 CBDATA_INIT_TYPE_FREECB(acl_address
, freed_acl_address
);
1079 l
= cbdataAlloc(acl_address
);
1080 parse_address(&l
->addr
);
1081 aclParseAclList(LegacyParser
, &l
->aclList
);
1084 tail
= &(*tail
)->next
;
1090 free_acl_address(acl_address
** head
)
1093 acl_address
*l
= *head
;
1099 CBDATA_TYPE(acl_tos
);
1102 dump_acl_tos(StoreEntry
* entry
, const char *name
, acl_tos
* head
)
1106 for (l
= head
; l
; l
= l
->next
) {
1108 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->tos
);
1110 storeAppendPrintf(entry
, "%s none", name
);
1112 dump_acl_list(entry
, l
->aclList
);
1114 storeAppendPrintf(entry
, "\n");
1119 freed_acl_tos(void *data
)
1121 acl_tos
*l
= static_cast<acl_tos
*>(data
);
1122 aclDestroyAclList(&l
->aclList
);
1126 parse_acl_tos(acl_tos
** head
)
1129 acl_tos
**tail
= head
; /* sane name below */
1132 char *token
= strtok(NULL
, w_space
);
1139 if (sscanf(token
, "0x%x%c", &tos
, &junk
) != 1) {
1144 if (tos
< 0 || tos
> 255) {
1149 CBDATA_INIT_TYPE_FREECB(acl_tos
, freed_acl_tos
);
1151 l
= cbdataAlloc(acl_tos
);
1155 aclParseAclList(LegacyParser
, &l
->aclList
);
1158 tail
= &(*tail
)->next
;
1164 free_acl_tos(acl_tos
** head
)
1174 CBDATA_TYPE(acl_size_t
);
1177 dump_acl_b_size_t(StoreEntry
* entry
, const char *name
, acl_size_t
* head
)
1181 for (l
= head
; l
; l
= l
->next
) {
1183 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) l
->size
, B_BYTES_STR
);
1185 storeAppendPrintf(entry
, "%s none", name
);
1187 dump_acl_list(entry
, l
->aclList
);
1189 storeAppendPrintf(entry
, "\n");
1194 freed_acl_b_size_t(void *data
)
1196 acl_size_t
*l
= static_cast<acl_size_t
*>(data
);
1197 aclDestroyAclList(&l
->aclList
);
1201 parse_acl_b_size_t(acl_size_t
** head
)
1204 acl_size_t
**tail
= head
; /* sane name below */
1206 CBDATA_INIT_TYPE_FREECB(acl_size_t
, freed_acl_b_size_t
);
1208 l
= cbdataAlloc(acl_size_t
);
1210 parse_b_int64_t(&l
->size
);
1212 aclParseAclList(LegacyParser
, &l
->aclList
);
1215 tail
= &(*tail
)->next
;
1221 free_acl_b_size_t(acl_size_t
** head
)
1224 acl_size_t
*l
= *head
;
1233 #include "DelayPools.h"
1234 #include "DelayConfig.h"
1235 /* do nothing - free_delay_pool_count is the magic free function.
1236 * this is why delay_pool_count isn't just marked TYPE: ushort
1238 #define free_delay_pool_class(X)
1239 #define free_delay_pool_access(X)
1240 #define free_delay_pool_rates(X)
1241 #define dump_delay_pool_class(X, Y, Z)
1242 #define dump_delay_pool_access(X, Y, Z)
1243 #define dump_delay_pool_rates(X, Y, Z)
1246 free_delay_pool_count(DelayConfig
* cfg
)
1248 cfg
->freePoolCount();
1252 dump_delay_pool_count(StoreEntry
* entry
, const char *name
, DelayConfig
&cfg
)
1254 cfg
.dumpPoolCount (entry
, name
);
1258 parse_delay_pool_count(DelayConfig
* cfg
)
1260 cfg
->parsePoolCount();
1264 parse_delay_pool_class(DelayConfig
* cfg
)
1266 cfg
->parsePoolClass();
1270 parse_delay_pool_rates(DelayConfig
* cfg
)
1272 cfg
->parsePoolRates();
1276 parse_delay_pool_access(DelayConfig
* cfg
)
1278 cfg
->parsePoolAccess(LegacyParser
);
1285 dump_http_header_access(StoreEntry
* entry
, const char *name
, header_mangler header
[])
1289 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1290 if (header
[i
].access_list
!= NULL
) {
1291 storeAppendPrintf(entry
, "%s ", name
);
1292 dump_acl_access(entry
, httpHeaderNameById(i
),
1293 header
[i
].access_list
);
1299 parse_http_header_access(header_mangler header
[])
1304 if ((t
= strtok(NULL
, w_space
)) == NULL
) {
1305 debugs(3, 0, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1306 debugs(3, 0, "parse_http_header_access: missing header name.");
1310 /* Now lookup index of header. */
1311 id
= httpHeaderIdByNameDef(t
, strlen(t
));
1313 if (strcmp(t
, "All") == 0)
1315 else if (strcmp(t
, "Other") == 0)
1317 else if (id
== -1) {
1318 debugs(3, 0, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1319 debugs(3, 0, "parse_http_header_access: unknown header name '" << t
<< "'");
1323 if (id
!= HDR_ENUM_END
) {
1324 parse_acl_access(&header
[id
].access_list
);
1326 char *next_string
= t
+ strlen(t
) - 1;
1328 *(next_string
+ 1) = ' ';
1330 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1331 char *new_string
= xstrdup(next_string
);
1332 strtok(new_string
, w_space
);
1333 parse_acl_access(&header
[i
].access_list
);
1334 safe_free(new_string
);
1340 free_http_header_access(header_mangler header
[])
1344 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1345 free_acl_access(&header
[i
].access_list
);
1350 dump_http_header_replace(StoreEntry
* entry
, const char *name
, header_mangler
1355 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1356 if (NULL
== header
[i
].replacement
)
1359 storeAppendPrintf(entry
, "%s %s %s\n", name
, httpHeaderNameById(i
),
1360 header
[i
].replacement
);
1365 parse_http_header_replace(header_mangler header
[])
1370 if ((t
= strtok(NULL
, w_space
)) == NULL
) {
1371 debugs(3, 0, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1372 debugs(3, 0, "parse_http_header_replace: missing header name.");
1376 /* Now lookup index of header. */
1377 id
= httpHeaderIdByNameDef(t
, strlen(t
));
1379 if (strcmp(t
, "All") == 0)
1381 else if (strcmp(t
, "Other") == 0)
1383 else if (id
== -1) {
1384 debugs(3, 0, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1385 debugs(3, 0, "parse_http_header_replace: unknown header name " << t
<< ".");
1390 if (id
!= HDR_ENUM_END
) {
1391 if (header
[id
].replacement
!= NULL
)
1392 safe_free(header
[id
].replacement
);
1394 header
[id
].replacement
= xstrdup(t
+ strlen(t
) + 1);
1396 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1397 if (header
[i
].replacement
!= NULL
)
1398 safe_free(header
[i
].replacement
);
1400 header
[i
].replacement
= xstrdup(t
+ strlen(t
) + 1);
1406 free_http_header_replace(header_mangler header
[])
1410 for (i
= 0; i
< HDR_ENUM_END
; i
++) {
1411 if (header
[i
].replacement
!= NULL
)
1412 safe_free(header
[i
].replacement
);
1419 dump_cachedir(StoreEntry
* entry
, const char *name
, SquidConfig::_cacheSwap swap
)
1425 for (i
= 0; i
< swap
.n_configured
; i
++) {
1426 s
= dynamic_cast<SwapDir
*>(swap
.swapDirs
[i
].getRaw());
1428 storeAppendPrintf(entry
, "%s %s %s", name
, s
->type(), s
->path
);
1430 storeAppendPrintf(entry
, "\n");
1435 check_null_string(char *s
)
1441 parse_authparam(Auth::authConfig
* config
)
1446 if ((type_str
= strtok(NULL
, w_space
)) == NULL
)
1449 if ((param_str
= strtok(NULL
, w_space
)) == NULL
)
1452 /* find a configuration for the scheme in the currently parsed configs... */
1453 AuthConfig
*schemeCfg
= AuthConfig::Find(type_str
);
1455 if (schemeCfg
== NULL
) {
1456 /* Create a configuration based on the scheme info */
1457 AuthScheme::Pointer theScheme
= AuthScheme::Find(type_str
);
1459 if (theScheme
== NULL
) {
1460 debugs(3, DBG_CRITICAL
, "Parsing Config File: Unknown authentication scheme '" << type_str
<< "'.");
1464 config
->push_back(theScheme
->createConfig());
1465 schemeCfg
= AuthConfig::Find(type_str
);
1466 if (schemeCfg
== NULL
) {
1467 debugs(3, DBG_CRITICAL
, "Parsing Config File: Corruption configuring authentication scheme '" << type_str
<< "'.");
1472 schemeCfg
->parse(schemeCfg
, config
->size(), param_str
);
1476 free_authparam(Auth::authConfig
* cfg
)
1478 /* Wipe the Auth globals and Detach/Destruct component config + state. */
1481 /* remove our pointers to the probably-dead sub-configs */
1482 while (cfg
->size()) {
1486 /* on reconfigure initialize new auth schemes for the new config. */
1487 if (reconfiguring
) {
1493 dump_authparam(StoreEntry
* entry
, const char *name
, authConfig cfg
)
1495 for (authConfig::iterator i
= cfg
.begin(); i
!= cfg
.end(); ++i
)
1496 (*i
)->dump(entry
, name
, (*i
));
1499 /* TODO: just return the object, the # is irrelevant */
1501 find_fstype(char *type
)
1503 for (size_t i
= 0; i
< StoreFileSystem::FileSystems().size(); ++i
)
1504 if (strcasecmp(type
, StoreFileSystem::FileSystems().items
[i
]->type()) == 0)
1511 parse_cachedir(SquidConfig::_cacheSwap
* swap
)
1515 RefCount
<SwapDir
> sd
;
1519 if ((type_str
= strtok(NULL
, w_space
)) == NULL
)
1522 if ((path_str
= strtok(NULL
, w_space
)) == NULL
)
1525 fs
= find_fstype(type_str
);
1530 /* reconfigure existing dir */
1532 for (i
= 0; i
< swap
->n_configured
; i
++) {
1533 assert (swap
->swapDirs
[i
].getRaw());
1535 if ((strcasecmp(path_str
, dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw())->path
)) == 0) {
1536 /* this is specific to on-fs Stores. The right
1537 * way to handle this is probably to have a mapping
1538 * from paths to stores, and have on-fs stores
1539 * register with that, and lookip in that in their
1540 * own setup logic. RBC 20041225. TODO.
1543 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw());
1545 if (sd
->type() != StoreFileSystem::FileSystems().items
[fs
]->type()) {
1546 debugs(3, 0, "ERROR: Can't change type of existing cache_dir " <<
1547 sd
->type() << " " << sd
->path
<< " to " << type_str
<< ". Restart required");
1551 sd
->reconfigure (i
, path_str
);
1553 update_maxobjsize();
1560 if (swap
->n_configured
> 63) {
1561 /* 7 bits, signed */
1562 debugs(3, DBG_CRITICAL
, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle.");
1563 debugs(3, DBG_CRITICAL
, "WARNING: '" << path_str
<< "' is one to many.");
1568 allocate_new_swapdir(swap
);
1570 swap
->swapDirs
[swap
->n_configured
] = StoreFileSystem::FileSystems().items
[fs
]->createSwapDir();
1572 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[swap
->n_configured
].getRaw());
1574 /* parse the FS parameters and options */
1575 sd
->parse(swap
->n_configured
, path_str
);
1577 ++swap
->n_configured
;
1579 /* Update the max object size */
1580 update_maxobjsize();
1584 peer_type_str(const peer_t type
)
1586 const char * result
;
1598 case PEER_MULTICAST
:
1599 result
= "multicast";
1611 dump_peer(StoreEntry
* entry
, const char *name
, peer
* p
)
1615 LOCAL_ARRAY(char, xname
, 128);
1618 storeAppendPrintf(entry
, "%s %s %s %d %d name=%s",
1625 dump_peer_options(entry
, p
);
1627 for (d
= p
->peer_domain
; d
; d
= d
->next
) {
1628 storeAppendPrintf(entry
, "cache_peer_domain %s %s%s\n",
1630 d
->do_ping
? null_string
: "!",
1635 snprintf(xname
, 128, "cache_peer_access %s", p
->name
);
1636 dump_acl_access(entry
, xname
, p
->access
);
1639 for (t
= p
->typelist
; t
; t
= t
->next
) {
1640 storeAppendPrintf(entry
, "neighbor_type_domain %s %s %s\n",
1642 peer_type_str(t
->type
),
1651 * utility function to prevent getservbyname() being called with a numeric value
1652 * on Windows at least it returns garage results.
1655 isUnsignedNumeric(const char *str
, size_t len
)
1657 if (len
< 1) return false;
1659 for (; len
>0 && *str
; str
++, len
--) {
1660 if (! isdigit(*str
))
1667 \param proto 'tcp' or 'udp' for protocol
1668 \returns Port the named service is supposed to be listening on.
1671 GetService(const char *proto
)
1673 struct servent
*port
= NULL
;
1674 /** Parses a port number or service name from the squid.conf */
1675 char *token
= strtok(NULL
, w_space
);
1676 if (token
== NULL
) {
1678 return 0; /* NEVER REACHED */
1680 /** Returns either the service port number from /etc/services */
1681 if ( !isUnsignedNumeric(token
, strlen(token
)) )
1682 port
= getservbyname(token
, proto
);
1684 return ntohs((u_short
)port
->s_port
);
1686 /** Or a numeric translation of the config text. */
1687 return xatos(token
);
1691 \returns Port the named TCP service is supposed to be listening on.
1692 \copydoc GetService(const char *proto)
1697 return GetService("tcp");
1701 \returns Port the named UDP service is supposed to be listening on.
1702 \copydoc GetService(const char *proto)
1707 return GetService("udp");
1711 parse_peer(peer
** head
)
1715 CBDATA_INIT_TYPE_FREECB(peer
, peerDestroy
);
1716 p
= cbdataAlloc(peer
);
1717 p
->http_port
= CACHE_HTTP_PORT
;
1718 p
->icp
.port
= CACHE_ICP_PORT
;
1721 p
->stats
.logged_state
= PEER_ALIVE
;
1723 if ((token
= strtok(NULL
, w_space
)) == NULL
)
1726 p
->host
= xstrdup(token
);
1728 p
->name
= xstrdup(token
);
1730 if ((token
= strtok(NULL
, w_space
)) == NULL
)
1733 p
->type
= parseNeighborType(token
);
1735 if (p
->type
== PEER_MULTICAST
) {
1736 p
->options
.no_digest
= 1;
1737 p
->options
.no_netdb_exchange
= 1;
1740 p
->http_port
= GetTcpService();
1745 p
->icp
.port
= GetUdpService();
1746 p
->connection_auth
= 2; /* auto */
1748 while ((token
= strtok(NULL
, w_space
))) {
1749 if (!strcasecmp(token
, "proxy-only")) {
1750 p
->options
.proxy_only
= 1;
1751 } else if (!strcasecmp(token
, "no-query")) {
1752 p
->options
.no_query
= 1;
1753 } else if (!strcasecmp(token
, "background-ping")) {
1754 p
->options
.background_ping
= 1;
1755 } else if (!strcasecmp(token
, "no-digest")) {
1756 p
->options
.no_digest
= 1;
1757 } else if (!strcasecmp(token
, "no-tproxy")) {
1758 p
->options
.no_tproxy
= 1;
1759 } else if (!strcasecmp(token
, "multicast-responder")) {
1760 p
->options
.mcast_responder
= 1;
1761 #if PEER_MULTICAST_SIBLINGS
1762 } else if (!strcasecmp(token
, "multicast-siblings")) {
1763 p
->options
.mcast_siblings
= 1;
1765 } else if (!strncasecmp(token
, "weight=", 7)) {
1766 p
->weight
= xatoi(token
+ 7);
1767 } else if (!strncasecmp(token
, "basetime=", 9)) {
1768 p
->basetime
= xatoi(token
+ 9);
1769 } else if (!strcasecmp(token
, "closest-only")) {
1770 p
->options
.closest_only
= 1;
1771 } else if (!strncasecmp(token
, "ttl=", 4)) {
1772 p
->mcast
.ttl
= xatoi(token
+ 4);
1774 if (p
->mcast
.ttl
< 0)
1777 if (p
->mcast
.ttl
> 128)
1779 } else if (!strcasecmp(token
, "default")) {
1780 p
->options
.default_parent
= 1;
1781 } else if (!strcasecmp(token
, "round-robin")) {
1782 p
->options
.roundrobin
= 1;
1783 } else if (!strcasecmp(token
, "weighted-round-robin")) {
1784 p
->options
.weighted_roundrobin
= 1;
1787 } else if (!strcasecmp(token
, "htcp")) {
1788 p
->options
.htcp
= 1;
1789 } else if (!strcasecmp(token
, "htcp-oldsquid")) {
1790 p
->options
.htcp
= 1;
1791 p
->options
.htcp_oldsquid
= 1;
1792 } else if (!strcasecmp(token
, "htcp-no-clr")) {
1793 if (p
->options
.htcp_only_clr
)
1794 fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously");
1795 p
->options
.htcp
= 1;
1796 p
->options
.htcp_no_clr
= 1;
1797 } else if (!strcasecmp(token
, "htcp-no-purge-clr")) {
1798 p
->options
.htcp
= 1;
1799 p
->options
.htcp_no_purge_clr
= 1;
1800 } else if (!strcasecmp(token
, "htcp-only-clr")) {
1801 if (p
->options
.htcp_no_clr
)
1802 fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously");
1803 p
->options
.htcp
= 1;
1804 p
->options
.htcp_only_clr
= 1;
1805 } else if (!strcasecmp(token
, "htcp-forward-clr")) {
1806 p
->options
.htcp
= 1;
1807 p
->options
.htcp_forward_clr
= 1;
1810 } else if (!strcasecmp(token
, "no-netdb-exchange")) {
1811 p
->options
.no_netdb_exchange
= 1;
1813 } else if (!strcasecmp(token
, "carp")) {
1814 if (p
->type
!= PEER_PARENT
)
1815 fatalf("parse_peer: non-parent carp peer %s/%d\n", p
->host
, p
->http_port
);
1817 p
->options
.carp
= 1;
1819 } else if (!strcasecmp(token
, "userhash")) {
1820 if (p
->type
!= PEER_PARENT
)
1821 fatalf("parse_peer: non-parent userhash peer %s/%d\n", p
->host
, p
->http_port
);
1823 p
->options
.userhash
= 1;
1825 } else if (!strcasecmp(token
, "sourcehash")) {
1826 if (p
->type
!= PEER_PARENT
)
1827 fatalf("parse_peer: non-parent sourcehash peer %s/%d\n", p
->host
, p
->http_port
);
1829 p
->options
.sourcehash
= 1;
1833 } else if (!strcasecmp(token
, "no-delay")) {
1834 p
->options
.no_delay
= 1;
1837 } else if (!strncasecmp(token
, "login=", 6)) {
1838 p
->login
= xstrdup(token
+ 6);
1839 rfc1738_unescape(p
->login
);
1840 } else if (!strncasecmp(token
, "connect-timeout=", 16)) {
1841 p
->connect_timeout
= xatoi(token
+ 16);
1842 } else if (!strncasecmp(token
, "connect-fail-limit=", 19)) {
1843 p
->connect_fail_limit
= xatoi(token
+ 19);
1844 #if USE_CACHE_DIGESTS
1845 } else if (!strncasecmp(token
, "digest-url=", 11)) {
1846 p
->digest_url
= xstrdup(token
+ 11);
1849 } else if (!strcasecmp(token
, "allow-miss")) {
1850 p
->options
.allow_miss
= 1;
1851 } else if (!strncasecmp(token
, "max-conn=", 9)) {
1852 p
->max_conn
= xatoi(token
+ 9);
1853 } else if (!strcasecmp(token
, "originserver")) {
1854 p
->options
.originserver
= 1;
1855 } else if (!strncasecmp(token
, "name=", 5)) {
1859 p
->name
= xstrdup(token
+ 5);
1860 } else if (!strncasecmp(token
, "forceddomain=", 13)) {
1861 safe_free(p
->domain
);
1864 p
->domain
= xstrdup(token
+ 13);
1868 } else if (strcmp(token
, "ssl") == 0) {
1870 } else if (strncmp(token
, "sslcert=", 8) == 0) {
1871 safe_free(p
->sslcert
);
1872 p
->sslcert
= xstrdup(token
+ 8);
1873 } else if (strncmp(token
, "sslkey=", 7) == 0) {
1874 safe_free(p
->sslkey
);
1875 p
->sslkey
= xstrdup(token
+ 7);
1876 } else if (strncmp(token
, "sslversion=", 11) == 0) {
1877 p
->sslversion
= atoi(token
+ 11);
1878 } else if (strncmp(token
, "ssloptions=", 11) == 0) {
1879 safe_free(p
->ssloptions
);
1880 p
->ssloptions
= xstrdup(token
+ 11);
1881 } else if (strncmp(token
, "sslcipher=", 10) == 0) {
1882 safe_free(p
->sslcipher
);
1883 p
->sslcipher
= xstrdup(token
+ 10);
1884 } else if (strncmp(token
, "sslcafile=", 10) == 0) {
1885 safe_free(p
->sslcafile
);
1886 p
->sslcafile
= xstrdup(token
+ 10);
1887 } else if (strncmp(token
, "sslcapath=", 10) == 0) {
1888 safe_free(p
->sslcapath
);
1889 p
->sslcapath
= xstrdup(token
+ 10);
1890 } else if (strncmp(token
, "sslcrlfile=", 11) == 0) {
1891 safe_free(p
->sslcrlfile
);
1892 p
->sslcapath
= xstrdup(token
+ 10);
1893 } else if (strncmp(token
, "sslflags=", 9) == 0) {
1894 safe_free(p
->sslflags
);
1895 p
->sslflags
= xstrdup(token
+ 9);
1896 } else if (strncmp(token
, "ssldomain=", 10) == 0) {
1897 safe_free(p
->ssldomain
);
1898 p
->ssldomain
= xstrdup(token
+ 10);
1901 } else if (strcmp(token
, "front-end-https") == 0) {
1902 p
->front_end_https
= 1;
1903 } else if (strcmp(token
, "front-end-https=on") == 0) {
1904 p
->front_end_https
= 1;
1905 } else if (strcmp(token
, "front-end-https=auto") == 0) {
1906 p
->front_end_https
= 2;
1907 } else if (strcmp(token
, "connection-auth=off") == 0) {
1908 p
->connection_auth
= 0;
1909 } else if (strcmp(token
, "connection-auth") == 0) {
1910 p
->connection_auth
= 1;
1911 } else if (strcmp(token
, "connection-auth=on") == 0) {
1912 p
->connection_auth
= 1;
1913 } else if (strcmp(token
, "connection-auth=auto") == 0) {
1914 p
->connection_auth
= 2;
1916 debugs(3, 0, "parse_peer: token='" << token
<< "'");
1921 if (peerFindByName(p
->name
))
1922 fatalf("ERROR: cache_peer %s specified twice\n", p
->name
);
1927 if (p
->connect_fail_limit
< 1)
1928 p
->connect_fail_limit
= 10;
1930 p
->icp
.version
= ICP_VERSION_CURRENT
;
1934 #if USE_CACHE_DIGESTS
1936 if (!p
->options
.no_digest
) {
1937 /* XXX This looks odd.. who has the original pointer
1940 PeerDigest
*pd
= peerDigestCreate(p
);
1941 p
->digest
= cbdataReference(pd
);
1946 p
->index
= ++Config
.npeers
;
1948 while (*head
!= NULL
)
1949 head
= &(*head
)->next
;
1957 free_peer(peer
** P
)
1961 while ((p
= *P
) != NULL
) {
1963 #if USE_CACHE_DIGESTS
1965 cbdataReferenceDone(p
->digest
);
1975 dump_cachemgrpasswd(StoreEntry
* entry
, const char *name
, cachemgr_passwd
* list
)
1979 while (list
!= NULL
) {
1980 if (strcmp(list
->passwd
, "none") && strcmp(list
->passwd
, "disable"))
1981 storeAppendPrintf(entry
, "%s XXXXXXXXXX", name
);
1983 storeAppendPrintf(entry
, "%s %s", name
, list
->passwd
);
1985 for (w
= list
->actions
; w
!= NULL
; w
= w
->next
) {
1986 storeAppendPrintf(entry
, " %s", w
->key
);
1989 storeAppendPrintf(entry
, "\n");
1995 parse_cachemgrpasswd(cachemgr_passwd
** head
)
1997 char *passwd
= NULL
;
1998 wordlist
*actions
= NULL
;
2000 cachemgr_passwd
**P
;
2001 parse_string(&passwd
);
2002 parse_wordlist(&actions
);
2003 p
= static_cast<cachemgr_passwd
*>(xcalloc(1, sizeof(cachemgr_passwd
)));
2005 p
->actions
= actions
;
2007 for (P
= head
; *P
; P
= &(*P
)->next
) {
2009 * See if any of the actions from this line already have a
2010 * password from previous lines. The password checking
2011 * routines in cache_manager.c take the the password from
2012 * the first cachemgr_passwd struct that contains the
2013 * requested action. Thus, we should warn users who might
2014 * think they can have two passwords for the same action.
2019 for (w
= (*P
)->actions
; w
; w
= w
->next
) {
2020 for (u
= actions
; u
; u
= u
->next
) {
2021 if (strcmp(w
->key
, u
->key
))
2024 debugs(0, 0, "WARNING: action '" << u
->key
<< "' (line " << config_lineno
<< ") already has a password");
2033 free_cachemgrpasswd(cachemgr_passwd
** head
)
2037 while ((p
= *head
) != NULL
) {
2040 wordlistDestroy(&p
->actions
);
2046 dump_denyinfo(StoreEntry
* entry
, const char *name
, acl_deny_info_list
* var
)
2050 while (var
!= NULL
) {
2051 storeAppendPrintf(entry
, "%s %s", name
, var
->err_page_name
);
2053 for (a
= var
->acl_list
; a
!= NULL
; a
= a
->next
)
2054 storeAppendPrintf(entry
, " %s", a
->name
);
2056 storeAppendPrintf(entry
, "\n");
2063 parse_denyinfo(acl_deny_info_list
** var
)
2065 aclParseDenyInfoLine(var
);
2069 free_denyinfo(acl_deny_info_list
** list
)
2071 acl_deny_info_list
*a
= NULL
;
2072 acl_deny_info_list
*a_next
= NULL
;
2073 acl_name_list
*l
= NULL
;
2074 acl_name_list
*l_next
= NULL
;
2076 for (a
= *list
; a
; a
= a_next
) {
2077 for (l
= a
->acl_list
; l
; l
= l_next
) {
2079 memFree(l
, MEM_ACL_NAME_LIST
);
2084 memFree(a
, MEM_ACL_DENY_INFO_LIST
);
2092 parse_peer_access(void)
2097 if (!(host
= strtok(NULL
, w_space
)))
2100 if ((p
= peerFindByName(host
)) == NULL
) {
2101 debugs(15, 0, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2105 aclParseAccessLine(LegacyParser
, &p
->access
);
2109 parse_hostdomain(void)
2112 char *domain
= NULL
;
2114 if (!(host
= strtok(NULL
, w_space
)))
2117 while ((domain
= strtok(NULL
, list_sep
))) {
2118 domain_ping
*l
= NULL
;
2119 domain_ping
**L
= NULL
;
2122 if ((p
= peerFindByName(host
)) == NULL
) {
2123 debugs(15, 0, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2127 l
= static_cast<domain_ping
*>(xcalloc(1, sizeof(domain_ping
)));
2130 if (*domain
== '!') { /* check for !.edu */
2135 l
->domain
= xstrdup(domain
);
2137 for (L
= &(p
->peer_domain
); *L
; L
= &((*L
)->next
));
2143 parse_hostdomaintype(void)
2147 char *domain
= NULL
;
2149 if (!(host
= strtok(NULL
, w_space
)))
2152 if (!(type
= strtok(NULL
, w_space
)))
2155 while ((domain
= strtok(NULL
, list_sep
))) {
2156 domain_type
*l
= NULL
;
2157 domain_type
**L
= NULL
;
2160 if ((p
= peerFindByName(host
)) == NULL
) {
2161 debugs(15, 0, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2165 l
= static_cast<domain_type
*>(xcalloc(1, sizeof(domain_type
)));
2166 l
->type
= parseNeighborType(type
);
2167 l
->domain
= xstrdup(domain
);
2169 for (L
= &(p
->typelist
); *L
; L
= &((*L
)->next
));
2175 dump_int(StoreEntry
* entry
, const char *name
, int var
)
2177 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2195 dump_onoff(StoreEntry
* entry
, const char *name
, int var
)
2197 storeAppendPrintf(entry
, "%s %s\n", name
, var
? "on" : "off");
2201 parse_onoff(int *var
)
2203 char *token
= strtok(NULL
, w_space
);
2208 if (!strcasecmp(token
, "on") || !strcasecmp(token
, "enable"))
2214 #define free_onoff free_int
2217 dump_tristate(StoreEntry
* entry
, const char *name
, int var
)
2228 storeAppendPrintf(entry
, "%s %s\n", name
, state
);
2232 parse_tristate(int *var
)
2234 char *token
= strtok(NULL
, w_space
);
2239 if (!strcasecmp(token
, "on") || !strcasecmp(token
, "enable"))
2241 else if (!strcasecmp(token
, "warn"))
2247 #define free_tristate free_int
2250 dump_refreshpattern(StoreEntry
* entry
, const char *name
, refresh_t
* head
)
2252 while (head
!= NULL
) {
2253 storeAppendPrintf(entry
, "%s%s %s %d %d%% %d",
2255 head
->flags
.icase
? " -i" : null_string
,
2257 (int) head
->min
/ 60,
2258 (int) (100.0 * head
->pct
+ 0.5),
2259 (int) head
->max
/ 60);
2261 if (head
->flags
.refresh_ims
)
2262 storeAppendPrintf(entry
, " refresh-ims");
2264 if (head
->flags
.store_stale
)
2265 storeAppendPrintf(entry
, " store-stale");
2269 if (head
->flags
.override_expire
)
2270 storeAppendPrintf(entry
, " override-expire");
2272 if (head
->flags
.override_lastmod
)
2273 storeAppendPrintf(entry
, " override-lastmod");
2275 if (head
->flags
.reload_into_ims
)
2276 storeAppendPrintf(entry
, " reload-into-ims");
2278 if (head
->flags
.ignore_reload
)
2279 storeAppendPrintf(entry
, " ignore-reload");
2281 if (head
->flags
.ignore_no_cache
)
2282 storeAppendPrintf(entry
, " ignore-no-cache");
2284 if (head
->flags
.ignore_no_store
)
2285 storeAppendPrintf(entry
, " ignore-no-store");
2287 if (head
->flags
.ignore_must_revalidate
)
2288 storeAppendPrintf(entry
, " ignore-must-revalidate");
2290 if (head
->flags
.ignore_private
)
2291 storeAppendPrintf(entry
, " ignore-private");
2293 if (head
->flags
.ignore_auth
)
2294 storeAppendPrintf(entry
, " ignore-auth");
2298 storeAppendPrintf(entry
, "\n");
2305 parse_refreshpattern(refresh_t
** head
)
2312 int refresh_ims
= 0;
2313 int store_stale
= 0;
2317 int override_expire
= 0;
2318 int override_lastmod
= 0;
2319 int reload_into_ims
= 0;
2320 int ignore_reload
= 0;
2321 int ignore_no_cache
= 0;
2322 int ignore_no_store
= 0;
2323 int ignore_must_revalidate
= 0;
2324 int ignore_private
= 0;
2325 int ignore_auth
= 0;
2332 int flags
= REG_EXTENDED
| REG_NOSUB
;
2334 if ((token
= strtok(NULL
, w_space
)) == NULL
) {
2339 if (strcmp(token
, "-i") == 0) {
2341 token
= strtok(NULL
, w_space
);
2342 } else if (strcmp(token
, "+i") == 0) {
2343 flags
&= ~REG_ICASE
;
2344 token
= strtok(NULL
, w_space
);
2347 if (token
== NULL
) {
2352 pattern
= xstrdup(token
);
2354 i
= GetInteger(); /* token: min */
2356 min
= (time_t) (i
* 60); /* convert minutes to seconds */
2358 i
= GetInteger(); /* token: pct */
2360 pct
= (double) i
/ 100.0;
2362 i
= GetInteger(); /* token: max */
2364 max
= (time_t) (i
* 60); /* convert minutes to seconds */
2367 while ((token
= strtok(NULL
, w_space
)) != NULL
) {
2368 if (!strcmp(token
, "refresh-ims")) {
2370 } else if (!strcmp(token
, "store-stale")) {
2374 } else if (!strcmp(token
, "override-expire"))
2375 override_expire
= 1;
2376 else if (!strcmp(token
, "override-lastmod"))
2377 override_lastmod
= 1;
2378 else if (!strcmp(token
, "ignore-no-cache"))
2379 ignore_no_cache
= 1;
2380 else if (!strcmp(token
, "ignore-no-store"))
2381 ignore_no_store
= 1;
2382 else if (!strcmp(token
, "ignore-must-revalidate"))
2383 ignore_must_revalidate
= 1;
2384 else if (!strcmp(token
, "ignore-private"))
2386 else if (!strcmp(token
, "ignore-auth"))
2388 else if (!strcmp(token
, "reload-into-ims")) {
2389 reload_into_ims
= 1;
2390 refresh_nocache_hack
= 1;
2391 /* tell client_side.c that this is used */
2392 } else if (!strcmp(token
, "ignore-reload")) {
2394 refresh_nocache_hack
= 1;
2395 /* tell client_side.c that this is used */
2399 debugs(22, 0, "redreshAddToList: Unknown option '" << pattern
<< "': " << token
);
2402 if ((errcode
= regcomp(&comp
, pattern
, flags
)) != 0) {
2404 regerror(errcode
, &comp
, errbuf
, sizeof errbuf
);
2405 debugs(22, 0, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
2406 debugs(22, 0, "refreshAddToList: Invalid regular expression '" << pattern
<< "': " << errbuf
);
2410 pct
= pct
< 0.0 ? 0.0 : pct
;
2411 max
= max
< 0 ? 0 : max
;
2412 t
= static_cast<refresh_t
*>(xcalloc(1, sizeof(refresh_t
)));
2413 t
->pattern
= (char *) xstrdup(pattern
);
2414 t
->compiled_pattern
= comp
;
2419 if (flags
& REG_ICASE
)
2423 t
->flags
.refresh_ims
= 1;
2426 t
->flags
.store_stale
= 1;
2430 if (override_expire
)
2431 t
->flags
.override_expire
= 1;
2433 if (override_lastmod
)
2434 t
->flags
.override_lastmod
= 1;
2436 if (reload_into_ims
)
2437 t
->flags
.reload_into_ims
= 1;
2440 t
->flags
.ignore_reload
= 1;
2442 if (ignore_no_cache
)
2443 t
->flags
.ignore_no_cache
= 1;
2445 if (ignore_no_store
)
2446 t
->flags
.ignore_no_store
= 1;
2448 if (ignore_must_revalidate
)
2449 t
->flags
.ignore_must_revalidate
= 1;
2452 t
->flags
.ignore_private
= 1;
2455 t
->flags
.ignore_auth
= 1;
2462 head
= &(*head
)->next
;
2470 free_refreshpattern(refresh_t
** head
)
2474 while ((t
= *head
) != NULL
) {
2476 safe_free(t
->pattern
);
2477 regfree(&t
->compiled_pattern
);
2482 refresh_nocache_hack
= 0;
2488 dump_string(StoreEntry
* entry
, const char *name
, char *var
)
2491 storeAppendPrintf(entry
, "%s %s\n", name
, var
);
2495 parse_string(char **var
)
2497 char *token
= strtok(NULL
, w_space
);
2503 *var
= xstrdup(token
);
2507 ConfigParser::ParseString(char **var
)
2513 ConfigParser::ParseString(String
*var
)
2515 char *token
= strtok(NULL
, w_space
);
2524 free_string(char **var
)
2530 parse_eol(char *volatile *var
)
2532 unsigned char *token
= (unsigned char *) strtok(NULL
, null_string
);
2540 while (*token
&& xisspace(*token
))
2548 *var
= xstrdup((char *) token
);
2551 #define dump_eol dump_string
2552 #define free_eol free_string
2555 dump_time_t(StoreEntry
* entry
, const char *name
, time_t var
)
2557 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int) var
);
2561 parse_time_t(time_t * var
)
2563 parseTimeLine(var
, T_SECOND_STR
);
2567 free_time_t(time_t * var
)
2574 dump_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2576 storeAppendPrintf(entry
, "%s %d\n", name
, (int) var
);
2581 dump_b_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2583 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
2588 dump_kb_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2590 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_KBYTES_STR
);
2595 dump_b_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2597 storeAppendPrintf(entry
, "%s %"PRId64
" %s\n", name
, var
, B_BYTES_STR
);
2601 dump_kb_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2603 storeAppendPrintf(entry
, "%s %"PRId64
" %s\n", name
, var
, B_KBYTES_STR
);
2608 parse_size_t(size_t * var
)
2617 parse_b_size_t(size_t * var
)
2619 parseBytesLine(var
, B_BYTES_STR
);
2624 parse_kb_size_t(size_t * var
)
2626 parseBytesLine(var
, B_KBYTES_STR
);
2631 parse_b_int64_t(int64_t * var
)
2633 parseBytesLine64(var
, B_BYTES_STR
);
2637 parse_kb_int64_t(int64_t * var
)
2639 parseBytesLine64(var
, B_KBYTES_STR
);
2643 free_size_t(size_t * var
)
2649 free_b_int64_t(int64_t * var
)
2654 #define free_b_size_t free_size_t
2655 #define free_kb_size_t free_size_t
2656 #define free_mb_size_t free_size_t
2657 #define free_gb_size_t free_size_t
2658 #define free_kb_int64_t free_b_int64_t
2661 dump_ushort(StoreEntry
* entry
, const char *name
, u_short var
)
2663 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2667 free_ushort(u_short
* u
)
2673 parse_ushort(u_short
* var
)
2675 ConfigParser::ParseUShort(var
);
2679 ConfigParser::ParseUShort(u_short
*var
)
2685 ConfigParser::ParseBool(bool *var
)
2687 int i
= GetInteger();
2698 dump_wordlist(StoreEntry
* entry
, const char *name
, wordlist
* list
)
2700 while (list
!= NULL
) {
2701 storeAppendPrintf(entry
, "%s %s\n", name
, list
->key
);
2707 ConfigParser::ParseWordList(wordlist
** list
)
2709 parse_wordlist(list
);
2713 parse_wordlist(wordlist
** list
)
2716 char *t
= strtok(NULL
, "");
2718 while ((token
= strwordtok(NULL
, &t
)))
2719 wordlistAdd(list
, token
);
2722 #if 0 /* now unused */
2724 check_null_wordlist(wordlist
* w
)
2731 check_null_acl_access(acl_access
* a
)
2736 #define free_wordlist wordlistDestroy
2738 #define free_uri_whitespace free_int
2741 parse_uri_whitespace(int *var
)
2743 char *token
= strtok(NULL
, w_space
);
2748 if (!strcasecmp(token
, "strip"))
2749 *var
= URI_WHITESPACE_STRIP
;
2750 else if (!strcasecmp(token
, "deny"))
2751 *var
= URI_WHITESPACE_DENY
;
2752 else if (!strcasecmp(token
, "allow"))
2753 *var
= URI_WHITESPACE_ALLOW
;
2754 else if (!strcasecmp(token
, "encode"))
2755 *var
= URI_WHITESPACE_ENCODE
;
2756 else if (!strcasecmp(token
, "chop"))
2757 *var
= URI_WHITESPACE_CHOP
;
2763 dump_uri_whitespace(StoreEntry
* entry
, const char *name
, int var
)
2767 if (var
== URI_WHITESPACE_ALLOW
)
2769 else if (var
== URI_WHITESPACE_ENCODE
)
2771 else if (var
== URI_WHITESPACE_CHOP
)
2773 else if (var
== URI_WHITESPACE_DENY
)
2778 storeAppendPrintf(entry
, "%s %s\n", name
, s
);
2782 free_removalpolicy(RemovalPolicySettings
** settings
)
2787 free_string(&(*settings
)->type
);
2789 free_wordlist(&(*settings
)->args
);
2797 parse_removalpolicy(RemovalPolicySettings
** settings
)
2800 free_removalpolicy(settings
);
2802 *settings
= new RemovalPolicySettings
;
2804 parse_string(&(*settings
)->type
);
2806 parse_wordlist(&(*settings
)->args
);
2810 dump_removalpolicy(StoreEntry
* entry
, const char *name
, RemovalPolicySettings
* settings
)
2813 storeAppendPrintf(entry
, "%s %s", name
, settings
->type
);
2814 args
= settings
->args
;
2817 storeAppendPrintf(entry
, " %s", args
->key
);
2821 storeAppendPrintf(entry
, "\n");
2825 free_memcachemode(SquidConfig
* config
)
2831 parse_memcachemode(SquidConfig
* config
)
2833 char *token
= strtok(NULL
, w_space
);
2837 if (strcmp(token
, "always") == 0) {
2838 Config
.onoff
.memory_cache_first
= 1;
2839 Config
.onoff
.memory_cache_disk
= 1;
2840 } else if (strcmp(token
, "disk") == 0) {
2841 Config
.onoff
.memory_cache_first
= 0;
2842 Config
.onoff
.memory_cache_disk
= 1;
2843 } else if (strncmp(token
, "net", 3) == 0) {
2844 Config
.onoff
.memory_cache_first
= 1;
2845 Config
.onoff
.memory_cache_disk
= 0;
2846 } else if (strcmp(token
, "never") == 0) {
2847 Config
.onoff
.memory_cache_first
= 0;
2848 Config
.onoff
.memory_cache_disk
= 0;
2854 dump_memcachemode(StoreEntry
* entry
, const char *name
, SquidConfig
&config
)
2856 storeAppendPrintf(entry
, "%s ", name
);
2857 if (Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
2858 storeAppendPrintf(entry
, "always");
2859 else if (!Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
2860 storeAppendPrintf(entry
, "disk");
2861 else if (Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
2862 storeAppendPrintf(entry
, "network");
2863 else if (!Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
2864 storeAppendPrintf(entry
, "none");
2865 storeAppendPrintf(entry
, "\n");
2868 #include "cf_parser.cci"
2871 parseNeighborType(const char *s
)
2873 if (!strcasecmp(s
, "parent"))
2876 if (!strcasecmp(s
, "neighbor"))
2877 return PEER_SIBLING
;
2879 if (!strcasecmp(s
, "neighbour"))
2880 return PEER_SIBLING
;
2882 if (!strcasecmp(s
, "sibling"))
2883 return PEER_SIBLING
;
2885 if (!strcasecmp(s
, "multicast"))
2886 return PEER_MULTICAST
;
2888 debugs(15, 0, "WARNING: Unknown neighbor type: " << s
);
2890 return PEER_SIBLING
;
2895 parse_IpAddress_list(Ip::Address_list
** head
)
2898 Ip::Address_list
*s
;
2901 while ((token
= strtok(NULL
, w_space
))) {
2902 if (GetHostWithPort(token
, &ipa
)) {
2905 head
= &(*head
)->next
;
2907 s
= static_cast<Ip::Address_list
*>(xcalloc(1, sizeof(*s
)));
2917 dump_IpAddress_list(StoreEntry
* e
, const char *n
, const Ip::Address_list
* s
)
2919 char ntoabuf
[MAX_IPSTRLEN
];
2922 storeAppendPrintf(e
, "%s %s\n",
2924 s
->s
.NtoA(ntoabuf
,MAX_IPSTRLEN
));
2930 free_IpAddress_list(Ip::Address_list
** head
)
2932 if (*head
) delete *head
;
2936 #if CURRENTLY_UNUSED
2937 /* This code was previously used by http_port. Left as it really should
2938 * be used by icp_port and htcp_port
2941 check_null_IpAddress_list(const Ip::Address_list
* s
)
2946 #endif /* CURRENTLY_UNUSED */
2947 #endif /* USE_WCCPv2 */
2949 CBDATA_CLASS_INIT(http_port_list
);
2952 parse_http_port_specification(http_port_list
* s
, char *token
)
2955 unsigned short port
= 0;
2959 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
2960 s
->name
= xstrdup(token
);
2961 s
->connection_auth_disabled
= false;
2964 if (*token
== '[') {
2967 t
= strchr(host
, ']');
2969 debugs(3, 0, "http(s)_port: missing ']' on IPv6 address: " << token
);
2974 debugs(3, 0, "http(s)_port: missing Port in: " << token
);
2977 port
= xatos(t
+ 1);
2980 if ((t
= strchr(token
, ':'))) {
2985 port
= xatos(t
+ 1);
2987 } else if ((port
= strtol(token
, &junk
, 10)), !*junk
) {
2989 debugs(3, 3, "http(s)_port: found Listen on Port: " << port
);
2991 debugs(3, 0, "http(s)_port: missing Port: " << token
);
2996 debugs(3, 0, "http(s)_port: Port cannot be 0: " << token
);
3003 debugs(3, 3, "http(s)_port: found Listen on wildcard address: *:" << s
->s
.GetPort() );
3004 } else if ( s
->s
= host
) { /* check/parse numeric IPA */
3006 debugs(3, 3, "http(s)_port: Listen on Host/IP: " << host
<< " --> " << s
->s
);
3007 } else if ( s
->s
.GetHostByName(host
) ) { /* check/parse for FQDN */
3008 /* dont use ipcache */
3009 s
->defaultsite
= xstrdup(host
);
3011 debugs(3, 3, "http(s)_port: found Listen as Host " << s
->defaultsite
<< " on IP: " << s
->s
);
3013 debugs(3, 0, "http(s)_port: failed to resolve Host/IP: " << host
);
3019 parse_http_port_option(http_port_list
* s
, char *token
)
3023 if (strcmp(token
, "accel") == 0) {
3024 if (s
->intercepted
|| s
->spoof_client_ip
) {
3025 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: Accelerator mode requires its own port. It cannot be shared with other modes.");
3029 } else if (strcmp(token
, "transparent") == 0 || strcmp(token
, "intercept") == 0) {
3030 if (s
->accel
|| s
->spoof_client_ip
) {
3031 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: Intercept mode requires its own interception port. It cannot be shared with other modes.");
3035 Ip::Interceptor
.StartInterception();
3036 /* Log information regarding the port modes under interception. */
3037 debugs(3, DBG_IMPORTANT
, "Starting Authentication on port " << s
->s
);
3038 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (interception enabled)");
3041 /* INET6: until transparent REDIRECT works on IPv6 SOCKET, force wildcard to IPv4 */
3042 debugs(3, DBG_IMPORTANT
, "Disabling IPv6 on port " << s
->s
<< " (interception enabled)");
3043 if ( !s
->s
.SetIPv4() ) {
3044 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: IPv6 addresses cannot be transparent (protocol does not provide NAT)" << s
->s
);
3048 } else if (strcmp(token
, "tproxy") == 0) {
3049 if (s
->intercepted
|| s
->accel
) {
3050 debugs(3,DBG_CRITICAL
, "FATAL: http(s)_port: TPROXY option requires its own interception port. It cannot be shared with other modes.");
3053 s
->spoof_client_ip
= 1;
3054 Ip::Interceptor
.StartTransparency();
3055 /* Log information regarding the port modes under transparency. */
3056 debugs(3, DBG_IMPORTANT
, "Starting IP Spoofing on port " << s
->s
);
3057 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (IP spoofing enabled)");
3059 if (!Ip::Interceptor
.ProbeForTproxy(s
->s
)) {
3060 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: TPROXY support in the system does not work.");
3064 } else if (strncmp(token
, "defaultsite=", 12) == 0) {
3066 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: defaultsite option requires Acceleration mode flag.");
3069 safe_free(s
->defaultsite
);
3070 s
->defaultsite
= xstrdup(token
+ 12);
3071 } else if (strcmp(token
, "vhost") == 0) {
3073 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: vhost option requires Acceleration mode flag.");
3077 } else if (strcmp(token
, "vport") == 0) {
3079 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: vport option requires Acceleration mode flag.");
3083 } else if (strncmp(token
, "vport=", 6) == 0) {
3085 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: vport option requires Acceleration mode flag.");
3088 s
->vport
= xatos(token
+ 6);
3089 } else if (strncmp(token
, "protocol=", 9) == 0) {
3091 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: protocol option requires Acceleration mode flag.");
3094 s
->protocol
= xstrdup(token
+ 9);
3095 } else if (strcmp(token
, "allow-direct") == 0) {
3097 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: vport option requires Acceleration mode flag.");
3100 s
->allow_direct
= 1;
3101 } else if (strcmp(token
, "ignore-cc") == 0) {
3102 #if !HTTP_VIOLATIONS
3104 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: ignore-cc option requires Scceleration mode flag.");
3109 } else if (strncmp(token
, "name=", 5) == 0) {
3111 s
->name
= xstrdup(token
+ 5);
3112 } else if (strcmp(token
, "no-connection-auth") == 0) {
3113 s
->connection_auth_disabled
= true;
3114 } else if (strcmp(token
, "connection-auth=off") == 0) {
3115 s
->connection_auth_disabled
= true;
3116 } else if (strcmp(token
, "connection-auth") == 0) {
3117 s
->connection_auth_disabled
= false;
3118 } else if (strcmp(token
, "connection-auth=on") == 0) {
3119 s
->connection_auth_disabled
= false;
3120 } else if (strncmp(token
, "disable-pmtu-discovery=", 23) == 0) {
3121 if (!strcasecmp(token
+ 23, "off"))
3122 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3123 else if (!strcasecmp(token
+ 23, "transparent"))
3124 s
->disable_pmtu_discovery
= DISABLE_PMTU_TRANSPARENT
;
3125 else if (!strcasecmp(token
+ 23, "always"))
3126 s
->disable_pmtu_discovery
= DISABLE_PMTU_ALWAYS
;
3129 } else if (strcmp(token
, "ipv4") == 0) {
3131 if ( !s
->s
.SetIPv4() ) {
3132 debugs(3, DBG_CRITICAL
, "FATAL: http(s)_port: IPv6 addresses cannot be used a IPv4-Only." << s
->s
);
3136 } else if (strcmp(token
, "tcpkeepalive") == 0) {
3137 s
->tcp_keepalive
.enabled
= 1;
3138 } else if (strncmp(token
, "tcpkeepalive=", 13) == 0) {
3139 char *t
= token
+ 13;
3140 s
->tcp_keepalive
.enabled
= 1;
3141 s
->tcp_keepalive
.idle
= atoi(t
);
3145 s
->tcp_keepalive
.interval
= atoi(t
);
3150 s
->tcp_keepalive
.timeout
= atoi(t
);
3154 } else if (strcmp(token
, "sslBump") == 0) {
3155 s
->sslBump
= 1; // accelerated when bumped, otherwise not
3156 } else if (strncmp(token
, "cert=", 5) == 0) {
3158 s
->cert
= xstrdup(token
+ 5);
3159 } else if (strncmp(token
, "key=", 4) == 0) {
3161 s
->key
= xstrdup(token
+ 4);
3162 } else if (strncmp(token
, "version=", 8) == 0) {
3163 s
->version
= xatoi(token
+ 8);
3164 if (s
->version
< 1 || s
->version
> 4)
3166 } else if (strncmp(token
, "options=", 8) == 0) {
3167 safe_free(s
->options
);
3168 s
->options
= xstrdup(token
+ 8);
3169 } else if (strncmp(token
, "cipher=", 7) == 0) {
3170 safe_free(s
->cipher
);
3171 s
->cipher
= xstrdup(token
+ 7);
3172 } else if (strncmp(token
, "clientca=", 9) == 0) {
3173 safe_free(s
->clientca
);
3174 s
->clientca
= xstrdup(token
+ 9);
3175 } else if (strncmp(token
, "cafile=", 7) == 0) {
3176 safe_free(s
->cafile
);
3177 s
->cafile
= xstrdup(token
+ 7);
3178 } else if (strncmp(token
, "capath=", 7) == 0) {
3179 safe_free(s
->capath
);
3180 s
->capath
= xstrdup(token
+ 7);
3181 } else if (strncmp(token
, "crlfile=", 8) == 0) {
3182 safe_free(s
->crlfile
);
3183 s
->crlfile
= xstrdup(token
+ 8);
3184 } else if (strncmp(token
, "dhparams=", 9) == 0) {
3185 safe_free(s
->dhfile
);
3186 s
->dhfile
= xstrdup(token
+ 9);
3187 } else if (strncmp(token
, "sslflags=", 9) == 0) {
3188 safe_free(s
->sslflags
);
3189 s
->sslflags
= xstrdup(token
+ 9);
3190 } else if (strncmp(token
, "sslcontext=", 11) == 0) {
3191 safe_free(s
->sslcontext
);
3192 s
->sslcontext
= xstrdup(token
+ 11);
3199 static http_port_list
*
3200 create_http_port(char *portspec
)
3202 http_port_list
*s
= new http_port_list("http");
3203 parse_http_port_specification(s
, portspec
);
3208 add_http_port(char *portspec
)
3210 http_port_list
*s
= create_http_port(portspec
);
3211 // we may need to merge better of the above returns a list with clones
3212 assert(s
->next
== NULL
);
3213 s
->next
= Config
.Sockaddr
.http
;
3214 Config
.Sockaddr
.http
= s
;
3217 #if IPV6_SPECIAL_SPLITSTACK
3219 clone_http_port_list(http_port_list
*a
)
3221 http_port_list
*b
= new http_port_list(a
->protocol
);
3225 b
->name
= xstrdup(a
->name
);
3227 b
->defaultsite
= xstrdup(a
->defaultsite
);
3229 b
->intercepted
= a
->intercepted
;
3230 b
->spoof_client_ip
= a
->spoof_client_ip
;
3231 b
->accel
= a
->accel
;
3232 b
->allow_direct
= a
->allow_direct
;
3233 b
->vhost
= a
->vhost
;
3234 b
->sslBump
= a
->sslBump
;
3235 b
->vport
= a
->vport
;
3236 b
->connection_auth_disabled
= a
->connection_auth_disabled
;
3237 b
->disable_pmtu_discovery
= a
->disable_pmtu_discovery
;
3239 memcpy( &(b
->tcp_keepalive
), &(a
->tcp_keepalive
), sizeof(a
->tcp_keepalive
));
3242 // AYJ: 2009-07-18: for now SSL does not clone. Configure separate ports with IPs and SSL settings
3245 // XXX: temporary hack to ease move of SSL options to http_port
3246 http_port_list
&http
;
3260 SSL_CTX
*sslContext
;
3270 parse_http_port_list(http_port_list
** head
)
3272 char *token
= strtok(NULL
, w_space
);
3279 http_port_list
*s
= create_http_port(token
);
3281 /* parse options ... */
3282 while ((token
= strtok(NULL
, w_space
))) {
3283 parse_http_port_option(s
, token
);
3286 #if IPV6_SPECIAL_SPLITSTACK
3287 if (s
->s
.IsAnyAddr()) {
3288 // clone the port options from *s to *(s->next)
3289 s
->next
= clone_http_port_list(s
);
3290 s
->next
->s
.SetIPv4();
3291 debugs(3, 3, "http(s)_port: clone wildcard address for split-stack: " << s
->s
<< " and " << s
->next
->s
);
3296 head
= &(*head
)->next
;
3302 dump_generic_http_port(StoreEntry
* e
, const char *n
, const http_port_list
* s
)
3304 char buf
[MAX_IPSTRLEN
];
3306 storeAppendPrintf(e
, "%s %s",
3308 s
->s
.ToURL(buf
,MAX_IPSTRLEN
));
3311 storeAppendPrintf(e
, " intercept");
3313 if (s
->spoof_client_ip
)
3314 storeAppendPrintf(e
, " tproxy");
3317 storeAppendPrintf(e
, " accel");
3320 storeAppendPrintf(e
, " vhost");
3323 storeAppendPrintf(e
, " vport");
3326 storeAppendPrintf(e
, " defaultsite=%s", s
->defaultsite
);
3328 if (s
->connection_auth_disabled
)
3329 storeAppendPrintf(e
, " connection-auth=off");
3331 storeAppendPrintf(e
, " connection-auth=on");
3333 if (s
->disable_pmtu_discovery
!= DISABLE_PMTU_OFF
) {
3336 if (s
->disable_pmtu_discovery
== DISABLE_PMTU_ALWAYS
)
3339 pmtu
= "transparent";
3341 storeAppendPrintf(e
, " disable-pmtu-discovery=%s", pmtu
);
3344 if (s
->tcp_keepalive
.enabled
) {
3345 if (s
->tcp_keepalive
.idle
|| s
->tcp_keepalive
.interval
|| s
->tcp_keepalive
.timeout
) {
3346 storeAppendPrintf(e
, " tcpkeepalive=%d,%d,%d", s
->tcp_keepalive
.idle
, s
->tcp_keepalive
.interval
, s
->tcp_keepalive
.timeout
);
3348 storeAppendPrintf(e
, " tcpkeepalive");
3354 storeAppendPrintf(e
, " sslBump");
3357 storeAppendPrintf(e
, " cert=%s", s
->cert
);
3360 storeAppendPrintf(e
, " key=%s", s
->key
);
3363 storeAppendPrintf(e
, " version=%d", s
->version
);
3366 storeAppendPrintf(e
, " options=%s", s
->options
);
3369 storeAppendPrintf(e
, " cipher=%s", s
->cipher
);
3372 storeAppendPrintf(e
, " cafile=%s", s
->cafile
);
3375 storeAppendPrintf(e
, " capath=%s", s
->capath
);
3378 storeAppendPrintf(e
, " crlfile=%s", s
->crlfile
);
3381 storeAppendPrintf(e
, " dhparams=%s", s
->dhfile
);
3384 storeAppendPrintf(e
, " sslflags=%s", s
->sslflags
);
3387 storeAppendPrintf(e
, " sslcontext=%s", s
->sslcontext
);
3392 dump_http_port_list(StoreEntry
* e
, const char *n
, const http_port_list
* s
)
3395 dump_generic_http_port(e
, n
, s
);
3396 storeAppendPrintf(e
, "\n");
3402 free_http_port_list(http_port_list
** head
)
3406 while ((s
= *head
) != NULL
) {
3414 // TODO: merge better with parse_http_port_list
3416 parse_https_port_list(https_port_list
** head
)
3421 token
= strtok(NULL
, w_space
);
3426 s
= new https_port_list
;
3427 parse_http_port_specification(&s
->http
, token
);
3429 /* parse options ... */
3430 while ((token
= strtok(NULL
, w_space
))) {
3431 parse_http_port_option(s
, token
);
3435 http_port_list
** headTmp
= &(*head
)->http
.next
;
3436 head
= (https_port_list
**)headTmp
;
3443 dump_https_port_list(StoreEntry
* e
, const char *n
, const https_port_list
* s
)
3445 dump_http_port_list(e
, n
, s
);
3449 free_https_port_list(https_port_list
** head
)
3451 free_http_port_list((http_port_list
**)head
);
3456 check_null_https_port_list(const https_port_list
* s
)
3463 #endif /* USE_SSL */
3466 configFreeMemory(void)
3472 requirePathnameExists(const char *name
, const char *path
)
3476 char pathbuf
[BUFSIZ
];
3477 assert(path
!= NULL
);
3479 if (Config
.chroot_dir
&& (geteuid() == 0)) {
3480 snprintf(pathbuf
, BUFSIZ
, "%s/%s", Config
.chroot_dir
, path
);
3484 if (stat(path
, &sb
) < 0) {
3485 if (opt_send_signal
== -1 || opt_send_signal
== SIGHUP
)
3486 fatalf("%s %s: %s", name
, path
, xstrerror());
3488 fprintf(stderr
, "WARNING: %s %s: %s\n", name
, path
, xstrerror());
3495 return ConfigParser::strtokFile();
3498 #include "AccessLogEntry.h"
3499 /* TODO: split out parsing somehow ...*/
3501 parse_logformat(logformat
** logformat_definitions
)
3506 if ((name
= strtok(NULL
, w_space
)) == NULL
)
3509 if ((def
= strtok(NULL
, "\r\n")) == NULL
) {
3514 debugs(3, 2, "Logformat for '" << name
<< "' is '" << def
<< "'");
3516 nlf
= (logformat
*)xcalloc(1, sizeof(logformat
));
3518 nlf
->name
= xstrdup(name
);
3520 if (!accessLogParseLogFormat(&nlf
->format
, def
)) {
3525 nlf
->next
= *logformat_definitions
;
3527 *logformat_definitions
= nlf
;
3531 parse_access_log(customlog
** logs
)
3533 const char *filename
, *logdef_name
;
3537 cl
= (customlog
*)xcalloc(1, sizeof(*cl
));
3539 if ((filename
= strtok(NULL
, w_space
)) == NULL
) {
3544 if (strcmp(filename
, "none") == 0) {
3545 cl
->type
= CLF_NONE
;
3549 if ((logdef_name
= strtok(NULL
, w_space
)) == NULL
)
3550 logdef_name
= "auto";
3552 debugs(3, 9, "Log definition name '" << logdef_name
<< "' file '" << filename
<< "'");
3554 cl
->filename
= xstrdup(filename
);
3556 /* look for the definition pointer corresponding to this name */
3557 lf
= Config
.Log
.logformats
;
3559 while (lf
!= NULL
) {
3560 debugs(3, 9, "Comparing against '" << lf
->name
<< "'");
3562 if (strcmp(lf
->name
, logdef_name
) == 0)
3569 cl
->type
= CLF_CUSTOM
;
3571 } else if (strcmp(logdef_name
, "auto") == 0) {
3572 cl
->type
= CLF_AUTO
;
3573 } else if (strcmp(logdef_name
, "squid") == 0) {
3574 cl
->type
= CLF_SQUID
;
3575 } else if (strcmp(logdef_name
, "common") == 0) {
3576 cl
->type
= CLF_COMMON
;
3578 } else if (strcmp(logdef_name
, "icap_squid") == 0) {
3579 cl
->type
= CLF_ICAP_SQUID
;
3582 debugs(3, 0, "Log format '" << logdef_name
<< "' is not defined");
3588 aclParseAclList(LegacyParser
, &cl
->aclList
);
3591 logs
= &(*logs
)->next
;
3597 check_null_access_log(customlog
*customlog_definitions
)
3599 return customlog_definitions
== NULL
;
3603 dump_logformat(StoreEntry
* entry
, const char *name
, logformat
* definitions
)
3605 accessLogDumpLogFormat(entry
, name
, definitions
);
3609 dump_access_log(StoreEntry
* entry
, const char *name
, customlog
* logs
)
3613 for (log
= logs
; log
; log
= log
->next
) {
3614 storeAppendPrintf(entry
, "%s ", name
);
3616 switch (log
->type
) {
3619 storeAppendPrintf(entry
, "%s %s", log
->filename
, log
->logFormat
->name
);
3623 storeAppendPrintf(entry
, "none");
3627 storeAppendPrintf(entry
, "%s squid", log
->filename
);
3631 storeAppendPrintf(entry
, "%s squid", log
->filename
);
3634 case CLF_ICAP_SQUID
:
3635 storeAppendPrintf(entry
, "%s icap_squid", log
->filename
);
3641 storeAppendPrintf(entry
, "%s auto", log
->filename
);
3643 storeAppendPrintf(entry
, "%s", log
->filename
);
3652 dump_acl_list(entry
, log
->aclList
);
3654 storeAppendPrintf(entry
, "\n");
3659 free_logformat(logformat
** definitions
)
3661 while (*definitions
) {
3662 logformat
*format
= *definitions
;
3663 *definitions
= format
->next
;
3664 safe_free(format
->name
);
3665 accessLogFreeLogFormat(&format
->format
);
3671 free_access_log(customlog
** definitions
)
3673 while (*definitions
) {
3674 customlog
*log
= *definitions
;
3675 *definitions
= log
->next
;
3677 log
->logFormat
= NULL
;
3678 log
->type
= CLF_UNKNOWN
;
3681 aclDestroyAclList(&log
->aclList
);
3683 safe_free(log
->filename
);
3692 parse_adaptation_service_set_type()
3694 Adaptation::Config::ParseServiceSet();
3698 parse_adaptation_service_chain_type()
3700 Adaptation::Config::ParseServiceChain();
3704 parse_adaptation_access_type()
3706 Adaptation::Config::ParseAccess(LegacyParser
);
3709 #endif /* USE_ADAPTATION */
3715 parse_icap_service_type(Adaptation::Icap::Config
* cfg
)
3717 cfg
->parseService();
3721 free_icap_service_type(Adaptation::Icap::Config
* cfg
)
3727 dump_icap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
3729 cfg
.dumpService(entry
, name
);
3733 parse_icap_class_type()
3735 debugs(93, 0, "WARNING: 'icap_class' is depricated. " <<
3736 "Use 'adaptation_service_set' instead");
3737 Adaptation::Config::ParseServiceSet();
3741 parse_icap_access_type()
3743 debugs(93, 0, "WARNING: 'icap_access' is depricated. " <<
3744 "Use 'adaptation_access' instead");
3745 Adaptation::Config::ParseAccess(LegacyParser
);
3754 parse_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
3756 cfg
->parseService();
3760 free_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
3766 dump_ecap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Ecap::Config
&cfg
)
3768 cfg
.dumpService(entry
, name
);
3771 #endif /* USE_ECAP */
3774 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
3779 cfg
->service_failure_limit
= GetInteger();
3781 if ((token
= strtok(NULL
, w_space
)) == NULL
)
3784 if (strcmp(token
,"in") != 0) {
3785 debugs(3, 0, "expecting 'in' on'" << config_input_line
<< "'");
3789 if ((token
= strtok(NULL
, w_space
)) == NULL
) {
3793 d
= static_cast<time_t> (xatoi(token
));
3795 m
= static_cast<time_t> (1);
3799 else if ((token
= strtok(NULL
, w_space
)) == NULL
) {
3800 debugs(3, 0, "No time-units on '" << config_input_line
<< "'");
3802 } else if ((m
= parseTimeUnits(token
)) == 0)
3805 cfg
->oldest_service_failure
= (m
* d
);
3808 static void dump_icap_service_failure_limit(StoreEntry
*entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
3810 storeAppendPrintf(entry
, "%s %d", name
, cfg
.service_failure_limit
);
3811 if (cfg
.oldest_service_failure
> 0) {
3812 storeAppendPrintf(entry
, " in %d seconds", (int)cfg
.oldest_service_failure
);
3814 storeAppendPrintf(entry
, "\n");
3817 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
3819 cfg
->oldest_service_failure
= 0;
3820 cfg
->service_failure_limit
= 0;