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>
This commit is contained in:
Michael Adam 2013-11-23 00:15:48 +01:00
parent b92d70be07
commit b3ac7d2c7b

View File

@ -60,6 +60,7 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
socklen_t length; socklen_t length;
char *data; char *data;
size_t ulen = strlen (*url); size_t ulen = strlen (*url);
ssize_t i;
length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data); length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
if (length <= 0) { if (length <= 0) {
@ -105,17 +106,29 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
"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->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, log_message(LOG_ERR,
"process_request: destination IP is localhost %d", "transparent: destination IP %s is local "
connptr->client_fd); "on socket fd %d",
request->host, connptr->client_fd);
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 "
"the proxy is running on", "url", *url, "machine the proxy is running on",
NULL); "url", *url, NULL);
return 0; return 0;
} }
}
return 1; return 1;
} }