From: Willy Tarreau Date: Sat, 19 Jan 2008 12:46:35 +0000 (+0100) Subject: [MINOR] use s->frt_addr as the server's address in transparent proxy X-Git-Tag: v1.3.15~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd41428fee1a9cdf589a5b2be33e3e55b0e1046f;p=thirdparty%2Fhaproxy.git [MINOR] use s->frt_addr as the server's address in transparent proxy There's no point trying to check original dest addr with only one method when doing transparent proxy as in full transparent mode, the real destination address is required. Let's copy the one from the frontend. --- diff --git a/src/backend.c b/src/backend.c index 1617a1877c..5ea6590d89 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1015,12 +1015,13 @@ int assign_server_address(struct session *s) } else if (s->fe->options & PR_O_TRANSP) { /* in transparent mode, use the original dest addr if no dispatch specified */ - socklen_t salen = sizeof(s->srv_addr); + if (!(s->flags & SN_FRT_ADDR_SET)) + get_frt_addr(s); - if (get_original_dst(s->cli_fd, &s->srv_addr, &salen) == -1) { - qfprintf(stderr, "Cannot get original server address.\n"); - return SRV_STATUS_INTERNAL; - } + memcpy(&s->srv_addr, &s->frt_addr, MIN(sizeof(s->srv_addr), sizeof(s->frt_addr))); + /* when we support IPv6 on the backend, we may add other tests */ + //qfprintf(stderr, "Cannot get original server address.\n"); + //return SRV_STATUS_INTERNAL; } else if (s->be->options & PR_O_HTTP_PROXY) { /* If HTTP PROXY option is set, then server is already assigned