diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-02-28 12:12:30 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-07-26 16:24:33 +0200 |
commit | 6e36584a2e9bad0e7c4f96d68c527992deadc650 (patch) | |
tree | 927317d737b55d0bdec616d01cd39e10cbcb6f32 | |
parent | c1cea3c97d5dfc260a54cab67b7dc1637a3deb59 (diff) | |
download | unit-6e36584a2e9bad0e7c4f96d68c527992deadc650.tar.gz unit-6e36584a2e9bad0e7c4f96d68c527992deadc650.tar.bz2 |
Supporting UNIX sockets in address matching.
This closes #645 issue on GitHub.
(Also moved a changelog line that was misplaced in a previous commit.)
Diffstat (limited to '')
-rw-r--r-- | docs/changes.xml | 19 | ||||
-rw-r--r-- | src/nxt_conf_validation.c | 5 | ||||
-rw-r--r-- | src/nxt_http_route.c | 7 | ||||
-rw-r--r-- | src/nxt_http_route_addr.c | 10 | ||||
-rw-r--r-- | src/nxt_http_route_addr.h | 1 |
5 files changed, 35 insertions, 7 deletions
diff --git a/docs/changes.xml b/docs/changes.xml index 66965311..8c4b5cf0 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -33,6 +33,12 @@ NGINX Unit updated to 1.28.0. <change type="feature"> <para> +supporting UNIX sockets in address matching. +</para> +</change> + +<change type="feature"> +<para> forwarded header to replace client address and protocol. </para> </change> @@ -49,6 +55,12 @@ more http variables support. </para> </change> +<change type="feature"> +<para> +added a new variable, $dollar, that translates to a literal "$" during +</para> +</change> + <change type="bugfix"> <para> an index file that didn't contain a file extension was incorrectly @@ -62,13 +74,6 @@ increased the applications' startup timeout. </para> </change> -<change type="feature"> -<para> -added a new variable, $dollar, that translates to a literal "$" during -variable substitution. -</para> -</change> - </changes> diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c index 47164e92..8c532914 100644 --- a/src/nxt_conf_validation.c +++ b/src/nxt_conf_validation.c @@ -2157,6 +2157,11 @@ nxt_conf_vldt_match_addr(nxt_conf_validation_t *vldt, return nxt_conf_vldt_error(vldt, "The \"address\" does not support " "IPv6 with your configuration."); + case NXT_ADDR_PATTERN_NO_UNIX_ERROR: + return nxt_conf_vldt_error(vldt, "The \"address\" does not support " + "UNIX domain sockets with your " + "configuration."); + default: return nxt_conf_vldt_error(vldt, "The \"address\" has an unknown " "format."); diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c index e00c37fe..cdc9077f 100644 --- a/src/nxt_http_route.c +++ b/src/nxt_http_route.c @@ -1818,6 +1818,13 @@ nxt_http_route_addr_pattern_match(nxt_http_route_addr_pattern_t *p, break; #endif +#if (NXT_HAVE_UNIX_DOMAIN) + case AF_UNIX: + + match = (base->addr_family == AF_UNIX); + break; +#endif + default: match = 0; break; diff --git a/src/nxt_http_route_addr.c b/src/nxt_http_route_addr.c index 985fb737..34455af4 100644 --- a/src/nxt_http_route_addr.c +++ b/src/nxt_http_route_addr.c @@ -41,6 +41,16 @@ nxt_http_route_addr_pattern_parse(nxt_mp_t *mp, base->negative = 0; } + if (nxt_str_eq(&addr, "unix", 4)) { +#if (NXT_HAVE_UNIX_DOMAIN) + base->addr_family = AF_UNIX; + + return NXT_OK; +#else + return NXT_ADDR_PATTERN_NO_UNIX_ERROR; +#endif + } + if (nxt_slow_path(addr.length < 2)) { return NXT_ADDR_PATTERN_LENGTH_ERROR; } diff --git a/src/nxt_http_route_addr.h b/src/nxt_http_route_addr.h index 3b1e1da3..2deda6f8 100644 --- a/src/nxt_http_route_addr.h +++ b/src/nxt_http_route_addr.h @@ -26,6 +26,7 @@ enum { NXT_ADDR_PATTERN_RANGE_OVERLAP_ERROR, NXT_ADDR_PATTERN_CIDR_ERROR, NXT_ADDR_PATTERN_NO_IPv6_ERROR, + NXT_ADDR_PATTERN_NO_UNIX_ERROR, }; |