Mercurial > hg > nginx-quic
comparison src/http/ngx_http_core_module.c @ 7624:1055e43e4fab
Made ngx_http_get_forwarded_addr_internal() non-recursive.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Tue, 11 Feb 2020 13:22:44 +0300 |
parents | 02a539522be4 |
children | f001d9384293 |
comparison
equal
deleted
inserted
replaced
7623:72b792bb3885 | 7624:1055e43e4fab |
---|---|
2665 static ngx_int_t | 2665 static ngx_int_t |
2666 ngx_http_get_forwarded_addr_internal(ngx_http_request_t *r, ngx_addr_t *addr, | 2666 ngx_http_get_forwarded_addr_internal(ngx_http_request_t *r, ngx_addr_t *addr, |
2667 u_char *xff, size_t xfflen, ngx_array_t *proxies, int recursive) | 2667 u_char *xff, size_t xfflen, ngx_array_t *proxies, int recursive) |
2668 { | 2668 { |
2669 u_char *p; | 2669 u_char *p; |
2670 ngx_int_t rc; | |
2671 ngx_addr_t paddr; | 2670 ngx_addr_t paddr; |
2672 | 2671 ngx_uint_t found; |
2673 if (ngx_cidr_match(addr->sockaddr, proxies) != NGX_OK) { | 2672 |
2674 return NGX_DECLINED; | 2673 found = 0; |
2675 } | 2674 |
2676 | 2675 do { |
2677 for (p = xff + xfflen - 1; p > xff; p--, xfflen--) { | 2676 |
2678 if (*p != ' ' && *p != ',') { | 2677 if (ngx_cidr_match(addr->sockaddr, proxies) != NGX_OK) { |
2679 break; | 2678 return found ? NGX_DONE : NGX_DECLINED; |
2680 } | 2679 } |
2681 } | 2680 |
2682 | 2681 for (p = xff + xfflen - 1; p > xff; p--, xfflen--) { |
2683 for ( /* void */ ; p > xff; p--) { | 2682 if (*p != ' ' && *p != ',') { |
2684 if (*p == ' ' || *p == ',') { | 2683 break; |
2685 p++; | 2684 } |
2686 break; | 2685 } |
2687 } | 2686 |
2688 } | 2687 for ( /* void */ ; p > xff; p--) { |
2689 | 2688 if (*p == ' ' || *p == ',') { |
2690 if (ngx_parse_addr_port(r->pool, &paddr, p, xfflen - (p - xff)) != NGX_OK) { | 2689 p++; |
2691 return NGX_DECLINED; | 2690 break; |
2692 } | 2691 } |
2693 | 2692 } |
2694 *addr = paddr; | 2693 |
2695 | 2694 if (ngx_parse_addr_port(r->pool, &paddr, p, xfflen - (p - xff)) |
2696 if (recursive && p > xff) { | 2695 != NGX_OK) |
2697 rc = ngx_http_get_forwarded_addr_internal(r, addr, xff, p - 1 - xff, | 2696 { |
2698 proxies, 1); | 2697 return found ? NGX_DONE : NGX_DECLINED; |
2699 | 2698 } |
2700 if (rc == NGX_DECLINED) { | 2699 |
2701 return NGX_DONE; | 2700 *addr = paddr; |
2702 } | 2701 found = 1; |
2703 | 2702 xfflen = p - 1 - xff; |
2704 /* rc == NGX_OK || rc == NGX_DONE */ | 2703 |
2705 return rc; | 2704 } while (recursive && p > xff); |
2706 } | |
2707 | 2705 |
2708 return NGX_OK; | 2706 return NGX_OK; |
2709 } | 2707 } |
2710 | 2708 |
2711 | 2709 |