summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2019-11-14 16:39:54 +0300
committerIgor Sysoev <igor@sysoev.ru>2019-11-14 16:39:54 +0300
commitddde9c23cf302309d85ccc24b35075ce94da89a0 (patch)
tree2bf729e8f0315cd4c775be572c0f01688d11bf03 /src/nxt_conf_validation.c
parent57e326b4119863f737d8677adc69dc53c7e4ed27 (diff)
downloadunit-ddde9c23cf302309d85ccc24b35075ce94da89a0.tar.gz
unit-ddde9c23cf302309d85ccc24b35075ce94da89a0.tar.bz2
Initial proxy support.
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 3cfecbad..105af675 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -62,6 +62,8 @@ static nxt_int_t nxt_conf_vldt_action(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_pass(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
+static nxt_int_t nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
@@ -316,6 +318,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_action_members[] = {
NULL,
NULL },
+ { nxt_string("proxy"),
+ NXT_CONF_VLDT_STRING,
+ &nxt_conf_vldt_proxy,
+ NULL },
+
NXT_CONF_VLDT_END
};
@@ -885,10 +892,11 @@ nxt_conf_vldt_action(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
void *data)
{
nxt_int_t ret;
- nxt_conf_value_t *pass_value, *share_value;
+ nxt_conf_value_t *pass_value, *share_value, *proxy_value;
static nxt_str_t pass_str = nxt_string("pass");
static nxt_str_t share_str = nxt_string("share");
+ static nxt_str_t proxy_str = nxt_string("proxy");
ret = nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_action_members);
@@ -898,11 +906,12 @@ nxt_conf_vldt_action(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
pass_value = nxt_conf_get_object_member(value, &pass_str, NULL);
share_value = nxt_conf_get_object_member(value, &share_str, NULL);
+ proxy_value = nxt_conf_get_object_member(value, &proxy_str, NULL);
- if (pass_value == NULL && share_value == NULL) {
+ if (pass_value == NULL && share_value == NULL && proxy_value == NULL) {
return nxt_conf_vldt_error(vldt, "The \"action\" object must have "
- "either \"pass\" or \"share\" "
- "option set.");
+ "either \"pass\" or \"share\" or "
+ "\"proxy\" option set.");
}
return NXT_OK;
@@ -993,6 +1002,30 @@ error:
static nxt_int_t
+nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
+ void *data)
+{
+ nxt_str_t name;
+ nxt_sockaddr_t *sa;
+
+ nxt_conf_get_string(value, &name);
+
+ if (nxt_str_start(&name, "http://", 7)) {
+ name.length -= 7;
+ name.start += 7;
+
+ sa = nxt_sockaddr_parse(vldt->pool, &name);
+ if (sa != NULL) {
+ return NXT_OK;
+ }
+ }
+
+ return nxt_conf_vldt_error(vldt, "The \"proxy\" address is invalid \"%V\"",
+ &name);
+}
+
+
+static nxt_int_t
nxt_conf_vldt_routes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
void *data)
{