#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.in,v 1.147 1998/04/23 22:30:19 wessels Exp $
+# $Id: Makefile.in,v 1.148 1998/05/05 03:49:56 wessels Exp $
#
# Uncomment and customize the following to suit your needs:
#
icp_v2.o \
icp_v3.o \
ident.o \
+ internal.o \
ipc.o \
ipcache.o \
main.o \
/*
- * $Id: client_side.cc,v 1.297 1998/05/02 06:41:09 wessels Exp $
+ * $Id: client_side.cc,v 1.298 1998/05/05 03:49:57 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
/* need to malloc because the URL returned by the redirector might
* not be big enough to append the local domain
* -- David Lamkin drl@net-tel.co.uk */
- l = strlen(result) + Config.appendDomainLen + 5;
+ l = strlen(result) + Config.appendDomainLen + 64;
http->uri = xcalloc(l, 1);
xstrncpy(http->uri, result, l);
new_request->http_ver = old_request->http_ver;
ch.src_addr = http->conn->peer.sin_addr;
ch.request = r;
answer = aclCheckFast(Config.accessList.miss, &ch);
- if (answer == 0 || http->flags.internal) {
- debug(33,1)("clientProcessMiss: Can't forward internal request '%s'\n",
- r->urlpath);
+ if (answer == 0) {
http->al.http.code = HTTP_FORBIDDEN;
err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN);
err->request = requestLink(r);
http->entry = clientCreateStoreEntry(http, r->method, r->flags);
http->entry->mem_obj->fd = http->conn->fd;
http->entry->refcount++;
+ if (http->flags.internal)
+ r->protocol = PROTO_INTERNAL;
protoDispatch(http->conn->fd, http->entry, r);
}
*t = '\0';
/* handle internal objects */
- if (0 == strncmp(url, "/squid-internal/", 16)) {
+ if (internalCheck(url)) {
/* prepend our name & port */
- http->uri = xstrdup(urlInternal(NULL, url + 16));
+ http->uri = xstrdup(internalLocalUri(NULL, url));
http->flags.internal = 1;
}
/* see if we running in Config2.Accel.on, if so got to convert it to URL */
PROTO_ICP,
PROTO_URN,
PROTO_WHOIS,
+ PROTO_INTERNAL,
PROTO_MAX
} protocol_t;
--- /dev/null
+
+#include "squid.h"
+
+void
+internalStart(request_t * request, StoreEntry * entry)
+{
+ const char *upath = strBuf(request->urlpath);
+ debug(0, 1) ("internalStart: %s requesting '%s'\n",
+ inet_ntoa(request->client_addr), upath);
+ if (0 == strcmp(upath, "/squid-internal-dynamic/netdb"))
+ netdbBinaryExchange(entry);
+ else
+ debug(0,0)("internalStart: unknown request '%s'\n", upath);
+}
+
+int
+internalCheck(const char *urlpath)
+{
+ return (0 == strncmp(urlpath, "/squid-internal-", 16));
+}
+
+/*
+ * makes internal url with a given host and port (remote internal url)
+ */
+char *
+internalRemoteUri(const char *host, u_short port, const char *dir, const char *name)
+{
+ LOCAL_ARRAY(char, buf, MAX_URL);
+ int k = 0;
+ static char lc_host[SQUIDHOSTNAMELEN];
+ assert(host && port && name);
+ xstrncpy(lc_host, host, SQUIDHOSTNAMELEN);
+ Tolower(lc_host);
+ k += snprintf(buf + k, MAX_URL - k, "http://%s", lc_host);
+ if (port != urlDefaultPort(PROTO_HTTP))
+ k += snprintf(buf + k, MAX_URL - k, ":%d", port);
+ if (dir)
+ k += snprintf(buf + k, MAX_URL - k, "%s", dir);
+ k += snprintf(buf + k, MAX_URL - k, "%s", name);
+ return buf;
+}
+
+/*
+ * makes internal url with local host and port
+ */
+char *
+internalLocalUri(const char *dir, const char *name)
+{
+ return internalRemoteUri(getMyHostname(), Config.Port.http->i, dir, name);
+}
/*
- * $Id: mime.cc,v 1.63 1998/04/24 07:09:38 wessels Exp $
+ * $Id: mime.cc,v 1.64 1998/05/05 03:49:59 wessels Exp $
*
* DEBUG: section 25 MIME Parsing
* AUTHOR: Harvest Derived
char *icon = mimeGetIcon(fn);
if (icon == NULL)
return NULL;
- return urlInternal("icons", icon);
+ return internalLocalUri("/squid-internal-static/icons/", icon);
}
char *
const char *type = mimeGetContentType(icon);
if (type == NULL)
fatal("Unknown icon format while reading mime.conf\n");
- xstrncpy(url, urlInternal("icons", icon), MAX_URL);
+ buf = internalLocalUri("/squid-internal-static/icons/", icon);
+ xstrncpy(url, buf, MAX_URL);
key = storeKeyPublic(url, METHOD_GET);
if (storeGet(key))
return;
extern void netdbUpdatePeer(request_t *, peer * e, int rtt, int hops);
extern void netdbDeleteAddrNetwork(struct in_addr addr);
extern int netdbHostPeerRtt(const char *host, peer * peer);
+extern void netdbBinaryExchange(StoreEntry *);
extern void cachemgrStart(int fd, request_t * request, StoreEntry * entry);
extern void cachemgrRegister(const char *, const char *, OBJH *, int);
extern void urlInitialize(void);
extern request_t *urlParse(method_t, char *);
extern char *urlCanonical(const request_t *, char *);
-extern char *urlRInternal(const char *host, u_short port, const char *dir, const char *name);
-extern char *urlInternal(const char *dir, const char *name);
extern request_t *requestLink(request_t *);
extern void requestUnlink(request_t *);
extern int matchDomainName(const char *d, const char *h);
extern void cacheDigestGuessStatsReport(const cd_guess_stats * stats, StoreEntry * sentry, const char *label);
extern void cacheDigestReport(CacheDigest * cd, const char *label, StoreEntry * e);
+extern void internalStart(request_t *, StoreEntry *);
+extern int internalCheck(const char *urlpath);
+extern char *internalLocalUri(const char *dir, const char *name);
+extern char *internalRemoteUri(const char *, u_short, const char *, const char *);
+
/*
* prototypes for system functions missing from system includes
*/
/*
- * $Id: store_digest.cc,v 1.11 1998/04/24 07:09:47 wessels Exp $
+ * $Id: store_digest.cc,v 1.12 1998/05/05 03:50:01 wessels Exp $
*
* DEBUG: section 71 Store Digest Manager
* AUTHOR: Alex Rousskov
}
debug(71, 2) ("storeDigestRewrite: start rewrite #%d\n", sd_state.rewrite_count + 1);
/* make new store entry */
- url = urlInternal("", StoreDigestUrlPath);
+ url = internalLocalUri(NULL, StoreDigestUrlPath);
flags = 0;
EBIT_SET(flags, REQ_CACHABLE);
sd_state.rewrite_lock = e = storeCreateEntry(url, url, flags, METHOD_GET);
/*
- * $Id: url.cc,v 1.88 1998/04/24 04:52:40 wessels Exp $
+ * $Id: url.cc,v 1.89 1998/05/05 03:50:02 wessels Exp $
*
* DEBUG: section 23 URL Parsing
* AUTHOR: Duane Wessels
"icp",
"urn",
"whois",
+ "internal",
"TOTAL"
};
return PROTO_URN;
if (strncasecmp(s, "whois", 5) == 0)
return PROTO_WHOIS;
+ if (strncasecmp(s, "internal", 8) == 0)
+ return PROTO_INTERNAL;
return PROTO_NONE;
}
case PROTO_WAIS:
return 210;
case PROTO_CACHEOBJ:
+ case PROTO_INTERNAL:
return CACHE_HTTP_PORT;
case PROTO_WHOIS:
return 43;
return buf;
}
-/* makes internal url with a given host and port (remote internal url) */
-char *
-urlRInternal(const char *host, u_short port, const char *dir, const char *name)
-{
- LOCAL_ARRAY(char, buf, MAX_URL);
- int k = 0;
- static char lc_host[SQUIDHOSTNAMELEN];
- assert(host && port && name);
- xstrncpy(lc_host, host, SQUIDHOSTNAMELEN);
- Tolower(lc_host);
- k += snprintf(buf + k, MAX_URL - k, "http://%s", lc_host);
- if (port != urlDefaultPort(PROTO_HTTP))
- k += snprintf(buf + k, MAX_URL - k, ":%d", port);
- k += snprintf(buf + k, MAX_URL - k, "/%s", "squid-internal");
- if (NULL != dir && '\0' != *dir)
- k += snprintf(buf + k, MAX_URL - k, "/%s", dir);
- k += snprintf(buf + k, MAX_URL - k, "/%s", name);
- return buf;
-}
-
-/* makes internal url with local host and port */
-char *
-urlInternal(const char *dir, const char *name)
-{
- return urlRInternal(getMyHostname(), Config.Port.http->i, dir, name);
-}
-
request_t *
requestLink(request_t * request)
{