[BB#95] Fix FilterURLs with transparent proxy support.
Pass a pointer to a char pointer to do_transparent_proxy so the reassembled URL will actually end up back in the caller where it is needed for filtering decisions. This fixes the problem that a tinyproxy configured with the transparent proxy functionality and "FilterURLs Yes" would filter on everything but the domain. Signed-off-by: daniel.egger@sphairon.com Signed-off-by: Michael Adam <obnox@samba.org>
This commit is contained in:
parent
c4b187c8ab
commit
d13d575d29
@ -418,7 +418,7 @@ BAD_REQUEST_ERROR:
|
|||||||
} else {
|
} else {
|
||||||
#ifdef TRANSPARENT_PROXY
|
#ifdef TRANSPARENT_PROXY
|
||||||
if (!do_transparent_proxy
|
if (!do_transparent_proxy
|
||||||
(connptr, hashofheaders, request, &config, url)) {
|
(connptr, hashofheaders, request, &config, &url)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -55,11 +55,11 @@ static int build_url (char **url, const char *host, int port, const char *path)
|
|||||||
int
|
int
|
||||||
do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
|
do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
|
||||||
struct request_s *request, struct config_s *conf,
|
struct request_s *request, struct config_s *conf,
|
||||||
char *url)
|
char **url)
|
||||||
{
|
{
|
||||||
socklen_t length;
|
socklen_t length;
|
||||||
char *data;
|
char *data;
|
||||||
size_t ulen = strlen (url);
|
size_t ulen = strlen (*url);
|
||||||
|
|
||||||
length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
|
length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
@ -73,7 +73,7 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
|
|||||||
connptr->client_fd);
|
connptr->client_fd);
|
||||||
indicate_http_error (connptr, 400, "Bad Request",
|
indicate_http_error (connptr, 400, "Bad Request",
|
||||||
"detail", "Unknown destination",
|
"detail", "Unknown destination",
|
||||||
"url", url, NULL);
|
"url", *url, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,15 +83,15 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
|
|||||||
request->port = ntohs (dest_addr.sin_port);
|
request->port = ntohs (dest_addr.sin_port);
|
||||||
|
|
||||||
request->path = (char *) safemalloc (ulen + 1);
|
request->path = (char *) safemalloc (ulen + 1);
|
||||||
strlcpy (request->path, url, ulen + 1);
|
strlcpy (request->path, *url, ulen + 1);
|
||||||
|
|
||||||
/* url overwritten by the call below is the url passed
|
/* url overwritten by the call below is the url passed
|
||||||
* to this function, and is not the url variable in the
|
* to this function, and is not the url variable in the
|
||||||
* caller. */
|
* caller. */
|
||||||
build_url (&url, request->host, request->port, request->path);
|
build_url (url, request->host, request->port, request->path);
|
||||||
log_message (LOG_INFO,
|
log_message (LOG_INFO,
|
||||||
"process_request: trans IP %s %s for %d",
|
"process_request: trans IP %s %s for %d",
|
||||||
request->method, url, connptr->client_fd);
|
request->method, *url, connptr->client_fd);
|
||||||
} else {
|
} else {
|
||||||
request->host = (char *) safemalloc (length + 1);
|
request->host = (char *) safemalloc (length + 1);
|
||||||
if (sscanf (data, "%[^:]:%hu", request->host, &request->port) !=
|
if (sscanf (data, "%[^:]:%hu", request->host, &request->port) !=
|
||||||
@ -101,15 +101,15 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
|
|||||||
}
|
}
|
||||||
|
|
||||||
request->path = (char *) safemalloc (ulen + 1);
|
request->path = (char *) safemalloc (ulen + 1);
|
||||||
strlcpy (request->path, url, ulen + 1);
|
strlcpy (request->path, *url, ulen + 1);
|
||||||
|
|
||||||
/* url overwritten by the call below is the url passed
|
/* url overwritten by the call below is the url passed
|
||||||
* to this function, and is not the url variable in the
|
* to this function, and is not the url variable in the
|
||||||
* caller. */
|
* caller. */
|
||||||
build_url (&url, request->host, request->port, request->path);
|
build_url (url, request->host, request->port, request->path);
|
||||||
log_message (LOG_INFO,
|
log_message (LOG_INFO,
|
||||||
"process_request: trans Host %s %s for %d",
|
"process_request: trans Host %s %s for %d",
|
||||||
request->method, url, connptr->client_fd);
|
request->method, *url, connptr->client_fd);
|
||||||
}
|
}
|
||||||
if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) {
|
if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) {
|
||||||
log_message (LOG_ERR,
|
log_message (LOG_ERR,
|
||||||
@ -118,7 +118,7 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
|
|||||||
indicate_http_error (connptr, 400, "Bad Request",
|
indicate_http_error (connptr, 400, "Bad Request",
|
||||||
"detail",
|
"detail",
|
||||||
"You tried to connect to the machine "
|
"You tried to connect to the machine "
|
||||||
"the proxy is running on", "url", url,
|
"the proxy is running on", "url", *url,
|
||||||
NULL);
|
NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
extern int do_transparent_proxy (struct conn_s *connptr,
|
extern int do_transparent_proxy (struct conn_s *connptr,
|
||||||
hashmap_t hashofheaders,
|
hashmap_t hashofheaders,
|
||||||
struct request_s *request,
|
struct request_s *request,
|
||||||
struct config_s *config, char *url);
|
struct config_s *config, char **url);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user