refuse to start unless at least one port is defined.
- CARP now plays well with the other peering algorithms
- Configuration file can be read from an external program
or preprocessor. See squid.8 man page.
+ - http_port is now optional, allowing for SSL only operation
Changes to squid-2.5 ():
/*
- * $Id: cache_cf.cc,v 1.403 2002/04/04 21:17:25 hno Exp $
+ * $Id: cache_cf.cc,v 1.404 2002/04/04 21:33:26 hno Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
static void parse_sockaddr_in_list(sockaddr_in_list **);
static void dump_sockaddr_in_list(StoreEntry *, const char *, const sockaddr_in_list *);
static void free_sockaddr_in_list(sockaddr_in_list **);
+#if 0
static int check_null_sockaddr_in_list(const sockaddr_in_list *);
+#endif
#if USE_SSL
static void parse_https_port_list(https_port_list **);
static void dump_https_port_list(StoreEntry *, const char *, const https_port_list *);
if (Config.Accel.port == 0)
vport_mode = 1;
}
- if (Config.Sockaddr.http == NULL)
- fatal("No http_port specified!");
- snprintf(ThisCache, sizeof(ThisCache), "%s:%d (%s)",
+ snprintf(ThisCache, sizeof(ThisCache), "%s (%s)",
uniqueHostname(),
- (int) ntohs(Config.Sockaddr.http->s.sin_port),
full_appname_string);
/*
* the extra space is for loop detection in client_side.c -- we search
* for substrings in the Via header.
*/
- snprintf(ThisCache2, sizeof(ThisCache), " %s:%d (%s)",
+ snprintf(ThisCache2, sizeof(ThisCache), " %s (%s)",
uniqueHostname(),
- (int) ntohs(Config.Sockaddr.http->s.sin_port),
full_appname_string);
if (!Config.udpMaxHitObjsz || Config.udpMaxHitObjsz > SQUID_UDP_SO_SNDBUF)
Config.udpMaxHitObjsz = SQUID_UDP_SO_SNDBUF;
return PEER_SIBLING;
}
-static void
-parse_sockaddr_in_list(sockaddr_in_list ** head)
+void
+parse_sockaddr_in_list_token(sockaddr_in_list ** head, char *token)
{
- char *token;
char *t;
char *host;
const struct hostent *hp;
unsigned short port;
sockaddr_in_list *s;
- while ((token = strtok(NULL, w_space))) {
- host = NULL;
- port = 0;
- if ((t = strchr(token, ':'))) {
- /* host:port */
- host = token;
- *t = '\0';
- port = (unsigned short) atoi(t + 1);
- if (0 == port)
- self_destruct();
- } else if ((port = atoi(token)) > 0) {
- /* port */
- } else {
- self_destruct();
- }
- s = xcalloc(1, sizeof(*s));
- s->s.sin_port = htons(port);
- if (NULL == host)
- s->s.sin_addr = any_addr;
- else if (1 == safe_inet_addr(host, &s->s.sin_addr))
- (void) 0;
- else if ((hp = gethostbyname(host))) /* dont use ipcache */
- s->s.sin_addr = inaddrFromHostent(hp);
- else
+
+ host = NULL;
+ port = 0;
+ if ((t = strchr(token, ':'))) {
+ /* host:port */
+ host = token;
+ *t = '\0';
+ port = (unsigned short) atoi(t + 1);
+ if (0 == port)
self_destruct();
- while (*head)
- head = &(*head)->next;
- *head = s;
+ } else if ((port = atoi(token)) > 0) {
+ /* port */
+ } else {
+ self_destruct();
+ }
+ s = xcalloc(1, sizeof(*s));
+ s->s.sin_port = htons(port);
+ if (NULL == host)
+ s->s.sin_addr = any_addr;
+ else if (1 == safe_inet_addr(host, &s->s.sin_addr))
+ (void) 0;
+ else if ((hp = gethostbyname(host))) /* dont use ipcache */
+ s->s.sin_addr = inaddrFromHostent(hp);
+ else
+ self_destruct();
+ while (*head)
+ head = &(*head)->next;
+ *head = s;
+}
+
+static void
+parse_sockaddr_in_list(sockaddr_in_list ** head)
+{
+ char *token;
+ while ((token = strtok(NULL, w_space))) {
+ parse_sockaddr_in_list_token(head, token);
}
}
}
}
+#if 0
static int
check_null_sockaddr_in_list(const sockaddr_in_list * s)
{
return NULL == s;
}
+#endif
#if USE_SSL
static void
#
-# $Id: cf.data.pre,v 1.252 2002/04/02 20:32:43 hno Exp $
+# $Id: cf.data.pre,v 1.253 2002/04/04 21:33:26 hno Exp $
#
#
# SQUID Web Proxy Cache http://www.squid-cache.org/
NAME: http_port ascii_port
TYPE: sockaddr_in_list
DEFAULT: none
-DEFAULT_IF_NONE: 3128
LOC: Config.Sockaddr.http
DOC_START
Usage: port
option. Most likely, you do not need to bind to a specific
address, so you can use the port number alone.
- The default port number is 3128.
-
If you are running Squid in accelerator mode, then you
probably want to listen on port 80 also, or instead.
and an external interface then we recommend you to specify the
internal address:port in http_port. This way Squid will only be
visible on the internal address.
+
+NOCOMMENT_START
+# Squid normally listens to port 3128
+http_port 3128
+NOCOMMENT_END
DOC_END
NAME: https_port
/*
- * $Id: client_side.cc,v 1.567 2002/04/01 06:02:15 wessels Exp $
+ * $Id: client_side.cc,v 1.568 2002/04/04 21:33:26 hno Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
/* Append X-Cache-Lookup: -- temporary hack, to be removed @?@ @?@ */
httpHeaderPutStrf(hdr, HDR_X_CACHE_LOOKUP, "%s from %s:%d",
http->lookup_type ? http->lookup_type : "NONE",
- getMyHostname(), ntohs(Config.Sockaddr.http->s.sin_port));
+ getMyHostname(), getMyPort());
#endif
if (httpReplyBodySize(request->method, rep) < 0) {
debug(33, 3) ("clientBuildReplyHeader: can't keep-alive, unknown body size\n");
if (!http->flags.internal) {
if (internalCheck(strBuf(request->urlpath))) {
if (internalHostnameIs(request->host) &&
- request->port == ntohs(Config.Sockaddr.http->s.sin_port)) {
+ request->port == getMyPort()) {
http->flags.internal = 1;
} else if (internalStaticCheck(strBuf(request->urlpath))) {
xstrncpy(request->host, internalHostname(), SQUIDHOSTNAMELEN);
- request->port = ntohs(Config.Sockaddr.http->s.sin_port);
+ request->port = getMyPort();
http->flags.internal = 1;
}
}
/*
- * $Id: internal.cc,v 1.23 2001/01/12 00:37:18 wessels Exp $
+ * $Id: internal.cc,v 1.24 2002/04/04 21:33:26 hno Exp $
*
* DEBUG: section 76 Internal Squid Object handling
* AUTHOR: Duane, Alex, Henrik
{
static MemBuf mb = MemBufNULL;
static char lc_host[SQUIDHOSTNAMELEN];
- assert(host && port && name);
+ assert(host && name);
/* convert host name to lower case */
xstrncpy(lc_host, host, SQUIDHOSTNAMELEN - 1);
Tolower(lc_host);
memBufReset(&mb);
memBufPrintf(&mb, "http://%s", lc_host);
/* append port if not default */
- if (port != urlDefaultPort(PROTO_HTTP))
+ if (port && port != urlDefaultPort(PROTO_HTTP))
memBufPrintf(&mb, ":%d", port);
if (dir)
memBufPrintf(&mb, "%s", dir);
internalLocalUri(const char *dir, const char *name)
{
return internalRemoteUri(getMyHostname(),
- ntohs(Config.Sockaddr.http->s.sin_port), dir, name);
+ 0, dir, name);
}
const char *
/*
- * $Id: main.cc,v 1.347 2002/01/15 16:49:19 hno Exp $
+ * $Id: main.cc,v 1.348 2002/04/04 21:33:27 hno Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
static int opt_send_signal = -1;
static int opt_no_daemon = 0;
static int opt_parse_cfg_only = 0;
-static int httpPortNumOverride = 1;
static int icpPortNumOverride = 1; /* Want to detect "-u 0" */
static int configured_once = 0;
#if MALLOC_DBG
opt_reload_hit_only = 1;
break;
case 'a':
- httpPortNumOverride = atoi(optarg);
+ parse_sockaddr_in_list_token(&Config.Sockaddr.http, optarg);
break;
case 'd':
opt_debug_stderr = atoi(optarg);
squid_signal(SIGCHLD, sig_child, SA_NODEFER | SA_RESTART);
setEffectiveUser();
- assert(Config.Sockaddr.http);
- if (httpPortNumOverride != 1)
- Config.Sockaddr.http->s.sin_port = htons(httpPortNumOverride);
if (icpPortNumOverride != 1)
Config.Port.icp = (u_short) icpPortNumOverride;
/*
- * $Id: protos.h,v 1.430 2002/04/01 06:02:16 wessels Exp $
+ * $Id: protos.h,v 1.431 2002/04/04 21:33:27 hno Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
extern void parse_time_t(time_t * var);
extern void parse_cachedir_options(SwapDir * sd, struct cache_dir_option *options, int reconfiguring);
extern void dump_cachedir_options(StoreEntry * e, struct cache_dir_option *options, SwapDir * sd);
+extern void parse_sockaddr_in_list_token(sockaddr_in_list **, char *);
/*
extern int xrename(const char *from, const char *to);
extern int isPowTen(int);
extern void parseEtcHosts(void);
+extern int getMyPort(void);
#if USE_HTCP
extern void htcpInit(void);
/*
- * $Id: send-announce.cc,v 1.62 2001/04/14 00:03:23 hno Exp $
+ * $Id: send-announce.cc,v 1.63 2002/04/04 21:33:27 hno Exp $
*
* DEBUG: section 27 Cache Announcer
* AUTHOR: Duane Wessels
assert(Config.Sockaddr.http);
snprintf(tbuf, 256, "Running on %s %d %d\n",
getMyHostname(),
- (int) ntohs(Config.Sockaddr.http->s.sin_port),
+ getMyPort(),
(int) Config.Port.icp);
strcat(sndbuf, tbuf);
if (Config.adminEmail) {
/*
- * $Id: tools.cc,v 1.214 2002/03/30 16:29:51 hno Exp $
+ * $Id: tools.cc,v 1.215 2002/04/04 21:33:27 hno Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
wordlistDestroy(&hosts);
}
}
+
+int
+getMyPort(void)
+{
+#if USE_SSL
+ if (Config.Sockaddr.http)
+ return Config.Sockaddr.http->s.sin_port;
+ else
+ return Config.Sockaddr.https->s.sin_port;
+#else
+ return Config.Sockaddr.http->s.sin_port;
+#endif
+}