summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2020-08-13 19:28:27 +0300
committerAndrei Belov <defan@nginx.com>2020-08-13 19:28:27 +0300
commitaff76e4f90b4e948c327ce2b021dc3203c33cbcd (patch)
tree5bd6ac3aa92683777548472984c209bf26d8a971 /src/nxt_conf_validation.c
parent04ce9f997e0e49e57ce4b5fc4aa98134232a1974 (diff)
parent6473d4b65a99aa10d509220fb99d8c4f65631ed0 (diff)
downloadunit-1.19.0-1.tar.gz
unit-1.19.0-1.tar.bz2
Merged with the default branch.1.19.0-1
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c208
1 files changed, 164 insertions, 44 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index c4f78608..b5530b85 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -31,6 +31,11 @@ typedef enum {
|NXT_CONF_VLDT_OBJECT)
+typedef enum {
+ NXT_CONF_VLDT_REQUIRED = 1,
+} nxt_conf_vldt_flags_t;
+
+
typedef nxt_int_t (*nxt_conf_vldt_handler_t)(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value,
void *data);
@@ -38,14 +43,15 @@ typedef nxt_int_t (*nxt_conf_vldt_handler_t)(nxt_conf_validation_t *vldt,
typedef struct {
nxt_str_t name;
- nxt_conf_vldt_type_t type;
+ nxt_conf_vldt_type_t type:32;
+ nxt_conf_vldt_flags_t flags:32;
nxt_conf_vldt_handler_t validator;
void *data;
} nxt_conf_vldt_object_t;
-#define NXT_CONF_VLDT_NEXT(f) { nxt_null_string, 0, NULL, (f) }
-#define NXT_CONF_VLDT_END { nxt_null_string, 0, NULL, NULL }
+#define NXT_CONF_VLDT_NEXT(f) { nxt_null_string, 0, 0, NULL, (f) }
+#define NXT_CONF_VLDT_END { nxt_null_string, 0, 0, NULL, NULL }
typedef nxt_int_t (*nxt_conf_vldt_member_t)(nxt_conf_validation_t *vldt,
@@ -58,6 +64,8 @@ static nxt_int_t nxt_conf_vldt_type(nxt_conf_validation_t *vldt,
nxt_str_t *name, nxt_conf_value_t *value, nxt_conf_vldt_type_t type);
static nxt_int_t nxt_conf_vldt_error(nxt_conf_validation_t *vldt,
const char *fmt, ...);
+static nxt_int_t nxt_conf_vldt_var(nxt_conf_validation_t *vldt,
+ const char *option, nxt_str_t *value);
static nxt_int_t nxt_conf_vldt_mtypes(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
@@ -165,16 +173,19 @@ static nxt_int_t nxt_conf_vldt_clone_gidmap(nxt_conf_validation_t *vldt,
static nxt_conf_vldt_object_t nxt_conf_vldt_websocket_members[] = {
{ nxt_string("read_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("keepalive_interval"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("max_frame_size"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
@@ -185,6 +196,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_websocket_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[] = {
{ nxt_string("mime_types"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_mtypes,
NULL },
@@ -195,46 +207,55 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[] = {
{ nxt_string("header_read_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("body_read_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("send_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("idle_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("body_buffer_size"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("max_body_size"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("body_temp_path"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("websocket"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_websocket_members },
{ nxt_string("static"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_static_members },
@@ -245,6 +266,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_setting_members[] = {
{ nxt_string("http"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_http_members },
@@ -255,31 +277,37 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_setting_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_root_members[] = {
{ nxt_string("settings"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_setting_members },
{ nxt_string("listeners"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_listener },
{ nxt_string("routes"),
NXT_CONF_VLDT_ARRAY | NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_routes,
NULL },
{ nxt_string("applications"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_app },
{ nxt_string("upstreams"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_upstream },
{ nxt_string("access_log"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
@@ -292,6 +320,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_root_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_tls_members[] = {
{ nxt_string("certificate"),
NXT_CONF_VLDT_STRING,
+ 0,
&nxt_conf_vldt_certificate,
NULL },
@@ -304,11 +333,13 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_tls_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = {
{ nxt_string("pass"),
NXT_CONF_VLDT_STRING,
+ 0,
&nxt_conf_vldt_pass,
NULL },
{ nxt_string("application"),
NXT_CONF_VLDT_STRING,
+ 0,
&nxt_conf_vldt_app_name,
NULL },
@@ -316,6 +347,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = {
{ nxt_string("tls"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_tls_members },
@@ -328,46 +360,55 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_match_members[] = {
{ nxt_string("method"),
NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_patterns,
NULL },
{ nxt_string("scheme"),
NXT_CONF_VLDT_STRING,
+ 0,
&nxt_conf_vldt_match_scheme_pattern,
NULL },
{ nxt_string("host"),
NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_patterns,
NULL },
{ nxt_string("source"),
NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_addrs,
NULL },
{ nxt_string("destination"),
NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_addrs,
NULL },
{ nxt_string("uri"),
NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_encoded_patterns,
NULL },
{ nxt_string("arguments"),
NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_encoded_patterns_sets,
NULL },
{ nxt_string("headers"),
NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_patterns_sets,
NULL },
{ nxt_string("cookies"),
NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_match_patterns_sets,
NULL },
@@ -378,6 +419,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_match_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_pass_action_members[] = {
{ nxt_string("pass"),
NXT_CONF_VLDT_STRING,
+ 0,
&nxt_conf_vldt_pass,
NULL },
@@ -388,11 +430,13 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_pass_action_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_return_action_members[] = {
{ nxt_string("return"),
NXT_CONF_VLDT_INTEGER,
+ 0,
&nxt_conf_vldt_return,
NULL },
{ nxt_string("location"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
@@ -403,11 +447,13 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_return_action_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_share_action_members[] = {
{ nxt_string("share"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("fallback"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_action,
NULL },
@@ -418,6 +464,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_share_action_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_proxy_action_members[] = {
{ nxt_string("proxy"),
NXT_CONF_VLDT_STRING,
+ 0,
&nxt_conf_vldt_proxy,
NULL },
@@ -428,11 +475,13 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_proxy_action_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_route_members[] = {
{ nxt_string("match"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_match_members },
{ nxt_string("action"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_action,
NULL },
@@ -443,21 +492,25 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_route_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_app_limits_members[] = {
{ nxt_string("timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("reschedule_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("requests"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("shm"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
@@ -468,16 +521,19 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_limits_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_app_processes_members[] = {
{ nxt_string("spare"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("max"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("idle_timeout"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
@@ -490,6 +546,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
#if (NXT_HAVE_CLONE_NEWUSER)
{ nxt_string("credential"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
#endif
@@ -497,6 +554,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
#if (NXT_HAVE_CLONE_NEWPID)
{ nxt_string("pid"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
#endif
@@ -504,6 +562,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
#if (NXT_HAVE_CLONE_NEWNET)
{ nxt_string("network"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
#endif
@@ -511,6 +570,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
#if (NXT_HAVE_CLONE_NEWNS)
{ nxt_string("mount"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
#endif
@@ -518,6 +578,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
#if (NXT_HAVE_CLONE_NEWUTS)
{ nxt_string("uname"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
#endif
@@ -525,6 +586,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
#if (NXT_HAVE_CLONE_NEWCGROUP)
{ nxt_string("cgroup"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
#endif
@@ -538,18 +600,23 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_app_procmap_members[] = {
{ nxt_string("container"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("host"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
{ nxt_string("size"),
NXT_CONF_VLDT_INTEGER,
+ 0,
NULL,
NULL },
+
+ NXT_CONF_VLDT_END
};
#endif
@@ -558,6 +625,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_procmap_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[] = {
{ nxt_string("namespaces"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_clone_namespaces,
(void *) &nxt_conf_vldt_app_namespaces_members },
@@ -565,11 +633,13 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[] = {
{ nxt_string("uidmap"),
NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_array_iterator,
(void *) &nxt_conf_vldt_clone_uidmap },
{ nxt_string("gidmap"),
NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_array_iterator,
(void *) &nxt_conf_vldt_clone_gidmap },
@@ -579,6 +649,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[] = {
{ nxt_string("rootfs"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
@@ -588,6 +659,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[] = {
{ nxt_string("new_privs"),
NXT_CONF_VLDT_BOOLEAN,
+ 0,
NULL,
NULL },
@@ -600,41 +672,49 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[] = {
{ nxt_string("type"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("limits"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_app_limits_members },
{ nxt_string("processes"),
NXT_CONF_VLDT_INTEGER | NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_processes,
(void *) &nxt_conf_vldt_app_processes_members },
{ nxt_string("user"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("group"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("working_directory"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("environment"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_environment },
{ nxt_string("isolation"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_isolation,
(void *) &nxt_conf_vldt_app_isolation_members },
@@ -645,11 +725,13 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_external_members[] = {
{ nxt_string("executable"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
{ nxt_string("arguments"),
NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_array_iterator,
(void *) &nxt_conf_vldt_argument },
@@ -660,16 +742,19 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_external_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
{ nxt_string("home"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("path"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("module"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
@@ -680,34 +765,42 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_php_target_members[] = {
{ nxt_string("root"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
{ nxt_string("script"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("index"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
- NULL }
+ NULL },
+
+ NXT_CONF_VLDT_END
};
static nxt_conf_vldt_object_t nxt_conf_vldt_php_options_members[] = {
{ nxt_string("file"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("admin"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_php_option },
{ nxt_string("user"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_php_option },
@@ -718,6 +811,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_options_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_php_common_members[] = {
{ nxt_string("options"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object,
(void *) &nxt_conf_vldt_php_options_members },
@@ -728,16 +822,19 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_common_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_php_notargets_members[] = {
{ nxt_string("root"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
{ nxt_string("script"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
{ nxt_string("index"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
@@ -748,21 +845,25 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_notargets_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
{ nxt_string("root"),
NXT_CONF_VLDT_ANY_TYPE,
+ 0,
&nxt_conf_vldt_php_targets_exclusive,
(void *) "root" },
{ nxt_string("script"),
NXT_CONF_VLDT_ANY_TYPE,
+ 0,
&nxt_conf_vldt_php_targets_exclusive,
(void *) "script" },
{ nxt_string("index"),
NXT_CONF_VLDT_ANY_TYPE,
+ 0,
&nxt_conf_vldt_php_targets_exclusive,
(void *) "index" },
{ nxt_string("targets"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_php_targets,
NULL },
@@ -773,6 +874,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_perl_members[] = {
{ nxt_string("script"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
@@ -783,6 +885,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_perl_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_ruby_members[] = {
{ nxt_string("script"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
@@ -793,21 +896,25 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_ruby_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_java_members[] = {
{ nxt_string("classpath"),
NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_array_iterator,
(void *) &nxt_conf_vldt_java_classpath },
{ nxt_string("webapp"),
NXT_CONF_VLDT_STRING,
+ NXT_CONF_VLDT_REQUIRED,
NULL,
NULL },
{ nxt_string("options"),
NXT_CONF_VLDT_ARRAY,
+ 0,
&nxt_conf_vldt_array_iterator,
(void *) &nxt_conf_vldt_java_option },
{ nxt_string("unit_jars"),
NXT_CONF_VLDT_STRING,
+ 0,
NULL,
NULL },
@@ -818,6 +925,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_java_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_upstream_members[] = {
{ nxt_string("servers"),
NXT_CONF_VLDT_OBJECT,
+ 0,
&nxt_conf_vldt_object_iterator,
(void *) &nxt_conf_vldt_server },
@@ -828,6 +936,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_upstream_members[] = {
static nxt_conf_vldt_object_t nxt_conf_vldt_upstream_server_members[] = {
{ nxt_string("weight"),
NXT_CONF_VLDT_NUMBER,
+ 0,
&nxt_conf_vldt_server_weight,
NULL },
@@ -861,7 +970,7 @@ nxt_conf_vldt_type(nxt_conf_validation_t *vldt, nxt_str_t *name,
{
u_char *p;
nxt_str_t expected;
- nxt_bool_t serial;
+ nxt_bool_t comma;
nxt_uint_t value_type, n, t;
u_char buf[nxt_length(NXT_CONF_VLDT_ANY_TYPE_STR)];
@@ -889,7 +998,7 @@ nxt_conf_vldt_type(nxt_conf_validation_t *vldt, nxt_str_t *name,
p = nxt_cpymem(p, "either ", 7);
}
- serial = (n > 2);
+ comma = (n > 2);
for ( ;; ) {
t = __builtin_ffs(type) - 1;
@@ -902,7 +1011,7 @@ nxt_conf_vldt_type(nxt_conf_validation_t *vldt, nxt_str_t *name,
break;
}
- if (n > 1 || serial) {
+ if (comma) {
*p++ = ',';
}
@@ -958,6 +1067,21 @@ nxt_conf_vldt_error(nxt_conf_validation_t *vldt, const char *fmt, ...)
}
+static nxt_int_t
+nxt_conf_vldt_var(nxt_conf_validation_t *vldt, const char *option,
+ nxt_str_t *value)
+{
+ u_char error[NXT_MAX_ERROR_STR];
+
+ if (nxt_var_test(value, error) != NXT_OK) {
+ return nxt_conf_vldt_error(vldt, "%s in the \"%s\" value.",
+ error, option);
+ }
+
+ return NXT_OK;
+}
+
+
typedef struct {
nxt_mp_t *pool;
nxt_str_t *type;
@@ -1135,6 +1259,10 @@ nxt_conf_vldt_pass(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
nxt_conf_get_string(value, &pass);
+ if (nxt_is_var(&pass)) {
+ return nxt_conf_vldt_var(vldt, "pass", &pass);
+ }
+
ret = nxt_http_pass_segments(vldt->pool, &pass, segments, 3);
if (ret != NXT_OK) {
@@ -1346,16 +1474,9 @@ static nxt_int_t
nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value)
{
- u_char ch;
nxt_str_t pattern;
nxt_uint_t i, first, last;
- enum {
- sw_none,
- sw_side,
- sw_middle
- } state;
-
if (nxt_conf_type(value) != NXT_CONF_STRING) {
return nxt_conf_vldt_error(vldt, "The \"match\" patterns for \"host\", "
"\"uri\", and \"method\" must be strings.");
@@ -1369,37 +1490,11 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
first = (pattern.start[0] == '!');
last = pattern.length - 1;
- state = sw_none;
-
- for (i = first; i != pattern.length; i++) {
- ch = pattern.start[i];
-
- if (ch != '*') {
- continue;
- }
-
- switch (state) {
- case sw_none:
- state = (i == first) ? sw_side : sw_middle;
- break;
-
- case sw_side:
- if (i == last) {
- if (last - first != 1) {
- break;
- }
-
- return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
- "not contain double \"*\" markers.");
- }
-
- /* Fall through. */
-
- case sw_middle:
- return nxt_conf_vldt_error(vldt, "The \"match\" patterns can "
- "either contain \"*\" markers at "
- "the sides or only one in the middle.");
+ for (i = first; i < last; i++) {
+ if (pattern.start[i] == '*' && pattern.start[i + 1] == '*') {
+ return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
+ "not contain double \"*\" markers.");
}
}
@@ -1759,6 +1854,31 @@ nxt_conf_vldt_object(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
nxt_conf_value_t *member;
nxt_conf_vldt_object_t *vals;
+ vals = data;
+
+ for ( ;; ) {
+ if (vals->name.length == 0) {
+
+ if (vals->data != NULL) {
+ vals = vals->data;
+ continue;
+ }
+
+ break;
+ }
+
+ if (vals->flags & NXT_CONF_VLDT_REQUIRED) {
+ member = nxt_conf_get_object_member(value, &vals->name, NULL);
+
+ if (member == NULL) {
+ return nxt_conf_vldt_error(vldt, "Required parameter \"%V\" "
+ "is missing.", &vals->name);
+ }
+ }
+
+ vals++;
+ }
+
index = 0;
for ( ;; ) {