diff --git a/src/http_fetch.c b/src/http_fetch.c index 7b4e41d85f..0d78fa54ac 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -1179,10 +1180,10 @@ static int smp_fetch_base32(const struct arg *args, struct sample *smp, const ch */ static int smp_fetch_base32_src(const struct arg *args, struct sample *smp, const char *kw, void *private) { + const struct sockaddr_storage *src = (smp->strm ? si_src(&smp->strm->si[0]) : NULL); struct buffer *temp; - struct connection *cli_conn = objt_conn(smp->sess->origin); - if (!cli_conn || !conn_get_src(cli_conn)) + if (!src) return 0; if (!smp_fetch_base32(args, smp, kw, private)) @@ -1192,16 +1193,16 @@ static int smp_fetch_base32_src(const struct arg *args, struct sample *smp, cons *(unsigned int *) temp->area = htonl(smp->data.u.sint); temp->data += sizeof(unsigned int); - switch (cli_conn->src->ss_family) { + switch (src->ss_family) { case AF_INET: memcpy(temp->area + temp->data, - &((struct sockaddr_in *)cli_conn->src)->sin_addr, + &((struct sockaddr_in *)src)->sin_addr, 4); temp->data += 4; break; case AF_INET6: memcpy(temp->area + temp->data, - &((struct sockaddr_in6 *)cli_conn->src)->sin6_addr, + &((struct sockaddr_in6 *)src)->sin6_addr, 16); temp->data += 16; break; @@ -2041,10 +2042,10 @@ static int smp_fetch_url32(const struct arg *args, struct sample *smp, const cha */ static int smp_fetch_url32_src(const struct arg *args, struct sample *smp, const char *kw, void *private) { + const struct sockaddr_storage *src = (smp->strm ? si_src(&smp->strm->si[0]) : NULL); struct buffer *temp; - struct connection *cli_conn = objt_conn(smp->sess->origin); - if (!cli_conn || !conn_get_src(cli_conn)) + if (!src) return 0; if (!smp_fetch_url32(args, smp, kw, private)) @@ -2054,16 +2055,16 @@ static int smp_fetch_url32_src(const struct arg *args, struct sample *smp, const *(unsigned int *) temp->area = htonl(smp->data.u.sint); temp->data += sizeof(unsigned int); - switch (cli_conn->src->ss_family) { + switch (src->ss_family) { case AF_INET: memcpy(temp->area + temp->data, - &((struct sockaddr_in *)cli_conn->src)->sin_addr, + &((struct sockaddr_in *)src)->sin_addr, 4); temp->data += 4; break; case AF_INET6: memcpy(temp->area + temp->data, - &((struct sockaddr_in6 *)cli_conn->src)->sin6_addr, + &((struct sockaddr_in6 *)src)->sin6_addr, 16); temp->data += 16; break;