summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_access_module.c6
-rw-r--r--src/http/modules/ngx_http_geo_module.c4
-rw-r--r--src/http/modules/ngx_http_realip_module.c6
-rw-r--r--src/http/modules/ngx_http_upstream_ip_hash_module.c20
4 files changed, 26 insertions, 10 deletions
diff --git a/src/http/modules/ngx_http_access_module.c b/src/http/modules/ngx_http_access_module.c
index 12f0b9922..8cd2e0e13 100644
--- a/src/http/modules/ngx_http_access_module.c
+++ b/src/http/modules/ngx_http_access_module.c
@@ -9,8 +9,6 @@
#include <ngx_http.h>
-/* AF_INET only */
-
typedef struct {
in_addr_t mask;
in_addr_t addr;
@@ -103,6 +101,10 @@ ngx_http_access_handler(ngx_http_request_t *r)
/* AF_INET only */
+ if (r->connection->sockaddr->sa_family != AF_INET) {
+ return NGX_DECLINED;
+ }
+
sin = (struct sockaddr_in *) r->connection->sockaddr;
rule = alcf->rules->elts;
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
index bd6499ec7..a8f26854b 100644
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -175,6 +175,10 @@ ngx_http_geo_addr(ngx_http_request_t *r, ngx_http_geo_ctx_t *ctx)
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http geo started: %V", &r->connection->addr_text);
+ if (r->connection->sockaddr->sa_family != AF_INET) {
+ return 0;
+ }
+
sin = (struct sockaddr_in *) r->connection->sockaddr;
return ntohl(sin->sin_addr.s_addr);
}
diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
index 44c74a182..58bdeeb37 100644
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -14,8 +14,6 @@
#define NGX_HTTP_REALIP_HEADER 2
-/* AF_INET only */
-
typedef struct {
in_addr_t mask;
in_addr_t addr;
@@ -209,6 +207,10 @@ found:
/* AF_INET only */
+ if (r->connection->sockaddr->sa_family != AF_INET) {
+ return NGX_DECLINED;
+ }
+
sin = (struct sockaddr_in *) c->sockaddr;
from = rlcf->from->elts;
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
index 1d13481a9..dffbf22b2 100644
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -15,7 +15,6 @@ typedef struct {
ngx_uint_t hash;
- /* AF_INET only */
u_char addr[3];
u_char tries;
@@ -111,11 +110,20 @@ ngx_http_upstream_init_ip_hash_peer(ngx_http_request_t *r,
r->upstream->peer.get = ngx_http_upstream_get_ip_hash_peer;
/* AF_INET only */
- sin = (struct sockaddr_in *) r->connection->sockaddr;
- p = (u_char *) &sin->sin_addr.s_addr;
- iphp->addr[0] = p[0];
- iphp->addr[1] = p[1];
- iphp->addr[2] = p[2];
+
+ if (r->connection->sockaddr->sa_family == AF_INET) {
+
+ sin = (struct sockaddr_in *) r->connection->sockaddr;
+ p = (u_char *) &sin->sin_addr.s_addr;
+ iphp->addr[0] = p[0];
+ iphp->addr[1] = p[1];
+ iphp->addr[2] = p[2];
+
+ } else {
+ iphp->addr[0] = 0;
+ iphp->addr[1] = 0;
+ iphp->addr[2] = 0;
+ }
iphp->hash = 89;
iphp->tries = 0;