mirror of
https://github.com/nginx/nginx.git
synced 2024-12-01 03:17:17 +08:00
Geo: fixed handling of AF_UNIX client addresses (ticket #1684).
Previously, AF_UNIX client addresses were handled as AF_INET, leading to unexpected results.
This commit is contained in:
parent
cb4dd56771
commit
ce4a23d144
@ -215,6 +215,13 @@ ngx_http_geo_cidr_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
case AF_UNIX:
|
||||
vv = (ngx_http_variable_value_t *)
|
||||
ngx_radix32tree_find(ctx->u.trees.tree, INADDR_NONE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: /* AF_INET */
|
||||
sin = (struct sockaddr_in *) addr.sockaddr;
|
||||
inaddr = ntohl(sin->sin_addr.s_addr);
|
||||
@ -277,6 +284,12 @@ ngx_http_geo_range_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
case AF_UNIX:
|
||||
inaddr = INADDR_NONE;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: /* AF_INET */
|
||||
sin = (struct sockaddr_in *) addr.sockaddr;
|
||||
inaddr = ntohl(sin->sin_addr.s_addr);
|
||||
|
@ -206,6 +206,13 @@ ngx_stream_geo_cidr_variable(ngx_stream_session_t *s,
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
case AF_UNIX:
|
||||
vv = (ngx_stream_variable_value_t *)
|
||||
ngx_radix32tree_find(ctx->u.trees.tree, INADDR_NONE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: /* AF_INET */
|
||||
sin = (struct sockaddr_in *) addr.sockaddr;
|
||||
inaddr = ntohl(sin->sin_addr.s_addr);
|
||||
@ -268,6 +275,12 @@ ngx_stream_geo_range_variable(ngx_stream_session_t *s,
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||
case AF_UNIX:
|
||||
inaddr = INADDR_NONE;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: /* AF_INET */
|
||||
sin = (struct sockaddr_in *) addr.sockaddr;
|
||||
inaddr = ntohl(sin->sin_addr.s_addr);
|
||||
|
Loading…
Reference in New Issue
Block a user