nxt_http_request.c (2123:36000da0aa5b) nxt_http_request.c (2132:34d63ed988dc)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

--- 300 unchanged lines hidden (view full) ---

309
310 nxt_http_request_read_body(task, r);
311}
312
313
314static nxt_int_t
315nxt_http_request_client_ip(nxt_task_t *task, nxt_http_request_t *r)
316{
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

--- 300 unchanged lines hidden (view full) ---

309
310 nxt_http_request_read_body(task, r);
311}
312
313
314static nxt_int_t
315nxt_http_request_client_ip(nxt_task_t *task, nxt_http_request_t *r)
316{
317 u_char *start, *p;
318 nxt_int_t ret, i, len;
319 nxt_str_t *header;
320 nxt_array_t *fields_arr; /* of nxt_http_field_t * */
321 nxt_sockaddr_t *sa, *prev_sa;
322 nxt_http_field_t *f, **fields;
323 nxt_http_client_ip_t *client_ip;
317 u_char *start, *p;
318 nxt_int_t ret, i, len;
319 nxt_str_t *header;
320 nxt_array_t *fields_arr; /* of nxt_http_field_t * */
321 nxt_sockaddr_t *sa, *prev_sa;
322 nxt_http_field_t *f, **fields;
323 nxt_http_forward_t *forward;
324 nxt_http_forward_header_t *client_ip;
324
325
325 client_ip = r->conf->socket_conf->client_ip;
326 forward = r->conf->socket_conf->client_ip;
326
327
327 if (client_ip == NULL) {
328 if (forward == NULL) {
328 return NXT_OK;
329 }
330
329 return NXT_OK;
330 }
331
331 ret = nxt_http_route_addr_rule(r, client_ip->source, r->remote);
332 ret = nxt_http_route_addr_rule(r, forward->source, r->remote);
332 if (ret <= 0) {
333 return NXT_OK;
334 }
335
333 if (ret <= 0) {
334 return NXT_OK;
335 }
336
337 client_ip = &forward->client_ip;
336 header = client_ip->header;
337
338 fields_arr = nxt_array_create(r->mem_pool, 2, sizeof(nxt_http_field_t *));
339 if (nxt_slow_path(fields_arr == NULL)) {
340 return NXT_ERROR;
341 }
342
343 nxt_list_each(f, r->fields) {

--- 39 unchanged lines hidden (view full) ---

383 if (nxt_slow_path(sa == NULL)) {
384 if (prev_sa != NULL) {
385 r->remote = prev_sa;
386 }
387
388 return NXT_OK;
389 }
390
338 header = client_ip->header;
339
340 fields_arr = nxt_array_create(r->mem_pool, 2, sizeof(nxt_http_field_t *));
341 if (nxt_slow_path(fields_arr == NULL)) {
342 return NXT_ERROR;
343 }
344
345 nxt_list_each(f, r->fields) {

--- 39 unchanged lines hidden (view full) ---

385 if (nxt_slow_path(sa == NULL)) {
386 if (prev_sa != NULL) {
387 r->remote = prev_sa;
388 }
389
390 return NXT_OK;
391 }
392
391 if (!client_ip->recursive) {
393 if (!forward->recursive) {
392 r->remote = sa;
393
394 return NXT_OK;
395 }
396
394 r->remote = sa;
395
396 return NXT_OK;
397 }
398
397 ret = nxt_http_route_addr_rule(r, client_ip->source, sa);
399 ret = nxt_http_route_addr_rule(r, forward->source, sa);
398 if (ret <= 0 || (i == 0 && p == start)) {
399 r->remote = sa;
400
401 return NXT_OK;
402 }
403
404 prev_sa = sa;
405 len = p - 1 - start;

--- 704 unchanged lines hidden ---
400 if (ret <= 0 || (i == 0 && p == start)) {
401 r->remote = sa;
402
403 return NXT_OK;
404 }
405
406 prev_sa = sa;
407 len = p - 1 - start;

--- 704 unchanged lines hidden ---