diff src/http/modules/ngx_http_geo_module.c @ 7430:286ae954009d

Geo: fixed handling of AF_UNIX client addresses (ticket #1684). Previously, AF_UNIX client addresses were handled as AF_INET, leading to unexpected results.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 14 Dec 2018 18:11:06 +0300
parents 88aad69eccef
children ef6a3a99a81a
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -215,6 +215,13 @@ ngx_http_geo_cidr_variable(ngx_http_requ
         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_req
             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);