summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-11-23 00:15:48 +0100
committerMichael Adam <obnox@samba.org>2013-11-23 00:18:04 +0100
commitb3ac7d2c7bebea4bb4c489ad60648e4da30a251a (patch)
tree045bf1665fa96ff37c3cb60f0c2d8d484b97dc65 /src
parentb92d70be0747c8157c9d881a64bcea5547b228f9 (diff)
downloadtinyproxy-b3ac7d2c7bebea4bb4c489ad60648e4da30a251a.tar.gz
tinyproxy-b3ac7d2c7bebea4bb4c489ad60648e4da30a251a.zip
transparent: make transparent support compile after introduction of multi Listen
I seem to have forgotten to compile with transparent support enabled... This belongs to the fix for bug BB#63. Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/transparent-proxy.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/transparent-proxy.c b/src/transparent-proxy.c
index 843f22c..5d0c8f6 100644
--- a/src/transparent-proxy.c
+++ b/src/transparent-proxy.c
@@ -60,6 +60,7 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
socklen_t length;
char *data;
size_t ulen = strlen (*url);
+ ssize_t i;
length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
if (length <= 0) {
@@ -105,16 +106,28 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
"process_request: trans Host %s %s for %d",
request->method, *url, connptr->client_fd);
}
- if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) {
- log_message (LOG_ERR,
- "process_request: destination IP is localhost %d",
- connptr->client_fd);
- indicate_http_error (connptr, 400, "Bad Request",
- "detail",
- "You tried to connect to the machine "
- "the proxy is running on", "url", *url,
- NULL);
- return 0;
+
+ if (conf->listen_addrs == NULL) {
+ return 1;
+ }
+
+ for (i = 0; i < vector_length(conf->listen_addrs); i++) {
+ const char *addr;
+
+ addr = (char *)vector_getentry(conf->listen_addrs, i, NULL);
+
+ if (addr && strcmp(request->host, addr) == 0) {
+ log_message(LOG_ERR,
+ "transparent: destination IP %s is local "
+ "on socket fd %d",
+ request->host, connptr->client_fd);
+ indicate_http_error(connptr, 400, "Bad Request",
+ "detail",
+ "You tried to connect to the "
+ "machine the proxy is running on",
+ "url", *url, NULL);
+ return 0;
+ }
}
return 1;