~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/icp_v3.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
1
/*
3
 
 * $Id: icp_v3.cc,v 1.42 2007/04/28 22:26:37 hno Exp $
 
2
 * $Id$
4
3
 *
5
 
 * DEBUG: section 12    Internet Cache Protocol
 
4
 * DEBUG: section 12    Internet Cache Protocol (ICP)
6
5
 * AUTHOR: Duane Wessels
7
6
 *
8
7
 * SQUID Web Proxy Cache          http://www.squid-cache.org/
21
20
 *  it under the terms of the GNU General Public License as published by
22
21
 *  the Free Software Foundation; either version 2 of the License, or
23
22
 *  (at your option) any later version.
24
 
 *  
 
23
 *
25
24
 *  This program is distributed in the hope that it will be useful,
26
25
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
27
26
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
27
 *  GNU General Public License for more details.
29
 
 *  
 
28
 *
30
29
 *  You should have received a copy of the GNU General Public License
31
30
 *  along with this program; if not, write to the Free Software
32
31
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33
32
 *
34
33
 */
35
34
 
 
35
/**
 
36
 \defgroup ServerProtocolICPInternal3 ICPv3 Internals
 
37
 \ingroup ServerProtocolICPAPI
 
38
 */
 
39
 
36
40
#include "squid.h"
37
41
#include "Store.h"
38
42
#include "ICP.h"
39
43
#include "HttpRequest.h"
40
44
 
 
45
/// \ingroup ServerProtocolICPInternal3
41
46
class ICP3State : public ICPState, public StoreClient
42
47
{
43
48
 
44
49
public:
45
 
    ICP3State(icp_common_t &aHeader, HttpRequest *aRequest):
46
 
        ICPState(aHeader, aRequest)
47
 
        {}
 
50
    ICP3State(icp_common_t &aHeader, HttpRequest *aRequest) :
 
51
            ICPState(aHeader, aRequest) {}
48
52
 
49
53
    ~ICP3State();
50
54
    void created (StoreEntry *newEntry);
51
55
};
52
56
 
 
57
/// \ingroup ServerProtocolICPInternal3
53
58
static void
54
 
 
55
 
doV3Query(int fd, struct sockaddr_in from, char *buf, icp_common_t header)
 
59
doV3Query(int fd, IpAddress &from, char *buf, icp_common_t header)
56
60
{
57
61
    /* We have a valid packet */
58
62
    char *url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
59
 
    HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, &from);
 
63
    HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, from);
60
64
 
61
65
    if (!icp_request)
62
66
        return;
63
67
 
64
 
    if (!icpAccessAllowed(&from, icp_request))
65
 
    {
66
 
        icpDenyAccess (&from, url, header.reqnum, fd);
 
68
    if (!icpAccessAllowed(from, icp_request)) {
 
69
        icpDenyAccess (from, url, header.reqnum, fd);
67
70
        delete icp_request;
68
71
        return;
69
72
    }
80
83
    StoreEntry::getPublic (state, url, METHOD_GET);
81
84
}
82
85
 
83
 
ICP3State::~ICP3State ()
 
86
ICP3State::~ICP3State()
84
87
{}
85
88
 
86
89
void
87
 
ICP3State::created (StoreEntry *newEntry)
 
90
ICP3State::created(StoreEntry *newEntry)
88
91
{
89
92
    StoreEntry *entry = newEntry->isNull () ? NULL : newEntry;
90
93
    debugs(12, 5, "icpHandleIcpV3: OPCODE " << icp_opcode_str[header.opcode]);
97
100
    else
98
101
        codeToSend = icpGetCommonOpcode();
99
102
 
100
 
    icpCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, &from);
 
103
    icpCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, from);
101
104
 
102
105
    delete this;
103
106
}
104
107
 
 
108
 
 
109
/// \ingroup ServerProtocolICPInternal3
105
110
/* Currently Harvest cached-2.x uses ICP_VERSION_3 */
106
111
void
107
 
 
108
 
icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
 
112
icpHandleIcpV3(int fd, IpAddress&from, char *buf, int len)
109
113
{
110
 
    if (len <= 0)
111
 
    {
 
114
    if (len <= 0) {
112
115
        debugs(12, 3, "icpHandleIcpV3: ICP message is too small");
113
116
        return;
114
117
    }
118
121
     * Length field should match the number of bytes read
119
122
     */
120
123
 
121
 
    if (len != header.length)
122
 
    {
 
124
    if (len != header.length) {
123
125
        debugs(12, 3, "icpHandleIcpV3: ICP message is too small");
124
126
        return;
125
127
    }
126
128
 
127
 
    switch (header.opcode)
128
 
    {
 
129
    switch (header.opcode) {
129
130
 
130
131
    case ICP_QUERY:
131
 
        doV3Query(fd, from,buf, header);
 
132
        doV3Query(fd, from, buf, header);
132
133
        break;
133
134
 
134
135
    case ICP_HIT:
135
 
#if ALLOW_SOURCE_PING
136
 
 
137
 
    case ICP_SECHO:
138
 
#endif
139
136
 
140
137
    case ICP_DECHO:
141
138
 
144
141
    case ICP_DENIED:
145
142
 
146
143
    case ICP_MISS_NOFETCH:
147
 
        header.handleReply(buf, &from);
 
144
        header.handleReply(buf, from);
148
145
        break;
149
146
 
150
147
    case ICP_INVALID:
153
150
        break;
154
151
 
155
152
    default:
156
 
        debugs(12, 0, "icpHandleIcpV3: UNKNOWN OPCODE: " << header.opcode << " from " << inet_ntoa(from.sin_addr));
 
153
        debugs(12, 0, "icpHandleIcpV3: UNKNOWN OPCODE: " << header.opcode << " from " << from);
157
154
        break;
158
155
    }
159
156
}