From: wessels <> Date: Tue, 14 Jul 1998 12:12:58 +0000 (+0000) Subject: Moved 'miss_access' ACL check to fwdStart() X-Git-Tag: SQUID_3_0_PRE1~3099 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1061d2b385d8abfda7c6e8dc3e00235049d9697;p=thirdparty%2Fsquid.git Moved 'miss_access' ACL check to fwdStart() --- diff --git a/src/asn.cc b/src/asn.cc index e0db099ec5..016c0d3150 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,5 +1,5 @@ /* - * $Id: asn.cc,v 1.39 1998/06/04 18:57:07 wessels Exp $ + * $Id: asn.cc,v 1.40 1998/07/14 06:12:58 wessels Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -182,7 +182,7 @@ asnCacheStart(int as) if ((e = storeGet(k)) == NULL) { e = storeCreateEntry(asres, asres, 0, METHOD_GET); storeClientListAdd(e, asState); - fwdStart(-1, e, asState->request); + fwdStart(-1, e, asState->request, any_addr); } else { storeLockObject(e); storeClientListAdd(e, asState); diff --git a/src/client_side.cc b/src/client_side.cc index c19b0e7de5..fd7b5c4f9b 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.344 1998/07/09 19:21:00 rousskov Exp $ + * $Id: client_side.cc,v 1.345 1998/07/14 06:12:58 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -269,7 +269,8 @@ clientProcessExpired(void *data) entry->refcount++; /* EXPIRED CASE */ http->entry = entry; http->out.offset = 0; - fwdStart(http->conn->fd, http->entry, http->request); + fwdStart(http->conn->fd, http->entry, http->request, + http->conn->peer.sin_addr); /* Register with storage manager to receive updates when data comes in. */ if (entry->store_status == STORE_ABORTED) debug(33, 0) ("clientProcessExpired: entry->swap_status == STORE_ABORTED\n"); @@ -1996,28 +1997,12 @@ clientProcessMiss(clientHttpRequest * http) errorAppendEntry(http->entry, err); return; } - /* - * Check if this host is allowed to fetch MISSES from us (miss_access) - */ - memset(&ch, '\0', sizeof(aclCheck_t)); - ch.src_addr = http->conn->peer.sin_addr; - ch.request = r; - answer = aclCheckFast(Config.accessList.miss, &ch); - if (answer == 0) { - http->al.http.code = HTTP_FORBIDDEN; - err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN); - err->request = requestLink(r); - err->src_addr = http->conn->peer.sin_addr; - http->entry = clientCreateStoreEntry(http, r->method, 0); - errorAppendEntry(http->entry, err); - return; - } assert(http->out.offset == 0); http->entry = clientCreateStoreEntry(http, r->method, r->flags); http->entry->refcount++; if (http->flags.internal) r->protocol = PROTO_INTERNAL; - fwdStart(http->conn->fd, http->entry, r); + fwdStart(http->conn->fd, http->entry, r, http->conn->peer.sin_addr); } static clientHttpRequest * diff --git a/src/forward.cc b/src/forward.cc index aa1b991b13..787e669970 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.16 1998/07/13 21:37:15 wessels Exp $ + * $Id: forward.cc,v 1.17 1998/07/14 06:12:59 wessels Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -310,39 +310,52 @@ fwdDispatch(FwdState * fwdState) /* PUBLIC FUNCTIONS */ void -fwdStart(int fd, StoreEntry * entry, request_t * request) +fwdStart(int fd, StoreEntry * e, request_t * r, struct in_addr peer_addr) { FwdState *fwdState; - debug(17, 3) ("fwdStart: '%s'\n", storeUrl(entry)); - entry->mem_obj->request = requestLink(request); - entry->mem_obj->fd = fd; - switch (request->protocol) { + aclCheck_t ch; + int answer; + ErrorState *err; + /* + * Check if this host is allowed to fetch MISSES from us (miss_access) + */ + memset(&ch, '\0', sizeof(aclCheck_t)); + ch.src_addr = peer_addr; + ch.request = r; + answer = aclCheckFast(Config.accessList.miss, &ch); + if (answer == 0) { + err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN); + err->request = requestLink(r); + err->src_addr = peer_addr; + errorAppendEntry(e, err); + return; + } + debug(17, 3) ("fwdStart: '%s'\n", storeUrl(e)); + e->mem_obj->request = requestLink(r); + e->mem_obj->fd = fd; + switch (r->protocol) { /* * Note, don't create fwdState for these requests */ case PROTO_INTERNAL: - internalStart(request, entry); + internalStart(r, e); return; case PROTO_CACHEOBJ: - cachemgrStart(fd, request, entry); + cachemgrStart(fd, r, e); return; default: break; } fwdState = memAllocate(MEM_FWD_STATE); cbdataAdd(fwdState, MEM_FWD_STATE); - fwdState->entry = entry; + fwdState->entry = e; fwdState->client_fd = fd; fwdState->server_fd = -1; - fwdState->request = requestLink(request); + fwdState->request = requestLink(r); fwdState->start = squid_curtime; - storeLockObject(entry); - storeRegisterAbort(entry, fwdAbort, fwdState); - peerSelect(request, - entry, - fwdStartComplete, - fwdStartFail, - fwdState); + storeLockObject(e); + storeRegisterAbort(e, fwdAbort, fwdState); + peerSelect(r, e, fwdStartComplete, fwdStartFail, fwdState); } /* This is called before reading data from the server side to diff --git a/src/net_db.cc b/src/net_db.cc index f224e55a73..00a2b45933 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.115 1998/06/04 19:50:48 wessels Exp $ + * $Id: net_db.cc,v 1.116 1998/07/14 06:13:00 wessels Exp $ * * DEBUG: section 37 Network Measurement Database * AUTHOR: Duane Wessels @@ -1065,7 +1065,7 @@ netdbExchangeStart(void *data) storeClientCopy(ex->e, ex->seen, ex->used, ex->buf_sz, ex->buf, netdbExchangeHandleReply, ex); EBIT_SET(ex->r->flags, REQ_LOOPDETECT); /* cheat! -- force direct */ - fwdStart(-1, ex->e, ex->r); + fwdStart(-1, ex->e, ex->r, any_addr); #endif } diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 80b6bc894f..a9017b2bf3 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.39 1998/06/30 15:08:10 rousskov Exp $ + * $Id: peer_digest.cc,v 1.40 1998/07/14 06:13:00 wessels Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -291,7 +291,7 @@ peerDigestRequest(peer * p) fetch->offset = 0; debug(72, 3) ("peerDigestRequest: forwarding to fwdStart...\n"); /* push towards peer cache */ - fwdStart(-1, e, req); + fwdStart(-1, e, req, any_addr); storeClientCopy(e, 0, 0, SM_PAGE_SIZE, memAllocate(MEM_4K_BUF), peerDigestFetchReply, fetch); } diff --git a/src/protos.h b/src/protos.h index 1182b8a43e..7c108ff3c5 100644 --- a/src/protos.h +++ b/src/protos.h @@ -588,7 +588,7 @@ extern void peerSelectInit(void); extern EVH peerDigestInit; /* forward.c */ -extern void fwdStart(int, StoreEntry *, request_t *); +extern void fwdStart(int, StoreEntry *, request_t *, struct in_addr); extern int fwdAbortFetch(StoreEntry * entry); extern DEFER fwdCheckDeferRead; extern void fwdFail(FwdState *, int, http_status, int); diff --git a/src/urn.cc b/src/urn.cc index 0b595535a0..9e6fdd3a96 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,7 +1,7 @@ /* * - * $Id: urn.cc,v 1.36 1998/06/05 21:25:52 rousskov Exp $ + * $Id: urn.cc,v 1.37 1998/07/14 06:13:01 wessels Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -143,7 +143,7 @@ urnStart(request_t * r, StoreEntry * e) if ((urlres_e = storeGet(k)) == NULL) { urlres_e = storeCreateEntry(urlres, urlres, 0, METHOD_GET); storeClientListAdd(urlres_e, urnState); - fwdStart(-1, urlres_e, urlres_r); + fwdStart(-1, urlres_e, urlres_r, any_addr); } else { storeLockObject(urlres_e); storeClientListAdd(urlres_e, urnState);