1116Svbart@nginx.com
2116Svbart@nginx.com /*
3116Svbart@nginx.com * Copyright (C) Valentin V. Bartenev
4116Svbart@nginx.com * Copyright (C) NGINX, Inc.
52634Salx@kernel.org * Copyright 2024, Alejandro Colomar <alx@kernel.org>
6116Svbart@nginx.com */
7116Svbart@nginx.com
8116Svbart@nginx.com #include <nxt_main.h>
9116Svbart@nginx.com #include <nxt_conf.h>
10774Svbart@nginx.com #include <nxt_cert.h>
112450Sz.hong@f5.com #include <nxt_script.h>
12444Sigor@sysoev.ru #include <nxt_router.h>
131183Svbart@nginx.com #include <nxt_http.h>
141324Saxel.duch@nginx.com #include <nxt_sockaddr.h>
151324Saxel.duch@nginx.com #include <nxt_http_route_addr.h>
161721Saxel.duch@nginx.com #include <nxt_regex.h>
17116Svbart@nginx.com
18116Svbart@nginx.com
19487Svbart@nginx.com typedef enum {
20487Svbart@nginx.com NXT_CONF_VLDT_NULL = 1 << NXT_CONF_NULL,
21487Svbart@nginx.com NXT_CONF_VLDT_BOOLEAN = 1 << NXT_CONF_BOOLEAN,
22487Svbart@nginx.com NXT_CONF_VLDT_INTEGER = 1 << NXT_CONF_INTEGER,
231439Svbart@nginx.com NXT_CONF_VLDT_NUMBER = (1 << NXT_CONF_NUMBER) | NXT_CONF_VLDT_INTEGER,
24487Svbart@nginx.com NXT_CONF_VLDT_STRING = 1 << NXT_CONF_STRING,
25487Svbart@nginx.com NXT_CONF_VLDT_ARRAY = 1 << NXT_CONF_ARRAY,
26487Svbart@nginx.com NXT_CONF_VLDT_OBJECT = 1 << NXT_CONF_OBJECT,
27487Svbart@nginx.com } nxt_conf_vldt_type_t;
28487Svbart@nginx.com
291473Svbart@nginx.com #define NXT_CONF_VLDT_ANY_TYPE (NXT_CONF_VLDT_NULL \
301473Svbart@nginx.com |NXT_CONF_VLDT_BOOLEAN \
311473Svbart@nginx.com |NXT_CONF_VLDT_NUMBER \
321473Svbart@nginx.com |NXT_CONF_VLDT_STRING \
331473Svbart@nginx.com |NXT_CONF_VLDT_ARRAY \
341473Svbart@nginx.com |NXT_CONF_VLDT_OBJECT)
351473Svbart@nginx.com
361473Svbart@nginx.com
371525Svbart@nginx.com typedef enum {
381959Sz.hong@f5.com NXT_CONF_VLDT_REQUIRED = 1 << 0,
392247Sz.hong@f5.com NXT_CONF_VLDT_TSTR = 1 << 1,
401525Svbart@nginx.com } nxt_conf_vldt_flags_t;
411525Svbart@nginx.com
421525Svbart@nginx.com
431473Svbart@nginx.com typedef nxt_int_t (*nxt_conf_vldt_handler_t)(nxt_conf_validation_t *vldt,
441473Svbart@nginx.com nxt_conf_value_t *value,
451473Svbart@nginx.com void *data);
46357Svbart@nginx.com typedef nxt_int_t (*nxt_conf_vldt_member_t)(nxt_conf_validation_t *vldt,
47137Svbart@nginx.com nxt_str_t *name,
48116Svbart@nginx.com nxt_conf_value_t *value);
49685Svbart@nginx.com typedef nxt_int_t (*nxt_conf_vldt_element_t)(nxt_conf_validation_t *vldt,
50685Svbart@nginx.com nxt_conf_value_t *value);
51276Sigor@sysoev.ru
521651Sigor@sysoev.ru
531651Sigor@sysoev.ru typedef struct nxt_conf_vldt_object_s nxt_conf_vldt_object_t;
541651Sigor@sysoev.ru
551651Sigor@sysoev.ru struct nxt_conf_vldt_object_s {
561651Sigor@sysoev.ru nxt_str_t name;
571651Sigor@sysoev.ru nxt_conf_vldt_type_t type:32;
581651Sigor@sysoev.ru nxt_conf_vldt_flags_t flags:32;
591651Sigor@sysoev.ru nxt_conf_vldt_handler_t validator;
601651Sigor@sysoev.ru
611651Sigor@sysoev.ru union {
621651Sigor@sysoev.ru nxt_conf_vldt_object_t *members;
631651Sigor@sysoev.ru nxt_conf_vldt_object_t *next;
641651Sigor@sysoev.ru nxt_conf_vldt_member_t object;
651651Sigor@sysoev.ru nxt_conf_vldt_element_t array;
661651Sigor@sysoev.ru const char *string;
671651Sigor@sysoev.ru } u;
681651Sigor@sysoev.ru };
691651Sigor@sysoev.ru
701651Sigor@sysoev.ru
711651Sigor@sysoev.ru #define NXT_CONF_VLDT_NEXT(next) { .u.members = next }
721651Sigor@sysoev.ru #define NXT_CONF_VLDT_END { .name = nxt_null_string }
731651Sigor@sysoev.ru
741651Sigor@sysoev.ru
75357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_type(nxt_conf_validation_t *vldt,
76487Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value, nxt_conf_vldt_type_t type);
77357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_error(nxt_conf_validation_t *vldt,
78357Svbart@nginx.com const char *fmt, ...);
791959Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_var(nxt_conf_validation_t *vldt, nxt_str_t *name,
801959Sz.hong@f5.com nxt_str_t *value);
812625Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_if(nxt_conf_validation_t *vldt,
822625Sz.hong@f5.com nxt_conf_value_t *value, void *data);
831855Sz.hong@f5.com nxt_inline nxt_int_t nxt_conf_vldt_unsupported(nxt_conf_validation_t *vldt,
842079Salx.manpages@gmail.com nxt_conf_value_t *value, void *data)
852079Salx.manpages@gmail.com NXT_MAYBE_UNUSED;
86357Svbart@nginx.com
871183Svbart@nginx.com static nxt_int_t nxt_conf_vldt_mtypes(nxt_conf_validation_t *vldt,
881183Svbart@nginx.com nxt_conf_value_t *value, void *data);
891183Svbart@nginx.com static nxt_int_t nxt_conf_vldt_mtypes_type(nxt_conf_validation_t *vldt,
901183Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value);
911183Svbart@nginx.com static nxt_int_t nxt_conf_vldt_mtypes_extension(nxt_conf_validation_t *vldt,
921183Svbart@nginx.com nxt_conf_value_t *value);
93357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_listener(nxt_conf_validation_t *vldt,
94357Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value);
95774Svbart@nginx.com #if (NXT_TLS)
96774Svbart@nginx.com static nxt_int_t nxt_conf_vldt_certificate(nxt_conf_validation_t *vldt,
97774Svbart@nginx.com nxt_conf_value_t *value, void *data);
981885Sa.suvorov@f5.com #if (NXT_HAVE_OPENSSL_CONF_CMD)
991885Sa.suvorov@f5.com static nxt_int_t nxt_conf_vldt_object_conf_commands(nxt_conf_validation_t *vldt,
1001885Sa.suvorov@f5.com nxt_conf_value_t *value, void *data);
1011885Sa.suvorov@f5.com #endif
1021828Sa.suvorov@f5.com static nxt_int_t nxt_conf_vldt_certificate_element(nxt_conf_validation_t *vldt,
1031828Sa.suvorov@f5.com nxt_conf_value_t *value);
1041920Sa.suvorov@f5.com static nxt_int_t nxt_conf_vldt_tls_cache_size(nxt_conf_validation_t *vldt,
1051920Sa.suvorov@f5.com nxt_conf_value_t *value, void *data);
1061920Sa.suvorov@f5.com static nxt_int_t nxt_conf_vldt_tls_timeout(nxt_conf_validation_t *vldt,
1071920Sa.suvorov@f5.com nxt_conf_value_t *value, void *data);
1081942Sa.suvorov@f5.com #if (NXT_HAVE_OPENSSL_TLSEXT)
1091942Sa.suvorov@f5.com static nxt_int_t nxt_conf_vldt_ticket_key(nxt_conf_validation_t *vldt,
1101942Sa.suvorov@f5.com nxt_conf_value_t *value, void *data);
1111942Sa.suvorov@f5.com static nxt_int_t nxt_conf_vldt_ticket_key_element(nxt_conf_validation_t *vldt,
1121942Sa.suvorov@f5.com nxt_conf_value_t *value);
1131942Sa.suvorov@f5.com #endif
114774Svbart@nginx.com #endif
1151233Svbart@nginx.com static nxt_int_t nxt_conf_vldt_action(nxt_conf_validation_t *vldt,
1161233Svbart@nginx.com nxt_conf_value_t *value, void *data);
117965Svbart@nginx.com static nxt_int_t nxt_conf_vldt_pass(nxt_conf_validation_t *vldt,
118965Svbart@nginx.com nxt_conf_value_t *value, void *data);
1191429Svbart@nginx.com static nxt_int_t nxt_conf_vldt_return(nxt_conf_validation_t *vldt,
1201429Svbart@nginx.com nxt_conf_value_t *value, void *data);
1211961Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_share(nxt_conf_validation_t *vldt,
1222078Salx.manpages@gmail.com nxt_conf_value_t *value, void *data);
1231961Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_share_element(nxt_conf_validation_t *vldt,
1241961Sz.hong@f5.com nxt_conf_value_t *value);
1251270Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt,
1261270Sigor@sysoev.ru nxt_conf_value_t *value, void *data);
1271872So.canty@f5.com static nxt_int_t nxt_conf_vldt_python(nxt_conf_validation_t *vldt,
1281872So.canty@f5.com nxt_conf_value_t *value, void *data);
1291759Svbart@nginx.com static nxt_int_t nxt_conf_vldt_python_path(nxt_conf_validation_t *vldt,
1301759Svbart@nginx.com nxt_conf_value_t *value, void *data);
1311759Svbart@nginx.com static nxt_int_t nxt_conf_vldt_python_path_element(nxt_conf_validation_t *vldt,
1321759Svbart@nginx.com nxt_conf_value_t *value);
1331697Smax.romanov@nginx.com static nxt_int_t nxt_conf_vldt_python_protocol(nxt_conf_validation_t *vldt,
1341697Smax.romanov@nginx.com nxt_conf_value_t *value, void *data);
1352273Sjeff.iadarola@gmail.com static nxt_int_t nxt_conf_vldt_python_prefix(nxt_conf_validation_t *vldt,
1362273Sjeff.iadarola@gmail.com nxt_conf_value_t *value, void *data);
1371681Smax.romanov@nginx.com static nxt_int_t nxt_conf_vldt_threads(nxt_conf_validation_t *vldt,
1381681Smax.romanov@nginx.com nxt_conf_value_t *value, void *data);
1391681Smax.romanov@nginx.com static nxt_int_t nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
1401681Smax.romanov@nginx.com nxt_conf_value_t *value, void *data);
141966Svbart@nginx.com static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
142966Svbart@nginx.com nxt_conf_value_t *value, void *data);
143966Svbart@nginx.com static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
144966Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value);
145966Svbart@nginx.com static nxt_int_t nxt_conf_vldt_route(nxt_conf_validation_t *vldt,
146966Svbart@nginx.com nxt_conf_value_t *value);
1471474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_patterns_sets(
1481474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data);
1491474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_patterns_set(
1501474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value);
1511474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_patterns_set_member(
1521474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value);
1531474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_patterns(
1541474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data);
1551474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_pattern(
1561474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value);
157966Svbart@nginx.com static nxt_int_t nxt_conf_vldt_match_patterns(nxt_conf_validation_t *vldt,
158966Svbart@nginx.com nxt_conf_value_t *value, void *data);
159966Svbart@nginx.com static nxt_int_t nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
160966Svbart@nginx.com nxt_conf_value_t *value);
1611059Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t *vldt,
1621059Sigor@sysoev.ru nxt_conf_value_t *value, void *data);
1631059Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t *vldt,
1641059Sigor@sysoev.ru nxt_conf_value_t *value);
1651059Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_match_patterns_set_member(
1661059Sigor@sysoev.ru nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value);
1671110Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t *vldt,
1681110Saxel.duch@nginx.com nxt_conf_value_t *value, void *data);
1691324Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_addrs(nxt_conf_validation_t *vldt,
1701324Saxel.duch@nginx.com nxt_conf_value_t *value, void *data);
1711324Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_addr(nxt_conf_validation_t *vldt,
1721324Saxel.duch@nginx.com nxt_conf_value_t *value);
1732512Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt,
1742512Sz.hong@f5.com nxt_str_t *name, nxt_conf_value_t *value);
175357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt,
176137Svbart@nginx.com nxt_conf_value_t *value, void *data);
1772133Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_forwarded(nxt_conf_validation_t *vldt,
1782133Sz.hong@f5.com nxt_conf_value_t *value, void *data);
179357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_app(nxt_conf_validation_t *vldt,
180357Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value);
181357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_object(nxt_conf_validation_t *vldt,
182137Svbart@nginx.com nxt_conf_value_t *value, void *data);
183507Smax.romanov@nginx.com static nxt_int_t nxt_conf_vldt_processes(nxt_conf_validation_t *vldt,
184507Smax.romanov@nginx.com nxt_conf_value_t *value, void *data);
185357Svbart@nginx.com static nxt_int_t nxt_conf_vldt_object_iterator(nxt_conf_validation_t *vldt,
186137Svbart@nginx.com nxt_conf_value_t *value, void *data);
187685Svbart@nginx.com static nxt_int_t nxt_conf_vldt_array_iterator(nxt_conf_validation_t *vldt,
188685Svbart@nginx.com nxt_conf_value_t *value, void *data);
189678Svbart@nginx.com static nxt_int_t nxt_conf_vldt_environment(nxt_conf_validation_t *vldt,
190678Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value);
1911879So.canty@f5.com static nxt_int_t nxt_conf_vldt_targets_exclusive(
1921879So.canty@f5.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data);
1931879So.canty@f5.com static nxt_int_t nxt_conf_vldt_targets(nxt_conf_validation_t *vldt,
1941879So.canty@f5.com nxt_conf_value_t *value, void *data);
1951879So.canty@f5.com static nxt_int_t nxt_conf_vldt_target(nxt_conf_validation_t *vldt,
1961879So.canty@f5.com nxt_str_t *name, nxt_conf_value_t *value);
197685Svbart@nginx.com static nxt_int_t nxt_conf_vldt_argument(nxt_conf_validation_t *vldt,
198685Svbart@nginx.com nxt_conf_value_t *value);
1991473Svbart@nginx.com static nxt_int_t nxt_conf_vldt_php(nxt_conf_validation_t *vldt,
2001473Svbart@nginx.com nxt_conf_value_t *value, void *data);
201688Svbart@nginx.com static nxt_int_t nxt_conf_vldt_php_option(nxt_conf_validation_t *vldt,
202688Svbart@nginx.com nxt_str_t *name, nxt_conf_value_t *value);
203977Smax.romanov@gmail.com static nxt_int_t nxt_conf_vldt_java_classpath(nxt_conf_validation_t *vldt,
204977Smax.romanov@gmail.com nxt_conf_value_t *value);
205977Smax.romanov@gmail.com static nxt_int_t nxt_conf_vldt_java_option(nxt_conf_validation_t *vldt,
206977Smax.romanov@gmail.com nxt_conf_value_t *value);
2071394Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_upstream(nxt_conf_validation_t *vldt,
2082078Salx.manpages@gmail.com nxt_str_t *name, nxt_conf_value_t *value);
2091394Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_server(nxt_conf_validation_t *vldt,
2101394Sigor@sysoev.ru nxt_str_t *name, nxt_conf_value_t *value);
2111394Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_server_weight(nxt_conf_validation_t *vldt,
2121394Sigor@sysoev.ru nxt_conf_value_t *value, void *data);
2132166Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_access_log(nxt_conf_validation_t *vldt,
2142166Sz.hong@f5.com nxt_conf_value_t *value, void *data);
215116Svbart@nginx.com
2161235Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_isolation(nxt_conf_validation_t *vldt,
2171235Sigor@sysoev.ru nxt_conf_value_t *value, void *data);
2181235Sigor@sysoev.ru static nxt_int_t nxt_conf_vldt_clone_namespaces(nxt_conf_validation_t *vldt,
2191182St.nateldemoura@f5.com nxt_conf_value_t *value, void *data);
2201182St.nateldemoura@f5.com
2211182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWUSER)
2221182St.nateldemoura@f5.com static nxt_int_t nxt_conf_vldt_clone_uidmap(nxt_conf_validation_t *vldt,
2231182St.nateldemoura@f5.com nxt_conf_value_t *value);
2241182St.nateldemoura@f5.com static nxt_int_t nxt_conf_vldt_clone_gidmap(nxt_conf_validation_t *vldt,
2251182St.nateldemoura@f5.com nxt_conf_value_t *value);
2261182St.nateldemoura@f5.com #endif
227116Svbart@nginx.com
2282262Sa.clayton@nginx.com #if (NXT_HAVE_CGROUP)
2292262Sa.clayton@nginx.com static nxt_int_t nxt_conf_vldt_cgroup_path(nxt_conf_validation_t *vldt,
2302262Sa.clayton@nginx.com nxt_conf_value_t *value, void *data);
2312262Sa.clayton@nginx.com #endif
2322262Sa.clayton@nginx.com
2332450Sz.hong@f5.com #if (NXT_HAVE_NJS)
2342450Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_js_module(nxt_conf_validation_t *vldt,
2352450Sz.hong@f5.com nxt_conf_value_t *value, void *data);
2362450Sz.hong@f5.com static nxt_int_t nxt_conf_vldt_js_module_element(nxt_conf_validation_t *vldt,
2372450Sz.hong@f5.com nxt_conf_value_t *value);
2382450Sz.hong@f5.com #endif
2392450Sz.hong@f5.com
2401649Sigor@sysoev.ru
2411649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_setting_members[];
2421649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[];
2431649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_websocket_members[];
2441649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[];
2452133Sz.hong@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_forwarded_members[];
2461936So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_client_ip_members[];
2471649Sigor@sysoev.ru #if (NXT_TLS)
2481649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_tls_members[];
2491920Sa.suvorov@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_session_members[];
2501649Sigor@sysoev.ru #endif
2511649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_match_members[];
2521879So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_python_target_members[];
2531649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_common_members[];
2541649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_options_members[];
2551879So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_php_target_members[];
2562519Sa.clayton@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_wasm_access_members[];
2571649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[];
2581649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_limits_members[];
2591649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_processes_members[];
2601649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[];
2611649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[];
2622262Sa.clayton@nginx.com #if (NXT_HAVE_CGROUP)
2632262Sa.clayton@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_app_cgroup_members[];
2642262Sa.clayton@nginx.com #endif
2651649Sigor@sysoev.ru #if (NXT_HAVE_ISOLATION_ROOTFS)
2661649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_automount_members[];
2671649Sigor@sysoev.ru #endif
2682166Sz.hong@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_access_log_members[];
2691649Sigor@sysoev.ru
2701649Sigor@sysoev.ru
2711649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_root_members[] = {
2721650Sigor@sysoev.ru {
2731650Sigor@sysoev.ru .name = nxt_string("settings"),
2741650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
2751651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
2761651Sigor@sysoev.ru .u.members = nxt_conf_vldt_setting_members,
2771650Sigor@sysoev.ru }, {
2781650Sigor@sysoev.ru .name = nxt_string("listeners"),
2791650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
2801651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
2811651Sigor@sysoev.ru .u.object = nxt_conf_vldt_listener,
2821650Sigor@sysoev.ru }, {
2831650Sigor@sysoev.ru .name = nxt_string("routes"),
2841650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ARRAY | NXT_CONF_VLDT_OBJECT,
2851651Sigor@sysoev.ru .validator = nxt_conf_vldt_routes,
2861650Sigor@sysoev.ru }, {
2871650Sigor@sysoev.ru .name = nxt_string("applications"),
2881650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
2891651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
2901651Sigor@sysoev.ru .u.object = nxt_conf_vldt_app,
2911650Sigor@sysoev.ru }, {
2921650Sigor@sysoev.ru .name = nxt_string("upstreams"),
2931650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
2941651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
2951651Sigor@sysoev.ru .u.object = nxt_conf_vldt_upstream,
2961650Sigor@sysoev.ru }, {
2971650Sigor@sysoev.ru .name = nxt_string("access_log"),
2982166Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_OBJECT,
2992166Sz.hong@f5.com .validator = nxt_conf_vldt_access_log,
3001650Sigor@sysoev.ru },
3011131Smax.romanov@nginx.com
3021131Smax.romanov@nginx.com NXT_CONF_VLDT_END
3031131Smax.romanov@nginx.com };
3041131Smax.romanov@nginx.com
3051131Smax.romanov@nginx.com
3061649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_setting_members[] = {
3071650Sigor@sysoev.ru {
3081650Sigor@sysoev.ru .name = nxt_string("http"),
3091650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
3101651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
3111651Sigor@sysoev.ru .u.members = nxt_conf_vldt_http_members,
3122450Sz.hong@f5.com #if (NXT_HAVE_NJS)
3132450Sz.hong@f5.com }, {
3142450Sz.hong@f5.com .name = nxt_string("js_module"),
3152450Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
3162450Sz.hong@f5.com .validator = nxt_conf_vldt_js_module,
3172450Sz.hong@f5.com #endif
3181650Sigor@sysoev.ru },
3191183Svbart@nginx.com
3201183Svbart@nginx.com NXT_CONF_VLDT_END
3211183Svbart@nginx.com };
3221183Svbart@nginx.com
3231183Svbart@nginx.com
324716Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[] = {
3251650Sigor@sysoev.ru {
3261650Sigor@sysoev.ru .name = nxt_string("header_read_timeout"),
3271650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3281650Sigor@sysoev.ru }, {
3291650Sigor@sysoev.ru .name = nxt_string("body_read_timeout"),
3301650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3311650Sigor@sysoev.ru }, {
3321650Sigor@sysoev.ru .name = nxt_string("send_timeout"),
3331650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3341650Sigor@sysoev.ru }, {
3351650Sigor@sysoev.ru .name = nxt_string("idle_timeout"),
3361650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3371650Sigor@sysoev.ru }, {
3382265Sa.clayton@nginx.com .name = nxt_string("large_header_buffer_size"),
3392265Sa.clayton@nginx.com .type = NXT_CONF_VLDT_INTEGER,
3402265Sa.clayton@nginx.com }, {
3412266Sa.clayton@nginx.com .name = nxt_string("large_header_buffers"),
3422266Sa.clayton@nginx.com .type = NXT_CONF_VLDT_INTEGER,
3432266Sa.clayton@nginx.com }, {
3441650Sigor@sysoev.ru .name = nxt_string("body_buffer_size"),
3451650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3461650Sigor@sysoev.ru }, {
3471650Sigor@sysoev.ru .name = nxt_string("max_body_size"),
3481650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3491650Sigor@sysoev.ru }, {
3501650Sigor@sysoev.ru .name = nxt_string("body_temp_path"),
3511650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
3521650Sigor@sysoev.ru }, {
3531709Svbart@nginx.com .name = nxt_string("discard_unsafe_fields"),
3541709Svbart@nginx.com .type = NXT_CONF_VLDT_BOOLEAN,
3551709Svbart@nginx.com }, {
3561650Sigor@sysoev.ru .name = nxt_string("websocket"),
3571650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
3581651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
3591651Sigor@sysoev.ru .u.members = nxt_conf_vldt_websocket_members,
3601650Sigor@sysoev.ru }, {
3611650Sigor@sysoev.ru .name = nxt_string("static"),
3621650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
3631651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
3641651Sigor@sysoev.ru .u.members = nxt_conf_vldt_static_members,
3652381Salx@nginx.com }, {
3662381Salx@nginx.com .name = nxt_string("log_route"),
3672381Salx@nginx.com .type = NXT_CONF_VLDT_BOOLEAN,
3682437Sa.clayton@nginx.com }, {
3692437Sa.clayton@nginx.com .name = nxt_string("server_version"),
3702437Sa.clayton@nginx.com .type = NXT_CONF_VLDT_BOOLEAN,
3711650Sigor@sysoev.ru },
3721183Svbart@nginx.com
373716Svbart@nginx.com NXT_CONF_VLDT_END
374716Svbart@nginx.com };
375716Svbart@nginx.com
376716Svbart@nginx.com
3771649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_websocket_members[] = {
3781650Sigor@sysoev.ru {
3791650Sigor@sysoev.ru .name = nxt_string("read_timeout"),
3801650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3811650Sigor@sysoev.ru }, {
3821650Sigor@sysoev.ru
3831650Sigor@sysoev.ru .name = nxt_string("keepalive_interval"),
3841650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3851650Sigor@sysoev.ru }, {
3861650Sigor@sysoev.ru .name = nxt_string("max_frame_size"),
3871650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
3881650Sigor@sysoev.ru },
389630Svbart@nginx.com
390485Smax.romanov@nginx.com NXT_CONF_VLDT_END
391116Svbart@nginx.com };
392116Svbart@nginx.com
393116Svbart@nginx.com
3941649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[] = {
3951650Sigor@sysoev.ru {
3961650Sigor@sysoev.ru .name = nxt_string("mime_types"),
3971650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
3981651Sigor@sysoev.ru .validator = nxt_conf_vldt_mtypes,
3991650Sigor@sysoev.ru },
400774Svbart@nginx.com
401774Svbart@nginx.com NXT_CONF_VLDT_END
402774Svbart@nginx.com };
403774Svbart@nginx.com
404774Svbart@nginx.com
405132Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = {
4061650Sigor@sysoev.ru {
4071650Sigor@sysoev.ru .name = nxt_string("pass"),
4081650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
4091651Sigor@sysoev.ru .validator = nxt_conf_vldt_pass,
4102247Sz.hong@f5.com .flags = NXT_CONF_VLDT_TSTR,
4111650Sigor@sysoev.ru }, {
4121650Sigor@sysoev.ru .name = nxt_string("application"),
4131650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
4141651Sigor@sysoev.ru .validator = nxt_conf_vldt_app_name,
4151936So.canty@f5.com }, {
4162133Sz.hong@f5.com .name = nxt_string("forwarded"),
4172133Sz.hong@f5.com .type = NXT_CONF_VLDT_OBJECT,
4182133Sz.hong@f5.com .validator = nxt_conf_vldt_forwarded,
4192133Sz.hong@f5.com }, {
4201936So.canty@f5.com .name = nxt_string("client_ip"),
4211936So.canty@f5.com .type = NXT_CONF_VLDT_OBJECT,
4221936So.canty@f5.com .validator = nxt_conf_vldt_object,
4231936So.canty@f5.com .u.members = nxt_conf_vldt_client_ip_members
4241650Sigor@sysoev.ru },
425116Svbart@nginx.com
426774Svbart@nginx.com #if (NXT_TLS)
4271650Sigor@sysoev.ru {
4281650Sigor@sysoev.ru .name = nxt_string("tls"),
4291650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
4301651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
4311651Sigor@sysoev.ru .u.members = nxt_conf_vldt_tls_members,
4321650Sigor@sysoev.ru },
433774Svbart@nginx.com #endif
434774Svbart@nginx.com
435485Smax.romanov@nginx.com NXT_CONF_VLDT_END
436116Svbart@nginx.com };
437116Svbart@nginx.com
438116Svbart@nginx.com
4392133Sz.hong@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_forwarded_members[] = {
4402133Sz.hong@f5.com {
4412133Sz.hong@f5.com .name = nxt_string("client_ip"),
4422133Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
4432133Sz.hong@f5.com }, {
4442133Sz.hong@f5.com .name = nxt_string("protocol"),
4452133Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
4462133Sz.hong@f5.com }, {
4472133Sz.hong@f5.com .name = nxt_string("source"),
4482133Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
4492133Sz.hong@f5.com .validator = nxt_conf_vldt_match_addrs,
4502133Sz.hong@f5.com .flags = NXT_CONF_VLDT_REQUIRED
4512133Sz.hong@f5.com }, {
4522133Sz.hong@f5.com .name = nxt_string("recursive"),
4532133Sz.hong@f5.com .type = NXT_CONF_VLDT_BOOLEAN,
4542133Sz.hong@f5.com },
4552133Sz.hong@f5.com
4562133Sz.hong@f5.com NXT_CONF_VLDT_END
4572133Sz.hong@f5.com };
4582133Sz.hong@f5.com
4592133Sz.hong@f5.com
4601936So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_client_ip_members[] = {
4611936So.canty@f5.com {
4621936So.canty@f5.com .name = nxt_string("source"),
4631936So.canty@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
4641936So.canty@f5.com .validator = nxt_conf_vldt_match_addrs,
4651936So.canty@f5.com .flags = NXT_CONF_VLDT_REQUIRED
4661936So.canty@f5.com }, {
4671936So.canty@f5.com .name = nxt_string("header"),
4681936So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
4691936So.canty@f5.com .flags = NXT_CONF_VLDT_REQUIRED
4701936So.canty@f5.com }, {
4711936So.canty@f5.com .name = nxt_string("recursive"),
4721936So.canty@f5.com .type = NXT_CONF_VLDT_BOOLEAN,
4731936So.canty@f5.com },
4741936So.canty@f5.com
4751936So.canty@f5.com NXT_CONF_VLDT_END
4761936So.canty@f5.com };
4771936So.canty@f5.com
4781936So.canty@f5.com
4791649Sigor@sysoev.ru #if (NXT_TLS)
4801649Sigor@sysoev.ru
4811649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_tls_members[] = {
4821650Sigor@sysoev.ru {
4831650Sigor@sysoev.ru .name = nxt_string("certificate"),
4841828Sa.suvorov@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
4851885Sa.suvorov@f5.com .flags = NXT_CONF_VLDT_REQUIRED,
4861651Sigor@sysoev.ru .validator = nxt_conf_vldt_certificate,
4871885Sa.suvorov@f5.com }, {
4881885Sa.suvorov@f5.com .name = nxt_string("conf_commands"),
4891885Sa.suvorov@f5.com .type = NXT_CONF_VLDT_OBJECT,
4901885Sa.suvorov@f5.com #if (NXT_HAVE_OPENSSL_CONF_CMD)
4911885Sa.suvorov@f5.com .validator = nxt_conf_vldt_object_conf_commands,
4921885Sa.suvorov@f5.com #else
4931885Sa.suvorov@f5.com .validator = nxt_conf_vldt_unsupported,
4941885Sa.suvorov@f5.com .u.string = "conf_commands",
4951885Sa.suvorov@f5.com #endif
4961920Sa.suvorov@f5.com }, {
4971920Sa.suvorov@f5.com .name = nxt_string("session"),
4981920Sa.suvorov@f5.com .type = NXT_CONF_VLDT_OBJECT,
4991920Sa.suvorov@f5.com .validator = nxt_conf_vldt_object,
5001920Sa.suvorov@f5.com .u.members = nxt_conf_vldt_session_members,
5011920Sa.suvorov@f5.com },
5021920Sa.suvorov@f5.com
5031920Sa.suvorov@f5.com NXT_CONF_VLDT_END
5041920Sa.suvorov@f5.com };
5051920Sa.suvorov@f5.com
5061920Sa.suvorov@f5.com
5071920Sa.suvorov@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_session_members[] = {
5081920Sa.suvorov@f5.com {
5091920Sa.suvorov@f5.com .name = nxt_string("cache_size"),
5101920Sa.suvorov@f5.com .type = NXT_CONF_VLDT_INTEGER,
5111920Sa.suvorov@f5.com .validator = nxt_conf_vldt_tls_cache_size,
5121920Sa.suvorov@f5.com }, {
5131920Sa.suvorov@f5.com .name = nxt_string("timeout"),
5141920Sa.suvorov@f5.com .type = NXT_CONF_VLDT_INTEGER,
5151920Sa.suvorov@f5.com .validator = nxt_conf_vldt_tls_timeout,
5161942Sa.suvorov@f5.com }, {
5171942Sa.suvorov@f5.com .name = nxt_string("tickets"),
5181942Sa.suvorov@f5.com .type = NXT_CONF_VLDT_STRING
5191942Sa.suvorov@f5.com | NXT_CONF_VLDT_ARRAY
5201942Sa.suvorov@f5.com | NXT_CONF_VLDT_BOOLEAN,
5211942Sa.suvorov@f5.com #if (NXT_HAVE_OPENSSL_TLSEXT)
5221942Sa.suvorov@f5.com .validator = nxt_conf_vldt_ticket_key,
5231942Sa.suvorov@f5.com #else
5241942Sa.suvorov@f5.com .validator = nxt_conf_vldt_unsupported,
5251942Sa.suvorov@f5.com .u.string = "tickets",
5261942Sa.suvorov@f5.com #endif
5271650Sigor@sysoev.ru },
5281649Sigor@sysoev.ru
5291649Sigor@sysoev.ru NXT_CONF_VLDT_END
5301649Sigor@sysoev.ru };
5311649Sigor@sysoev.ru
5321920Sa.suvorov@f5.com
5331920Sa.suvorov@f5.com static nxt_int_t
nxt_conf_vldt_tls_cache_size(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)5341920Sa.suvorov@f5.com nxt_conf_vldt_tls_cache_size(nxt_conf_validation_t *vldt,
5351920Sa.suvorov@f5.com nxt_conf_value_t *value, void *data)
5361920Sa.suvorov@f5.com {
5371920Sa.suvorov@f5.com int64_t cache_size;
5381920Sa.suvorov@f5.com
5391920Sa.suvorov@f5.com cache_size = nxt_conf_get_number(value);
5401920Sa.suvorov@f5.com
5411920Sa.suvorov@f5.com if (cache_size < 0) {
5421920Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "The \"cache_size\" number must not "
5431920Sa.suvorov@f5.com "be negative.");
5441920Sa.suvorov@f5.com }
5451920Sa.suvorov@f5.com
5461920Sa.suvorov@f5.com return NXT_OK;
5471920Sa.suvorov@f5.com }
5481920Sa.suvorov@f5.com
5491920Sa.suvorov@f5.com
5501920Sa.suvorov@f5.com static nxt_int_t
nxt_conf_vldt_tls_timeout(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)5511920Sa.suvorov@f5.com nxt_conf_vldt_tls_timeout(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
5521920Sa.suvorov@f5.com void *data)
5531920Sa.suvorov@f5.com {
5541920Sa.suvorov@f5.com int64_t timeout;
5551920Sa.suvorov@f5.com
5561920Sa.suvorov@f5.com timeout = nxt_conf_get_number(value);
5571920Sa.suvorov@f5.com
5581920Sa.suvorov@f5.com if (timeout <= 0) {
5591920Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "The \"timeout\" number must be "
5601920Sa.suvorov@f5.com "greater than zero.");
5611920Sa.suvorov@f5.com }
5621920Sa.suvorov@f5.com
5631920Sa.suvorov@f5.com return NXT_OK;
5641920Sa.suvorov@f5.com }
5651920Sa.suvorov@f5.com
5661649Sigor@sysoev.ru #endif
5671649Sigor@sysoev.ru
5681942Sa.suvorov@f5.com #if (NXT_HAVE_OPENSSL_TLSEXT)
5691942Sa.suvorov@f5.com
5701942Sa.suvorov@f5.com static nxt_int_t
nxt_conf_vldt_ticket_key(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)5711942Sa.suvorov@f5.com nxt_conf_vldt_ticket_key(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
5721942Sa.suvorov@f5.com void *data)
5731942Sa.suvorov@f5.com {
5741942Sa.suvorov@f5.com if (nxt_conf_type(value) == NXT_CONF_BOOLEAN) {
5751942Sa.suvorov@f5.com return NXT_OK;
5761942Sa.suvorov@f5.com }
5771942Sa.suvorov@f5.com
5781942Sa.suvorov@f5.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
5791942Sa.suvorov@f5.com return nxt_conf_vldt_array_iterator(vldt, value,
5801942Sa.suvorov@f5.com &nxt_conf_vldt_ticket_key_element);
5811942Sa.suvorov@f5.com }
5821942Sa.suvorov@f5.com
5831942Sa.suvorov@f5.com /* NXT_CONF_STRING */
5841942Sa.suvorov@f5.com
5851942Sa.suvorov@f5.com return nxt_conf_vldt_ticket_key_element(vldt, value);
5861942Sa.suvorov@f5.com }
5871942Sa.suvorov@f5.com
5881942Sa.suvorov@f5.com
5891942Sa.suvorov@f5.com static nxt_int_t
nxt_conf_vldt_ticket_key_element(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)5901942Sa.suvorov@f5.com nxt_conf_vldt_ticket_key_element(nxt_conf_validation_t *vldt,
5911942Sa.suvorov@f5.com nxt_conf_value_t *value)
5921942Sa.suvorov@f5.com {
5931975Svbart@nginx.com ssize_t ret;
5941942Sa.suvorov@f5.com nxt_str_t key;
5951942Sa.suvorov@f5.com
5961942Sa.suvorov@f5.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
5971942Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "The \"key\" array must "
5981942Sa.suvorov@f5.com "contain only string values.");
5991942Sa.suvorov@f5.com }
6001942Sa.suvorov@f5.com
6011942Sa.suvorov@f5.com nxt_conf_get_string(value, &key);
6021942Sa.suvorov@f5.com
6031975Svbart@nginx.com ret = nxt_base64_decode(NULL, key.start, key.length);
6041975Svbart@nginx.com if (ret == NXT_ERROR) {
6051942Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "Invalid Base64 format for the ticket "
6061942Sa.suvorov@f5.com "key \"%V\".", &key);
6071942Sa.suvorov@f5.com }
6081942Sa.suvorov@f5.com
6091942Sa.suvorov@f5.com if (ret != 48 && ret != 80) {
6101942Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "Invalid length %d of the ticket "
6111942Sa.suvorov@f5.com "key \"%V\". Must be 48 or 80 bytes.",
6121942Sa.suvorov@f5.com ret, &key);
6131942Sa.suvorov@f5.com }
6141942Sa.suvorov@f5.com
6151942Sa.suvorov@f5.com return NXT_OK;
6161942Sa.suvorov@f5.com }
6171942Sa.suvorov@f5.com
6181942Sa.suvorov@f5.com #endif
6191942Sa.suvorov@f5.com
6201649Sigor@sysoev.ru
6211649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_route_members[] = {
6221650Sigor@sysoev.ru {
6231650Sigor@sysoev.ru .name = nxt_string("match"),
6241650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
6251651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
6261651Sigor@sysoev.ru .u.members = nxt_conf_vldt_match_members,
6271650Sigor@sysoev.ru }, {
6281650Sigor@sysoev.ru .name = nxt_string("action"),
6291650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
6301651Sigor@sysoev.ru .validator = nxt_conf_vldt_action,
6311650Sigor@sysoev.ru },
6321649Sigor@sysoev.ru
6331649Sigor@sysoev.ru NXT_CONF_VLDT_END
6341649Sigor@sysoev.ru };
6351649Sigor@sysoev.ru
6361649Sigor@sysoev.ru
637966Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_match_members[] = {
6381650Sigor@sysoev.ru {
6391650Sigor@sysoev.ru .name = nxt_string("method"),
6401650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
6411651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_patterns,
6421988Sz.hong@f5.com .u.string = "method",
6431650Sigor@sysoev.ru }, {
6441650Sigor@sysoev.ru .name = nxt_string("scheme"),
6451650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
6461651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_scheme_pattern,
6471650Sigor@sysoev.ru }, {
6481650Sigor@sysoev.ru .name = nxt_string("host"),
6491650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
6501651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_patterns,
6511988Sz.hong@f5.com .u.string = "host",
6521650Sigor@sysoev.ru }, {
6531650Sigor@sysoev.ru .name = nxt_string("source"),
6541650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
6551651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_addrs,
6561650Sigor@sysoev.ru }, {
6571650Sigor@sysoev.ru .name = nxt_string("destination"),
6581650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
6591651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_addrs,
6601650Sigor@sysoev.ru }, {
6611650Sigor@sysoev.ru .name = nxt_string("uri"),
6621650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
6631651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_encoded_patterns,
6641988Sz.hong@f5.com .u.string = "uri"
6651650Sigor@sysoev.ru }, {
6661991Sz.hong@f5.com .name = nxt_string("query"),
6671991Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
6681991Sz.hong@f5.com .validator = nxt_conf_vldt_match_encoded_patterns,
6691991Sz.hong@f5.com .u.string = "query"
6701991Sz.hong@f5.com }, {
6711650Sigor@sysoev.ru .name = nxt_string("arguments"),
6721650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
6731651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_encoded_patterns_sets,
6741650Sigor@sysoev.ru }, {
6751650Sigor@sysoev.ru .name = nxt_string("headers"),
6761650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
6771651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_patterns_sets,
6781988Sz.hong@f5.com .u.string = "headers"
6791650Sigor@sysoev.ru }, {
6801650Sigor@sysoev.ru .name = nxt_string("cookies"),
6811650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
6821651Sigor@sysoev.ru .validator = nxt_conf_vldt_match_patterns_sets,
6831988Sz.hong@f5.com .u.string = "cookies"
6841650Sigor@sysoev.ru },
6851059Sigor@sysoev.ru
686966Svbart@nginx.com NXT_CONF_VLDT_END
687966Svbart@nginx.com };
688966Svbart@nginx.com
689966Svbart@nginx.com
6902448Sz.hong@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_action_common_members[] = {
6912448Sz.hong@f5.com {
6922448Sz.hong@f5.com .name = nxt_string("rewrite"),
6932448Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
6942610Sz.hong@f5.com .flags = NXT_CONF_VLDT_TSTR,
6952448Sz.hong@f5.com },
6962512Sz.hong@f5.com {
6972512Sz.hong@f5.com .name = nxt_string("response_headers"),
6982512Sz.hong@f5.com .type = NXT_CONF_VLDT_OBJECT,
6992512Sz.hong@f5.com .validator = nxt_conf_vldt_object_iterator,
7002512Sz.hong@f5.com .u.object = nxt_conf_vldt_response_header,
7012512Sz.hong@f5.com },
7022448Sz.hong@f5.com
7032448Sz.hong@f5.com NXT_CONF_VLDT_END
7042448Sz.hong@f5.com };
7052448Sz.hong@f5.com
7062448Sz.hong@f5.com
7071377Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_pass_action_members[] = {
7081650Sigor@sysoev.ru {
7091650Sigor@sysoev.ru .name = nxt_string("pass"),
7101650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
7111651Sigor@sysoev.ru .validator = nxt_conf_vldt_pass,
7122247Sz.hong@f5.com .flags = NXT_CONF_VLDT_TSTR,
7131650Sigor@sysoev.ru },
714966Svbart@nginx.com
7152448Sz.hong@f5.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members)
7161377Svbart@nginx.com };
7171377Svbart@nginx.com
7181377Svbart@nginx.com
7191429Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_return_action_members[] = {
7201650Sigor@sysoev.ru {
7211650Sigor@sysoev.ru .name = nxt_string("return"),
7221650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
7231651Sigor@sysoev.ru .validator = nxt_conf_vldt_return,
7241650Sigor@sysoev.ru }, {
7251650Sigor@sysoev.ru .name = nxt_string("location"),
7261650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
7272247Sz.hong@f5.com .flags = NXT_CONF_VLDT_TSTR,
7281650Sigor@sysoev.ru },
7291432Svbart@nginx.com
7302448Sz.hong@f5.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members)
7311429Svbart@nginx.com };
7321429Svbart@nginx.com
7331429Svbart@nginx.com
7341377Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_share_action_members[] = {
7351650Sigor@sysoev.ru {
7361650Sigor@sysoev.ru .name = nxt_string("share"),
7371961Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
7381961Sz.hong@f5.com .validator = nxt_conf_vldt_share,
7391650Sigor@sysoev.ru }, {
7402108Salx.manpages@gmail.com .name = nxt_string("index"),
7412108Salx.manpages@gmail.com .type = NXT_CONF_VLDT_STRING,
7422108Salx.manpages@gmail.com }, {
7431859So.canty@f5.com .name = nxt_string("types"),
7441859So.canty@f5.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
7451859So.canty@f5.com .validator = nxt_conf_vldt_match_patterns,
7461859So.canty@f5.com }, {
7471650Sigor@sysoev.ru .name = nxt_string("fallback"),
7481650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
7491651Sigor@sysoev.ru .validator = nxt_conf_vldt_action,
7501855Sz.hong@f5.com }, {
7511855Sz.hong@f5.com .name = nxt_string("chroot"),
7521855Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
7531855Sz.hong@f5.com #if !(NXT_HAVE_OPENAT2)
7541855Sz.hong@f5.com .validator = nxt_conf_vldt_unsupported,
7551855Sz.hong@f5.com .u.string = "chroot",
7561855Sz.hong@f5.com #endif
7572247Sz.hong@f5.com .flags = NXT_CONF_VLDT_TSTR,
7581855Sz.hong@f5.com }, {
7591855Sz.hong@f5.com .name = nxt_string("follow_symlinks"),
7601855Sz.hong@f5.com .type = NXT_CONF_VLDT_BOOLEAN,
7611855Sz.hong@f5.com #if !(NXT_HAVE_OPENAT2)
7621855Sz.hong@f5.com .validator = nxt_conf_vldt_unsupported,
7631855Sz.hong@f5.com .u.string = "follow_symlinks",
7641855Sz.hong@f5.com #endif
7651855Sz.hong@f5.com }, {
7661855Sz.hong@f5.com .name = nxt_string("traverse_mounts"),
7671855Sz.hong@f5.com .type = NXT_CONF_VLDT_BOOLEAN,
7681855Sz.hong@f5.com #if !(NXT_HAVE_OPENAT2)
7691855Sz.hong@f5.com .validator = nxt_conf_vldt_unsupported,
7701855Sz.hong@f5.com .u.string = "traverse_mounts",
7711855Sz.hong@f5.com #endif
7721650Sigor@sysoev.ru },
7731378Svbart@nginx.com
7742448Sz.hong@f5.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members)
7751377Svbart@nginx.com };
7761377Svbart@nginx.com
7771377Svbart@nginx.com
7781377Svbart@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_proxy_action_members[] = {
7791650Sigor@sysoev.ru {
7801650Sigor@sysoev.ru .name = nxt_string("proxy"),
7811650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
7821651Sigor@sysoev.ru .validator = nxt_conf_vldt_proxy,
7831650Sigor@sysoev.ru },
7841270Sigor@sysoev.ru
7852448Sz.hong@f5.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members)
786966Svbart@nginx.com };
787966Svbart@nginx.com
788966Svbart@nginx.com
7891649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_external_members[] = {
7901650Sigor@sysoev.ru {
7911650Sigor@sysoev.ru .name = nxt_string("executable"),
7921650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
7931650Sigor@sysoev.ru .flags = NXT_CONF_VLDT_REQUIRED,
7941650Sigor@sysoev.ru }, {
7951650Sigor@sysoev.ru .name = nxt_string("arguments"),
7961650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ARRAY,
7971651Sigor@sysoev.ru .validator = nxt_conf_vldt_array_iterator,
7981651Sigor@sysoev.ru .u.array = nxt_conf_vldt_argument,
7991650Sigor@sysoev.ru },
8001649Sigor@sysoev.ru
8011651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
8021649Sigor@sysoev.ru };
8031649Sigor@sysoev.ru
8041649Sigor@sysoev.ru
8051872So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_python_common_members[] = {
8061650Sigor@sysoev.ru {
8071650Sigor@sysoev.ru .name = nxt_string("home"),
8081650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
8091650Sigor@sysoev.ru }, {
8101650Sigor@sysoev.ru .name = nxt_string("path"),
8111759Svbart@nginx.com .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
8121759Svbart@nginx.com .validator = nxt_conf_vldt_python_path,
8131650Sigor@sysoev.ru }, {
8141697Smax.romanov@nginx.com .name = nxt_string("protocol"),
8151697Smax.romanov@nginx.com .type = NXT_CONF_VLDT_STRING,
8161697Smax.romanov@nginx.com .validator = nxt_conf_vldt_python_protocol,
8171697Smax.romanov@nginx.com }, {
8181681Smax.romanov@nginx.com .name = nxt_string("threads"),
8191681Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
8201681Smax.romanov@nginx.com .validator = nxt_conf_vldt_threads,
8211681Smax.romanov@nginx.com }, {
8221681Smax.romanov@nginx.com .name = nxt_string("thread_stack_size"),
8231681Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
8241681Smax.romanov@nginx.com .validator = nxt_conf_vldt_thread_stack_size,
8251650Sigor@sysoev.ru },
8261649Sigor@sysoev.ru
8271651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
8281649Sigor@sysoev.ru };
8291649Sigor@sysoev.ru
8301872So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
8311872So.canty@f5.com {
8321872So.canty@f5.com .name = nxt_string("module"),
8331872So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
8341879So.canty@f5.com .validator = nxt_conf_vldt_targets_exclusive,
8351872So.canty@f5.com .u.string = "module",
8361872So.canty@f5.com }, {
8371872So.canty@f5.com .name = nxt_string("callable"),
8381872So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
8391879So.canty@f5.com .validator = nxt_conf_vldt_targets_exclusive,
8401872So.canty@f5.com .u.string = "callable",
8411872So.canty@f5.com }, {
8422273Sjeff.iadarola@gmail.com .name = nxt_string("prefix"),
8432273Sjeff.iadarola@gmail.com .type = NXT_CONF_VLDT_STRING,
8442273Sjeff.iadarola@gmail.com .validator = nxt_conf_vldt_targets_exclusive,
8452273Sjeff.iadarola@gmail.com .u.string = "prefix",
8462273Sjeff.iadarola@gmail.com }, {
8471872So.canty@f5.com .name = nxt_string("targets"),
8481872So.canty@f5.com .type = NXT_CONF_VLDT_OBJECT,
8491879So.canty@f5.com .validator = nxt_conf_vldt_targets,
8501879So.canty@f5.com .u.members = nxt_conf_vldt_python_target_members
8511872So.canty@f5.com },
8521872So.canty@f5.com
8531872So.canty@f5.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_python_common_members)
8541872So.canty@f5.com };
8551872So.canty@f5.com
8561872So.canty@f5.com
8571872So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_python_target_members[] = {
8581872So.canty@f5.com {
8591872So.canty@f5.com .name = nxt_string("module"),
8601872So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
8611872So.canty@f5.com .flags = NXT_CONF_VLDT_REQUIRED,
8621872So.canty@f5.com }, {
8631872So.canty@f5.com .name = nxt_string("callable"),
8641872So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
8652273Sjeff.iadarola@gmail.com }, {
8662273Sjeff.iadarola@gmail.com .name = nxt_string("prefix"),
8672273Sjeff.iadarola@gmail.com .type = NXT_CONF_VLDT_STRING,
8682273Sjeff.iadarola@gmail.com .validator = nxt_conf_vldt_python_prefix,
8691872So.canty@f5.com },
8701872So.canty@f5.com
8711872So.canty@f5.com NXT_CONF_VLDT_END
8721872So.canty@f5.com };
8731872So.canty@f5.com
8741872So.canty@f5.com
8751872So.canty@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_python_notargets_members[] = {
8761872So.canty@f5.com {
8771872So.canty@f5.com .name = nxt_string("module"),
8781872So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
8791872So.canty@f5.com .flags = NXT_CONF_VLDT_REQUIRED,
8801872So.canty@f5.com }, {
8811872So.canty@f5.com .name = nxt_string("callable"),
8821872So.canty@f5.com .type = NXT_CONF_VLDT_STRING,
8832273Sjeff.iadarola@gmail.com }, {
8842273Sjeff.iadarola@gmail.com .name = nxt_string("prefix"),
8852273Sjeff.iadarola@gmail.com .type = NXT_CONF_VLDT_STRING,
8862273Sjeff.iadarola@gmail.com .validator = nxt_conf_vldt_python_prefix,
8871872So.canty@f5.com },
8881872So.canty@f5.com
8891872So.canty@f5.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_python_common_members)
8901872So.canty@f5.com };
8911872So.canty@f5.com
8921649Sigor@sysoev.ru
8931649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
8941650Sigor@sysoev.ru {
8951650Sigor@sysoev.ru .name = nxt_string("root"),
8961650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ANY_TYPE,
8971879So.canty@f5.com .validator = nxt_conf_vldt_targets_exclusive,
8981651Sigor@sysoev.ru .u.string = "root",
8991650Sigor@sysoev.ru }, {
9001650Sigor@sysoev.ru .name = nxt_string("script"),
9011650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ANY_TYPE,
9021879So.canty@f5.com .validator = nxt_conf_vldt_targets_exclusive,
9031651Sigor@sysoev.ru .u.string = "script",
9041650Sigor@sysoev.ru }, {
9051650Sigor@sysoev.ru .name = nxt_string("index"),
9061650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ANY_TYPE,
9071879So.canty@f5.com .validator = nxt_conf_vldt_targets_exclusive,
9081651Sigor@sysoev.ru .u.string = "index",
9091650Sigor@sysoev.ru }, {
9101650Sigor@sysoev.ru .name = nxt_string("targets"),
9111650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
9121879So.canty@f5.com .validator = nxt_conf_vldt_targets,
9131879So.canty@f5.com .u.members = nxt_conf_vldt_php_target_members
9141650Sigor@sysoev.ru },
9151649Sigor@sysoev.ru
9161651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_php_common_members)
9171649Sigor@sysoev.ru };
9181649Sigor@sysoev.ru
9191649Sigor@sysoev.ru
9201649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_common_members[] = {
9211650Sigor@sysoev.ru {
9221650Sigor@sysoev.ru .name = nxt_string("options"),
9231650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
9241651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
9251651Sigor@sysoev.ru .u.members = nxt_conf_vldt_php_options_members,
9261650Sigor@sysoev.ru },
9271649Sigor@sysoev.ru
9281651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
9291649Sigor@sysoev.ru };
9301649Sigor@sysoev.ru
9311649Sigor@sysoev.ru
9321649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_options_members[] = {
9331650Sigor@sysoev.ru {
9341650Sigor@sysoev.ru .name = nxt_string("file"),
9351650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9361650Sigor@sysoev.ru }, {
9371650Sigor@sysoev.ru .name = nxt_string("admin"),
9381650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
9391651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
9401651Sigor@sysoev.ru .u.object = nxt_conf_vldt_php_option,
9411650Sigor@sysoev.ru }, {
9421650Sigor@sysoev.ru .name = nxt_string("user"),
9431650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
9441651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
9451651Sigor@sysoev.ru .u.object = nxt_conf_vldt_php_option,
9461650Sigor@sysoev.ru },
9471649Sigor@sysoev.ru
9481649Sigor@sysoev.ru NXT_CONF_VLDT_END
9491649Sigor@sysoev.ru };
9501649Sigor@sysoev.ru
9511649Sigor@sysoev.ru
9521649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_target_members[] = {
9531650Sigor@sysoev.ru {
9541650Sigor@sysoev.ru .name = nxt_string("root"),
9551650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9561650Sigor@sysoev.ru .flags = NXT_CONF_VLDT_REQUIRED,
9571650Sigor@sysoev.ru }, {
9581650Sigor@sysoev.ru .name = nxt_string("script"),
9591650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9601650Sigor@sysoev.ru }, {
9611650Sigor@sysoev.ru .name = nxt_string("index"),
9621650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9631650Sigor@sysoev.ru },
9641649Sigor@sysoev.ru
9651649Sigor@sysoev.ru NXT_CONF_VLDT_END
9661649Sigor@sysoev.ru };
9671649Sigor@sysoev.ru
9681649Sigor@sysoev.ru
9691649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_php_notargets_members[] = {
9701650Sigor@sysoev.ru {
9711650Sigor@sysoev.ru .name = nxt_string("root"),
9721650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9731650Sigor@sysoev.ru .flags = NXT_CONF_VLDT_REQUIRED,
9741650Sigor@sysoev.ru }, {
9751650Sigor@sysoev.ru .name = nxt_string("script"),
9761650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9771650Sigor@sysoev.ru }, {
9781650Sigor@sysoev.ru .name = nxt_string("index"),
9791650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9801650Sigor@sysoev.ru },
9811649Sigor@sysoev.ru
9821651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_php_common_members)
9831649Sigor@sysoev.ru };
9841649Sigor@sysoev.ru
9851649Sigor@sysoev.ru
9861649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_perl_members[] = {
9871650Sigor@sysoev.ru {
9881650Sigor@sysoev.ru .name = nxt_string("script"),
9891650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
9901650Sigor@sysoev.ru .flags = NXT_CONF_VLDT_REQUIRED,
9911689Smax.romanov@nginx.com }, {
9921689Smax.romanov@nginx.com .name = nxt_string("threads"),
9931689Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
9941689Smax.romanov@nginx.com .validator = nxt_conf_vldt_threads,
9951689Smax.romanov@nginx.com }, {
9961689Smax.romanov@nginx.com .name = nxt_string("thread_stack_size"),
9971689Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
9981689Smax.romanov@nginx.com .validator = nxt_conf_vldt_thread_stack_size,
9991650Sigor@sysoev.ru },
10001649Sigor@sysoev.ru
10011651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
10021649Sigor@sysoev.ru };
10031649Sigor@sysoev.ru
10041649Sigor@sysoev.ru
10051649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_ruby_members[] = {
10061650Sigor@sysoev.ru {
10071650Sigor@sysoev.ru .name = nxt_string("script"),
10081650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
10091650Sigor@sysoev.ru .flags = NXT_CONF_VLDT_REQUIRED,
10101687Smax.romanov@nginx.com }, {
10111687Smax.romanov@nginx.com .name = nxt_string("threads"),
10121687Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
10131687Smax.romanov@nginx.com .validator = nxt_conf_vldt_threads,
10141910So.canty@f5.com }, {
10151910So.canty@f5.com .name = nxt_string("hooks"),
10161910So.canty@f5.com .type = NXT_CONF_VLDT_STRING
10171650Sigor@sysoev.ru },
1018966Svbart@nginx.com
10191651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
10201649Sigor@sysoev.ru };
10211649Sigor@sysoev.ru
10221649Sigor@sysoev.ru
10231649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_java_members[] = {
10241650Sigor@sysoev.ru {
10251650Sigor@sysoev.ru .name = nxt_string("classpath"),
10261650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ARRAY,
10271651Sigor@sysoev.ru .validator = nxt_conf_vldt_array_iterator,
10281651Sigor@sysoev.ru .u.array = nxt_conf_vldt_java_classpath,
10291650Sigor@sysoev.ru }, {
10301650Sigor@sysoev.ru .name = nxt_string("webapp"),
10311650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
10321650Sigor@sysoev.ru .flags = NXT_CONF_VLDT_REQUIRED,
10331650Sigor@sysoev.ru }, {
10341650Sigor@sysoev.ru .name = nxt_string("options"),
10351650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ARRAY,
10361651Sigor@sysoev.ru .validator = nxt_conf_vldt_array_iterator,
10371651Sigor@sysoev.ru .u.array = nxt_conf_vldt_java_option,
10381650Sigor@sysoev.ru }, {
10391650Sigor@sysoev.ru .name = nxt_string("unit_jars"),
10401650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
10411684Smax.romanov@nginx.com }, {
10421684Smax.romanov@nginx.com .name = nxt_string("threads"),
10431684Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
10441684Smax.romanov@nginx.com .validator = nxt_conf_vldt_threads,
10451684Smax.romanov@nginx.com }, {
10461684Smax.romanov@nginx.com .name = nxt_string("thread_stack_size"),
10471684Smax.romanov@nginx.com .type = NXT_CONF_VLDT_INTEGER,
10481684Smax.romanov@nginx.com .validator = nxt_conf_vldt_thread_stack_size,
10491650Sigor@sysoev.ru },
10501649Sigor@sysoev.ru
10511651Sigor@sysoev.ru NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
10521649Sigor@sysoev.ru };
10531649Sigor@sysoev.ru
10541649Sigor@sysoev.ru
10552518Sa.clayton@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_wasm_members[] = {
10562518Sa.clayton@nginx.com {
10572518Sa.clayton@nginx.com .name = nxt_string("module"),
10582518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10592518Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
10602518Sa.clayton@nginx.com }, {
10612518Sa.clayton@nginx.com .name = nxt_string("request_handler"),
10622518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10632518Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
10642518Sa.clayton@nginx.com },{
10652518Sa.clayton@nginx.com .name = nxt_string("malloc_handler"),
10662518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10672518Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
10682518Sa.clayton@nginx.com }, {
10692518Sa.clayton@nginx.com .name = nxt_string("free_handler"),
10702518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10712518Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
10722518Sa.clayton@nginx.com }, {
10732518Sa.clayton@nginx.com .name = nxt_string("module_init_handler"),
10742518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10752518Sa.clayton@nginx.com }, {
10762518Sa.clayton@nginx.com .name = nxt_string("module_end_handler"),
10772518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10782518Sa.clayton@nginx.com }, {
10792518Sa.clayton@nginx.com .name = nxt_string("request_init_handler"),
10802518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10812518Sa.clayton@nginx.com }, {
10822518Sa.clayton@nginx.com .name = nxt_string("request_end_handler"),
10832518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10842518Sa.clayton@nginx.com }, {
10852518Sa.clayton@nginx.com .name = nxt_string("response_end_handler"),
10862518Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
10872519Sa.clayton@nginx.com }, {
10882519Sa.clayton@nginx.com .name = nxt_string("access"),
10892519Sa.clayton@nginx.com .type = NXT_CONF_VLDT_OBJECT,
10902519Sa.clayton@nginx.com .validator = nxt_conf_vldt_object,
10912519Sa.clayton@nginx.com .u.members = nxt_conf_vldt_wasm_access_members,
10922518Sa.clayton@nginx.com },
10932518Sa.clayton@nginx.com
10942518Sa.clayton@nginx.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
10952518Sa.clayton@nginx.com };
10962518Sa.clayton@nginx.com
10972518Sa.clayton@nginx.com
1098*2686Sa.clayton@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_wasm_wc_members[] = {
1099*2686Sa.clayton@nginx.com {
1100*2686Sa.clayton@nginx.com .name = nxt_string("component"),
1101*2686Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
1102*2686Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
1103*2686Sa.clayton@nginx.com }, {
1104*2686Sa.clayton@nginx.com .name = nxt_string("access"),
1105*2686Sa.clayton@nginx.com .type = NXT_CONF_VLDT_OBJECT,
1106*2686Sa.clayton@nginx.com .validator = nxt_conf_vldt_object,
1107*2686Sa.clayton@nginx.com .u.members = nxt_conf_vldt_wasm_access_members,
1108*2686Sa.clayton@nginx.com },
1109*2686Sa.clayton@nginx.com
1110*2686Sa.clayton@nginx.com NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
1111*2686Sa.clayton@nginx.com };
1112*2686Sa.clayton@nginx.com
1113*2686Sa.clayton@nginx.com
11142519Sa.clayton@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_wasm_access_members[] = {
11152519Sa.clayton@nginx.com {
11162519Sa.clayton@nginx.com .name = nxt_string("filesystem"),
11172519Sa.clayton@nginx.com .type = NXT_CONF_VLDT_ARRAY,
11182519Sa.clayton@nginx.com },
11192519Sa.clayton@nginx.com
11202519Sa.clayton@nginx.com NXT_CONF_VLDT_END
11212519Sa.clayton@nginx.com };
11222519Sa.clayton@nginx.com
11232519Sa.clayton@nginx.com
11241649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[] = {
11251650Sigor@sysoev.ru {
11261650Sigor@sysoev.ru .name = nxt_string("type"),
11271650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
11281650Sigor@sysoev.ru }, {
11291650Sigor@sysoev.ru .name = nxt_string("limits"),
11301650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
11311651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
11321651Sigor@sysoev.ru .u.members = nxt_conf_vldt_app_limits_members,
11331650Sigor@sysoev.ru }, {
11341650Sigor@sysoev.ru .name = nxt_string("processes"),
11351650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER | NXT_CONF_VLDT_OBJECT,
11361651Sigor@sysoev.ru .validator = nxt_conf_vldt_processes,
11371651Sigor@sysoev.ru .u.members = nxt_conf_vldt_app_processes_members,
11381650Sigor@sysoev.ru }, {
11391650Sigor@sysoev.ru .name = nxt_string("user"),
11401650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
11411650Sigor@sysoev.ru }, {
11421650Sigor@sysoev.ru .name = nxt_string("group"),
11431650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
11441650Sigor@sysoev.ru }, {
11451650Sigor@sysoev.ru .name = nxt_string("working_directory"),
11461650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
11471650Sigor@sysoev.ru }, {
11481650Sigor@sysoev.ru .name = nxt_string("environment"),
11491650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
11501651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
11511651Sigor@sysoev.ru .u.object = nxt_conf_vldt_environment,
11521650Sigor@sysoev.ru }, {
11531650Sigor@sysoev.ru .name = nxt_string("isolation"),
11541650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
11551651Sigor@sysoev.ru .validator = nxt_conf_vldt_isolation,
11561651Sigor@sysoev.ru .u.members = nxt_conf_vldt_app_isolation_members,
11572426Sa.clayton@nginx.com }, {
11582426Sa.clayton@nginx.com .name = nxt_string("stdout"),
11592426Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
11602426Sa.clayton@nginx.com }, {
11612426Sa.clayton@nginx.com .name = nxt_string("stderr"),
11622426Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
11631650Sigor@sysoev.ru },
11641649Sigor@sysoev.ru
1165966Svbart@nginx.com NXT_CONF_VLDT_END
1166966Svbart@nginx.com };
1167966Svbart@nginx.com
1168966Svbart@nginx.com
1169318Smax.romanov@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_app_limits_members[] = {
11701650Sigor@sysoev.ru {
11711650Sigor@sysoev.ru .name = nxt_string("timeout"),
11721650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
11731650Sigor@sysoev.ru }, {
11741650Sigor@sysoev.ru .name = nxt_string("requests"),
11751650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
11761650Sigor@sysoev.ru }, {
11771650Sigor@sysoev.ru .name = nxt_string("shm"),
11781650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
11791650Sigor@sysoev.ru },
11801320Smax.romanov@nginx.com
1181485Smax.romanov@nginx.com NXT_CONF_VLDT_END
1182318Smax.romanov@nginx.com };
1183318Smax.romanov@nginx.com
1184318Smax.romanov@nginx.com
1185507Smax.romanov@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_app_processes_members[] = {
11861650Sigor@sysoev.ru {
11871650Sigor@sysoev.ru .name = nxt_string("spare"),
11881650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
11891650Sigor@sysoev.ru }, {
11901650Sigor@sysoev.ru .name = nxt_string("max"),
11911650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
11921650Sigor@sysoev.ru }, {
11931650Sigor@sysoev.ru .name = nxt_string("idle_timeout"),
11941650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
11951650Sigor@sysoev.ru },
1196507Smax.romanov@nginx.com
1197507Smax.romanov@nginx.com NXT_CONF_VLDT_END
1198507Smax.romanov@nginx.com };
1199507Smax.romanov@nginx.com
1200507Smax.romanov@nginx.com
12011649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_isolation_members[] = {
12021650Sigor@sysoev.ru {
12031650Sigor@sysoev.ru .name = nxt_string("namespaces"),
12041650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
12051651Sigor@sysoev.ru .validator = nxt_conf_vldt_clone_namespaces,
12061651Sigor@sysoev.ru .u.members = nxt_conf_vldt_app_namespaces_members,
12071650Sigor@sysoev.ru },
12081649Sigor@sysoev.ru
12091649Sigor@sysoev.ru #if (NXT_HAVE_CLONE_NEWUSER)
12101650Sigor@sysoev.ru {
12111650Sigor@sysoev.ru .name = nxt_string("uidmap"),
12121650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ARRAY,
12131651Sigor@sysoev.ru .validator = nxt_conf_vldt_array_iterator,
12141651Sigor@sysoev.ru .u.array = nxt_conf_vldt_clone_uidmap,
12151650Sigor@sysoev.ru }, {
12161650Sigor@sysoev.ru .name = nxt_string("gidmap"),
12171650Sigor@sysoev.ru .type = NXT_CONF_VLDT_ARRAY,
12181651Sigor@sysoev.ru .validator = nxt_conf_vldt_array_iterator,
12191651Sigor@sysoev.ru .u.array = nxt_conf_vldt_clone_gidmap,
12201650Sigor@sysoev.ru },
12211649Sigor@sysoev.ru #endif
12221649Sigor@sysoev.ru
12231649Sigor@sysoev.ru #if (NXT_HAVE_ISOLATION_ROOTFS)
12241650Sigor@sysoev.ru {
12251650Sigor@sysoev.ru .name = nxt_string("rootfs"),
12261650Sigor@sysoev.ru .type = NXT_CONF_VLDT_STRING,
12271650Sigor@sysoev.ru }, {
12281650Sigor@sysoev.ru .name = nxt_string("automount"),
12291650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
12301651Sigor@sysoev.ru .validator = nxt_conf_vldt_object,
12311651Sigor@sysoev.ru .u.members = nxt_conf_vldt_app_automount_members,
12321650Sigor@sysoev.ru },
12331649Sigor@sysoev.ru #endif
12341649Sigor@sysoev.ru
12351649Sigor@sysoev.ru #if (NXT_HAVE_PR_SET_NO_NEW_PRIVS)
12361650Sigor@sysoev.ru {
12371650Sigor@sysoev.ru .name = nxt_string("new_privs"),
12381650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12391650Sigor@sysoev.ru },
12401649Sigor@sysoev.ru #endif
12411649Sigor@sysoev.ru
12422262Sa.clayton@nginx.com #if (NXT_HAVE_CGROUP)
12432262Sa.clayton@nginx.com {
12442262Sa.clayton@nginx.com .name = nxt_string("cgroup"),
12452262Sa.clayton@nginx.com .type = NXT_CONF_VLDT_OBJECT,
12462262Sa.clayton@nginx.com .validator = nxt_conf_vldt_object,
12472262Sa.clayton@nginx.com .u.members = nxt_conf_vldt_app_cgroup_members,
12482262Sa.clayton@nginx.com },
12492262Sa.clayton@nginx.com #endif
12502262Sa.clayton@nginx.com
12511649Sigor@sysoev.ru NXT_CONF_VLDT_END
12521649Sigor@sysoev.ru };
12531649Sigor@sysoev.ru
12541649Sigor@sysoev.ru
12551182St.nateldemoura@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_app_namespaces_members[] = {
12561182St.nateldemoura@f5.com
12571182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWUSER)
12581650Sigor@sysoev.ru {
12591650Sigor@sysoev.ru .name = nxt_string("credential"),
12601650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12611650Sigor@sysoev.ru },
12621182St.nateldemoura@f5.com #endif
12631182St.nateldemoura@f5.com
12641182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWPID)
12651650Sigor@sysoev.ru {
12661650Sigor@sysoev.ru .name = nxt_string("pid"),
12671650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12681650Sigor@sysoev.ru },
12691182St.nateldemoura@f5.com #endif
12701182St.nateldemoura@f5.com
12711182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWNET)
12721650Sigor@sysoev.ru {
12731650Sigor@sysoev.ru .name = nxt_string("network"),
12741650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12751650Sigor@sysoev.ru },
12761182St.nateldemoura@f5.com #endif
12771182St.nateldemoura@f5.com
12781182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWNS)
12791650Sigor@sysoev.ru {
12801650Sigor@sysoev.ru .name = nxt_string("mount"),
12811650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12821650Sigor@sysoev.ru },
12831182St.nateldemoura@f5.com #endif
12841182St.nateldemoura@f5.com
12851182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWUTS)
12861650Sigor@sysoev.ru {
12871650Sigor@sysoev.ru .name = nxt_string("uname"),
12881650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12891650Sigor@sysoev.ru },
12901182St.nateldemoura@f5.com #endif
12911182St.nateldemoura@f5.com
12921182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWCGROUP)
12931650Sigor@sysoev.ru {
12941650Sigor@sysoev.ru .name = nxt_string("cgroup"),
12951650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
12961650Sigor@sysoev.ru },
12971182St.nateldemoura@f5.com #endif
12981182St.nateldemoura@f5.com
12991182St.nateldemoura@f5.com NXT_CONF_VLDT_END
13001182St.nateldemoura@f5.com };
13011182St.nateldemoura@f5.com
13021182St.nateldemoura@f5.com
13031649Sigor@sysoev.ru #if (NXT_HAVE_ISOLATION_ROOTFS)
13041649Sigor@sysoev.ru
13051649Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_app_automount_members[] = {
13061650Sigor@sysoev.ru {
13071650Sigor@sysoev.ru .name = nxt_string("language_deps"),
13081650Sigor@sysoev.ru .type = NXT_CONF_VLDT_BOOLEAN,
13091704St.nateldemoura@f5.com }, {
13101704St.nateldemoura@f5.com .name = nxt_string("tmpfs"),
13111704St.nateldemoura@f5.com .type = NXT_CONF_VLDT_BOOLEAN,
13121708St.nateldemoura@f5.com }, {
13131708St.nateldemoura@f5.com .name = nxt_string("procfs"),
13141708St.nateldemoura@f5.com .type = NXT_CONF_VLDT_BOOLEAN,
13151650Sigor@sysoev.ru },
13161649Sigor@sysoev.ru
13171649Sigor@sysoev.ru NXT_CONF_VLDT_END
13181649Sigor@sysoev.ru };
13191649Sigor@sysoev.ru
13201649Sigor@sysoev.ru #endif
13211649Sigor@sysoev.ru
13221649Sigor@sysoev.ru
13232262Sa.clayton@nginx.com #if (NXT_HAVE_CGROUP)
13242262Sa.clayton@nginx.com
13252262Sa.clayton@nginx.com static nxt_conf_vldt_object_t nxt_conf_vldt_app_cgroup_members[] = {
13262262Sa.clayton@nginx.com {
13272262Sa.clayton@nginx.com .name = nxt_string("path"),
13282262Sa.clayton@nginx.com .type = NXT_CONF_VLDT_STRING,
13292262Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
13302262Sa.clayton@nginx.com .validator = nxt_conf_vldt_cgroup_path,
13312262Sa.clayton@nginx.com },
13322262Sa.clayton@nginx.com
13332262Sa.clayton@nginx.com NXT_CONF_VLDT_END
13342262Sa.clayton@nginx.com };
13352262Sa.clayton@nginx.com
13362262Sa.clayton@nginx.com #endif
13372262Sa.clayton@nginx.com
13382262Sa.clayton@nginx.com
13391182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWUSER)
13401182St.nateldemoura@f5.com
13411182St.nateldemoura@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_app_procmap_members[] = {
13421650Sigor@sysoev.ru {
13431650Sigor@sysoev.ru .name = nxt_string("container"),
13441650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
13452630Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
13461650Sigor@sysoev.ru }, {
13471650Sigor@sysoev.ru .name = nxt_string("host"),
13481650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
13492630Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
13501650Sigor@sysoev.ru }, {
13511650Sigor@sysoev.ru .name = nxt_string("size"),
13521650Sigor@sysoev.ru .type = NXT_CONF_VLDT_INTEGER,
13532630Sa.clayton@nginx.com .flags = NXT_CONF_VLDT_REQUIRED,
13541650Sigor@sysoev.ru },
13551524Svbart@nginx.com
13561524Svbart@nginx.com NXT_CONF_VLDT_END
13571182St.nateldemoura@f5.com };
13581182St.nateldemoura@f5.com
13591182St.nateldemoura@f5.com #endif
13601182St.nateldemoura@f5.com
13611182St.nateldemoura@f5.com
13621394Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_upstream_members[] = {
13631650Sigor@sysoev.ru {
13641650Sigor@sysoev.ru .name = nxt_string("servers"),
13651650Sigor@sysoev.ru .type = NXT_CONF_VLDT_OBJECT,
13661651Sigor@sysoev.ru .validator = nxt_conf_vldt_object_iterator,
13671651Sigor@sysoev.ru .u.object = nxt_conf_vldt_server,
13681650Sigor@sysoev.ru },
13691394Sigor@sysoev.ru
13701394Sigor@sysoev.ru NXT_CONF_VLDT_END
13711394Sigor@sysoev.ru };
13721394Sigor@sysoev.ru
13731394Sigor@sysoev.ru
13741394Sigor@sysoev.ru static nxt_conf_vldt_object_t nxt_conf_vldt_upstream_server_members[] = {
13751650Sigor@sysoev.ru {
13761650Sigor@sysoev.ru .name = nxt_string("weight"),
13771650Sigor@sysoev.ru .type = NXT_CONF_VLDT_NUMBER,
13781651Sigor@sysoev.ru .validator = nxt_conf_vldt_server_weight,
13791650Sigor@sysoev.ru },
13801394Sigor@sysoev.ru
13811394Sigor@sysoev.ru NXT_CONF_VLDT_END
13821394Sigor@sysoev.ru };
13831394Sigor@sysoev.ru
13841394Sigor@sysoev.ru
13852166Sz.hong@f5.com static nxt_conf_vldt_object_t nxt_conf_vldt_access_log_members[] = {
13862166Sz.hong@f5.com {
13872166Sz.hong@f5.com .name = nxt_string("path"),
13882166Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
13892166Sz.hong@f5.com }, {
13902166Sz.hong@f5.com .name = nxt_string("format"),
13912166Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
13922625Sz.hong@f5.com }, {
13932625Sz.hong@f5.com .name = nxt_string("if"),
13942625Sz.hong@f5.com .type = NXT_CONF_VLDT_STRING,
13952625Sz.hong@f5.com .validator = nxt_conf_vldt_if,
13962166Sz.hong@f5.com },
13972166Sz.hong@f5.com
13982166Sz.hong@f5.com NXT_CONF_VLDT_END
13992166Sz.hong@f5.com };
14002166Sz.hong@f5.com
14012166Sz.hong@f5.com
1402116Svbart@nginx.com nxt_int_t
nxt_conf_validate(nxt_conf_validation_t * vldt)1403357Svbart@nginx.com nxt_conf_validate(nxt_conf_validation_t *vldt)
1404116Svbart@nginx.com {
1405357Svbart@nginx.com nxt_int_t ret;
14062247Sz.hong@f5.com u_char error[NXT_MAX_ERROR_STR];
14072247Sz.hong@f5.com
14082247Sz.hong@f5.com vldt->tstr_state = nxt_tstr_state_new(vldt->pool, 1);
14092246Sz.hong@f5.com if (nxt_slow_path(vldt->tstr_state == NULL)) {
14102450Sz.hong@f5.com return NXT_ERROR;
14112147Sz.hong@f5.com }
14122147Sz.hong@f5.com
1413487Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, NULL, vldt->conf, NXT_CONF_VLDT_OBJECT);
1414357Svbart@nginx.com if (ret != NXT_OK) {
14152450Sz.hong@f5.com return ret;
1416116Svbart@nginx.com }
1417116Svbart@nginx.com
14182247Sz.hong@f5.com ret = nxt_conf_vldt_object(vldt, vldt->conf, nxt_conf_vldt_root_members);
14192247Sz.hong@f5.com if (ret != NXT_OK) {
14202450Sz.hong@f5.com return ret;
14212247Sz.hong@f5.com }
14222247Sz.hong@f5.com
14232247Sz.hong@f5.com ret = nxt_tstr_state_done(vldt->tstr_state, error);
14242247Sz.hong@f5.com if (ret != NXT_OK) {
14252318Sz.hong@f5.com ret = nxt_conf_vldt_error(vldt, "%s", error);
14262450Sz.hong@f5.com return ret;
14272247Sz.hong@f5.com }
14282247Sz.hong@f5.com
14292247Sz.hong@f5.com return NXT_OK;
1430137Svbart@nginx.com }
1431137Svbart@nginx.com
1432137Svbart@nginx.com
14331473Svbart@nginx.com #define NXT_CONF_VLDT_ANY_TYPE_STR \
1434487Svbart@nginx.com "either a null, a boolean, an integer, " \
1435487Svbart@nginx.com "a number, a string, an array, or an object"
1436487Svbart@nginx.com
1437487Svbart@nginx.com
1438137Svbart@nginx.com 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)1439357Svbart@nginx.com nxt_conf_vldt_type(nxt_conf_validation_t *vldt, nxt_str_t *name,
1440487Svbart@nginx.com nxt_conf_value_t *value, nxt_conf_vldt_type_t type)
1441137Svbart@nginx.com {
1442487Svbart@nginx.com u_char *p;
1443487Svbart@nginx.com nxt_str_t expected;
14441523Saxel.duch@nginx.com nxt_bool_t comma;
1445487Svbart@nginx.com nxt_uint_t value_type, n, t;
14461473Svbart@nginx.com u_char buf[nxt_length(NXT_CONF_VLDT_ANY_TYPE_STR)];
1447357Svbart@nginx.com
1448487Svbart@nginx.com static nxt_str_t type_name[] = {
1449487Svbart@nginx.com nxt_string("a null"),
1450487Svbart@nginx.com nxt_string("a boolean"),
14511439Svbart@nginx.com nxt_string("an integer number"),
14521439Svbart@nginx.com nxt_string("a fractional number"),
1453487Svbart@nginx.com nxt_string("a string"),
1454487Svbart@nginx.com nxt_string("an array"),
1455487Svbart@nginx.com nxt_string("an object"),
1456357Svbart@nginx.com };
1457357Svbart@nginx.com
1458357Svbart@nginx.com value_type = nxt_conf_type(value);
1459357Svbart@nginx.com
1460487Svbart@nginx.com if ((1 << value_type) & type) {
1461357Svbart@nginx.com return NXT_OK;
1462357Svbart@nginx.com }
1463357Svbart@nginx.com
1464487Svbart@nginx.com p = buf;
1465487Svbart@nginx.com
1466701Spluknet@nginx.com n = nxt_popcount(type);
1467487Svbart@nginx.com
1468487Svbart@nginx.com if (n > 1) {
1469487Svbart@nginx.com p = nxt_cpymem(p, "either ", 7);
1470487Svbart@nginx.com }
1471487Svbart@nginx.com
14721523Saxel.duch@nginx.com comma = (n > 2);
1473487Svbart@nginx.com
1474487Svbart@nginx.com for ( ;; ) {
1475487Svbart@nginx.com t = __builtin_ffs(type) - 1;
1476487Svbart@nginx.com
1477487Svbart@nginx.com p = nxt_cpymem(p, type_name[t].start, type_name[t].length);
1478487Svbart@nginx.com
1479487Svbart@nginx.com n--;
1480487Svbart@nginx.com
1481487Svbart@nginx.com if (n == 0) {
1482487Svbart@nginx.com break;
1483487Svbart@nginx.com }
1484487Svbart@nginx.com
14851523Saxel.duch@nginx.com if (comma) {
1486487Svbart@nginx.com *p++ = ',';
1487487Svbart@nginx.com }
1488487Svbart@nginx.com
1489487Svbart@nginx.com if (n == 1) {
1490487Svbart@nginx.com p = nxt_cpymem(p, " or", 3);
1491487Svbart@nginx.com }
1492487Svbart@nginx.com
1493487Svbart@nginx.com *p++ = ' ';
1494487Svbart@nginx.com
1495487Svbart@nginx.com type = type & ~(1 << t);
1496487Svbart@nginx.com }
1497487Svbart@nginx.com
1498487Svbart@nginx.com expected.length = p - buf;
1499487Svbart@nginx.com expected.start = buf;
1500487Svbart@nginx.com
1501357Svbart@nginx.com if (name == NULL) {
1502357Svbart@nginx.com return nxt_conf_vldt_error(vldt,
1503487Svbart@nginx.com "The configuration must be %V, but not %V.",
1504487Svbart@nginx.com &expected, &type_name[value_type]);
1505357Svbart@nginx.com }
1506357Svbart@nginx.com
1507357Svbart@nginx.com return nxt_conf_vldt_error(vldt,
1508487Svbart@nginx.com "The \"%V\" value must be %V, but not %V.",
1509487Svbart@nginx.com name, &expected, &type_name[value_type]);
1510116Svbart@nginx.com }
1511116Svbart@nginx.com
1512116Svbart@nginx.com
1513116Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_error(nxt_conf_validation_t * vldt,const char * fmt,...)1514357Svbart@nginx.com nxt_conf_vldt_error(nxt_conf_validation_t *vldt, const char *fmt, ...)
1515357Svbart@nginx.com {
1516357Svbart@nginx.com u_char *p, *end;
1517357Svbart@nginx.com size_t size;
1518357Svbart@nginx.com va_list args;
1519357Svbart@nginx.com u_char error[NXT_MAX_ERROR_STR];
1520357Svbart@nginx.com
1521357Svbart@nginx.com va_start(args, fmt);
1522357Svbart@nginx.com end = nxt_vsprintf(error, error + NXT_MAX_ERROR_STR, fmt, args);
1523357Svbart@nginx.com va_end(args);
1524357Svbart@nginx.com
1525357Svbart@nginx.com size = end - error;
1526357Svbart@nginx.com
1527357Svbart@nginx.com p = nxt_mp_nget(vldt->pool, size);
1528357Svbart@nginx.com if (p == NULL) {
1529357Svbart@nginx.com return NXT_ERROR;
1530357Svbart@nginx.com }
1531357Svbart@nginx.com
1532357Svbart@nginx.com nxt_memcpy(p, error, size);
1533357Svbart@nginx.com
1534357Svbart@nginx.com vldt->error.length = size;
1535357Svbart@nginx.com vldt->error.start = p;
1536357Svbart@nginx.com
1537357Svbart@nginx.com return NXT_DECLINED;
1538357Svbart@nginx.com }
1539357Svbart@nginx.com
1540357Svbart@nginx.com
15411855Sz.hong@f5.com nxt_inline nxt_int_t
nxt_conf_vldt_unsupported(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)15421855Sz.hong@f5.com nxt_conf_vldt_unsupported(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
15431855Sz.hong@f5.com void *data)
15441855Sz.hong@f5.com {
15451855Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "Unit is built without the \"%s\" "
15461855Sz.hong@f5.com "option support.", data);
15471855Sz.hong@f5.com }
15481855Sz.hong@f5.com
15491855Sz.hong@f5.com
15501563Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_var(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_str_t * value)15511959Sz.hong@f5.com nxt_conf_vldt_var(nxt_conf_validation_t *vldt, nxt_str_t *name,
15521563Svbart@nginx.com nxt_str_t *value)
15531563Svbart@nginx.com {
15541563Svbart@nginx.com u_char error[NXT_MAX_ERROR_STR];
15551563Svbart@nginx.com
15562246Sz.hong@f5.com if (nxt_tstr_test(vldt->tstr_state, value, error) != NXT_OK) {
15571959Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "%s in the \"%V\" value.",
15581959Sz.hong@f5.com error, name);
15591563Svbart@nginx.com }
15601563Svbart@nginx.com
15611563Svbart@nginx.com return NXT_OK;
15621563Svbart@nginx.com }
15631563Svbart@nginx.com
15641563Svbart@nginx.com
15652625Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_if(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)15662625Sz.hong@f5.com nxt_conf_vldt_if(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
15672625Sz.hong@f5.com void *data)
15682625Sz.hong@f5.com {
15692625Sz.hong@f5.com nxt_str_t str;
15702625Sz.hong@f5.com
15712625Sz.hong@f5.com static nxt_str_t if_str = nxt_string("if");
15722625Sz.hong@f5.com
15732625Sz.hong@f5.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
15742625Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"if\" must be a string");
15752625Sz.hong@f5.com }
15762625Sz.hong@f5.com
15772625Sz.hong@f5.com nxt_conf_get_string(value, &str);
15782625Sz.hong@f5.com
15792625Sz.hong@f5.com if (str.length == 0) {
15802625Sz.hong@f5.com return NXT_OK;
15812625Sz.hong@f5.com }
15822625Sz.hong@f5.com
15832625Sz.hong@f5.com if (str.start[0] == '!') {
15842625Sz.hong@f5.com str.start++;
15852625Sz.hong@f5.com str.length--;
15862625Sz.hong@f5.com }
15872625Sz.hong@f5.com
15882625Sz.hong@f5.com if (nxt_is_tstr(&str)) {
15892625Sz.hong@f5.com return nxt_conf_vldt_var(vldt, &if_str, &str);
15902625Sz.hong@f5.com }
15912625Sz.hong@f5.com
15922625Sz.hong@f5.com return NXT_OK;
15932625Sz.hong@f5.com }
15942625Sz.hong@f5.com
15952625Sz.hong@f5.com
15961183Svbart@nginx.com typedef struct {
15971183Svbart@nginx.com nxt_mp_t *pool;
15981183Svbart@nginx.com nxt_str_t *type;
15991183Svbart@nginx.com nxt_lvlhsh_t hash;
16001183Svbart@nginx.com } nxt_conf_vldt_mtypes_ctx_t;
16011183Svbart@nginx.com
16021183Svbart@nginx.com
16031183Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_mtypes(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)16041183Svbart@nginx.com nxt_conf_vldt_mtypes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
16051183Svbart@nginx.com void *data)
16061183Svbart@nginx.com {
16071183Svbart@nginx.com nxt_int_t ret;
16081183Svbart@nginx.com nxt_conf_vldt_mtypes_ctx_t ctx;
16091183Svbart@nginx.com
16101183Svbart@nginx.com ctx.pool = nxt_mp_create(1024, 128, 256, 32);
16111183Svbart@nginx.com if (nxt_slow_path(ctx.pool == NULL)) {
16121183Svbart@nginx.com return NXT_ERROR;
16131183Svbart@nginx.com }
16141183Svbart@nginx.com
16151183Svbart@nginx.com nxt_lvlhsh_init(&ctx.hash);
16161183Svbart@nginx.com
16171183Svbart@nginx.com vldt->ctx = &ctx;
16181183Svbart@nginx.com
16191183Svbart@nginx.com ret = nxt_conf_vldt_object_iterator(vldt, value,
16201183Svbart@nginx.com &nxt_conf_vldt_mtypes_type);
16211183Svbart@nginx.com
16221183Svbart@nginx.com vldt->ctx = NULL;
16231183Svbart@nginx.com
16241183Svbart@nginx.com nxt_mp_destroy(ctx.pool);
16251183Svbart@nginx.com
16261183Svbart@nginx.com return ret;
16271183Svbart@nginx.com }
16281183Svbart@nginx.com
16291183Svbart@nginx.com
16301183Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_mtypes_type(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)16311183Svbart@nginx.com nxt_conf_vldt_mtypes_type(nxt_conf_validation_t *vldt, nxt_str_t *name,
16321183Svbart@nginx.com nxt_conf_value_t *value)
16331183Svbart@nginx.com {
16341183Svbart@nginx.com nxt_int_t ret;
16351183Svbart@nginx.com nxt_conf_vldt_mtypes_ctx_t *ctx;
16361183Svbart@nginx.com
16371183Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, name, value,
16381183Svbart@nginx.com NXT_CONF_VLDT_STRING|NXT_CONF_VLDT_ARRAY);
16391183Svbart@nginx.com if (ret != NXT_OK) {
16401183Svbart@nginx.com return ret;
16411183Svbart@nginx.com }
16421183Svbart@nginx.com
16431183Svbart@nginx.com ctx = vldt->ctx;
16441183Svbart@nginx.com
16451183Svbart@nginx.com ctx->type = nxt_mp_get(ctx->pool, sizeof(nxt_str_t));
16461183Svbart@nginx.com if (nxt_slow_path(ctx->type == NULL)) {
16471183Svbart@nginx.com return NXT_ERROR;
16481183Svbart@nginx.com }
16491183Svbart@nginx.com
16501183Svbart@nginx.com *ctx->type = *name;
16511183Svbart@nginx.com
16521183Svbart@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
16531183Svbart@nginx.com return nxt_conf_vldt_array_iterator(vldt, value,
16541183Svbart@nginx.com &nxt_conf_vldt_mtypes_extension);
16551183Svbart@nginx.com }
16561183Svbart@nginx.com
16571183Svbart@nginx.com /* NXT_CONF_STRING */
16581183Svbart@nginx.com
16591183Svbart@nginx.com return nxt_conf_vldt_mtypes_extension(vldt, value);
16601183Svbart@nginx.com }
16611183Svbart@nginx.com
16621183Svbart@nginx.com
16631183Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_mtypes_extension(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)16641183Svbart@nginx.com nxt_conf_vldt_mtypes_extension(nxt_conf_validation_t *vldt,
16651183Svbart@nginx.com nxt_conf_value_t *value)
16661183Svbart@nginx.com {
16671923Sz.hong@f5.com nxt_str_t exten, *dup_type;
16681183Svbart@nginx.com nxt_conf_vldt_mtypes_ctx_t *ctx;
16691183Svbart@nginx.com
16701183Svbart@nginx.com ctx = vldt->ctx;
16711183Svbart@nginx.com
16721183Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
16731183Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"%V\" MIME type array must "
16741183Svbart@nginx.com "contain only strings.", ctx->type);
16751183Svbart@nginx.com }
16761183Svbart@nginx.com
16771923Sz.hong@f5.com nxt_conf_get_string(value, &exten);
16781923Sz.hong@f5.com
16791923Sz.hong@f5.com if (exten.length == 0) {
16801183Svbart@nginx.com return nxt_conf_vldt_error(vldt, "An empty file extension for "
16811183Svbart@nginx.com "the \"%V\" MIME type.", ctx->type);
16821183Svbart@nginx.com }
16831183Svbart@nginx.com
16841923Sz.hong@f5.com dup_type = nxt_http_static_mtype_get(&ctx->hash, &exten);
16851183Svbart@nginx.com
16861883So.canty@f5.com if (dup_type->length != 0) {
16871183Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"%V\" file extension has been "
16881183Svbart@nginx.com "declared for \"%V\" and \"%V\" "
16891183Svbart@nginx.com "MIME types at the same time.",
16901923Sz.hong@f5.com &exten, dup_type, ctx->type);
16911183Svbart@nginx.com }
16921183Svbart@nginx.com
16931923Sz.hong@f5.com return nxt_http_static_mtypes_hash_add(ctx->pool, &ctx->hash, &exten,
16941923Sz.hong@f5.com ctx->type);
16951183Svbart@nginx.com }
16961183Svbart@nginx.com
16971183Svbart@nginx.com
1698357Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_listener(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)1699357Svbart@nginx.com nxt_conf_vldt_listener(nxt_conf_validation_t *vldt, nxt_str_t *name,
1700357Svbart@nginx.com nxt_conf_value_t *value)
1701357Svbart@nginx.com {
17021578Svbart@nginx.com nxt_int_t ret;
17032180Salx.manpages@gmail.com nxt_str_t str;
17041578Svbart@nginx.com nxt_sockaddr_t *sa;
17051578Svbart@nginx.com
17062180Salx.manpages@gmail.com if (nxt_slow_path(nxt_str_dup(vldt->pool, &str, name) == NULL)) {
17072180Salx.manpages@gmail.com return NXT_ERROR;
17082180Salx.manpages@gmail.com }
17092180Salx.manpages@gmail.com
17102180Salx.manpages@gmail.com sa = nxt_sockaddr_parse(vldt->pool, &str);
17111578Svbart@nginx.com if (nxt_slow_path(sa == NULL)) {
17121578Svbart@nginx.com return nxt_conf_vldt_error(vldt,
17131578Svbart@nginx.com "The listener address \"%V\" is invalid.",
17141578Svbart@nginx.com name);
17151578Svbart@nginx.com }
1716357Svbart@nginx.com
1717487Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, name, value, NXT_CONF_VLDT_OBJECT);
1718357Svbart@nginx.com if (ret != NXT_OK) {
1719357Svbart@nginx.com return ret;
1720357Svbart@nginx.com }
1721357Svbart@nginx.com
1722357Svbart@nginx.com return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_listener_members);
1723357Svbart@nginx.com }
1724357Svbart@nginx.com
1725357Svbart@nginx.com
1726965Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_action(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)17271233Svbart@nginx.com nxt_conf_vldt_action(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
17281233Svbart@nginx.com void *data)
17291233Svbart@nginx.com {
17301377Svbart@nginx.com nxt_uint_t i;
17311377Svbart@nginx.com nxt_conf_value_t *action;
17321377Svbart@nginx.com nxt_conf_vldt_object_t *members;
17331377Svbart@nginx.com
17341377Svbart@nginx.com static struct {
17351377Svbart@nginx.com nxt_str_t name;
17361377Svbart@nginx.com nxt_conf_vldt_object_t *members;
17371377Svbart@nginx.com
17381377Svbart@nginx.com } actions[] = {
17391377Svbart@nginx.com { nxt_string("pass"), nxt_conf_vldt_pass_action_members },
17401429Svbart@nginx.com { nxt_string("return"), nxt_conf_vldt_return_action_members },
17411377Svbart@nginx.com { nxt_string("share"), nxt_conf_vldt_share_action_members },
17421377Svbart@nginx.com { nxt_string("proxy"), nxt_conf_vldt_proxy_action_members },
17431377Svbart@nginx.com };
17441233Svbart@nginx.com
17451377Svbart@nginx.com members = NULL;
17461377Svbart@nginx.com
17471377Svbart@nginx.com for (i = 0; i < nxt_nitems(actions); i++) {
17481377Svbart@nginx.com action = nxt_conf_get_object_member(value, &actions[i].name, NULL);
17491233Svbart@nginx.com
17501377Svbart@nginx.com if (action == NULL) {
17511377Svbart@nginx.com continue;
17521377Svbart@nginx.com }
17531233Svbart@nginx.com
17541377Svbart@nginx.com if (members != NULL) {
17551377Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"action\" object must have "
17561429Svbart@nginx.com "just one of \"pass\", \"return\", "
17571429Svbart@nginx.com "\"share\", or \"proxy\" options set.");
17581377Svbart@nginx.com }
17591377Svbart@nginx.com
17601377Svbart@nginx.com members = actions[i].members;
17611233Svbart@nginx.com }
17621233Svbart@nginx.com
17631377Svbart@nginx.com if (members == NULL) {
17641233Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"action\" object must have "
17651429Svbart@nginx.com "either \"pass\", \"return\", \"share\", "
17661429Svbart@nginx.com "or \"proxy\" option set.");
17671233Svbart@nginx.com }
17681233Svbart@nginx.com
17691377Svbart@nginx.com return nxt_conf_vldt_object(vldt, value, members);
17701233Svbart@nginx.com }
17711233Svbart@nginx.com
17721233Svbart@nginx.com
17731233Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_pass(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)1774965Svbart@nginx.com nxt_conf_vldt_pass(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
1775965Svbart@nginx.com void *data)
1776965Svbart@nginx.com {
17771472Svbart@nginx.com nxt_str_t pass;
17781472Svbart@nginx.com nxt_int_t ret;
17791473Svbart@nginx.com nxt_str_t segments[3];
17801473Svbart@nginx.com
17811473Svbart@nginx.com static nxt_str_t targets_str = nxt_string("targets");
1782965Svbart@nginx.com
1783965Svbart@nginx.com nxt_conf_get_string(value, &pass);
1784965Svbart@nginx.com
17851473Svbart@nginx.com ret = nxt_http_pass_segments(vldt->pool, &pass, segments, 3);
17861472Svbart@nginx.com
17871472Svbart@nginx.com if (ret != NXT_OK) {
17881472Svbart@nginx.com if (ret == NXT_DECLINED) {
17891472Svbart@nginx.com return nxt_conf_vldt_error(vldt, "Request \"pass\" value \"%V\" "
17901472Svbart@nginx.com "is invalid.", &pass);
17911472Svbart@nginx.com }
17921472Svbart@nginx.com
17931472Svbart@nginx.com return NXT_ERROR;
17941472Svbart@nginx.com }
17951472Svbart@nginx.com
17961472Svbart@nginx.com if (nxt_str_eq(&segments[0], "applications", 12)) {
17971472Svbart@nginx.com
17981472Svbart@nginx.com if (segments[1].length == 0) {
1799965Svbart@nginx.com goto error;
1800965Svbart@nginx.com }
1801965Svbart@nginx.com
18021472Svbart@nginx.com value = nxt_conf_get_object_member(vldt->conf, &segments[0], NULL);
18031472Svbart@nginx.com
18041472Svbart@nginx.com if (value == NULL) {
1805965Svbart@nginx.com goto error;
1806965Svbart@nginx.com }
1807965Svbart@nginx.com
18081472Svbart@nginx.com value = nxt_conf_get_object_member(value, &segments[1], NULL);
18091472Svbart@nginx.com
18101472Svbart@nginx.com if (value == NULL) {
1811965Svbart@nginx.com goto error;
1812965Svbart@nginx.com }
1813965Svbart@nginx.com
18141473Svbart@nginx.com if (segments[2].length > 0) {
18151473Svbart@nginx.com value = nxt_conf_get_object_member(value, &targets_str, NULL);
18161473Svbart@nginx.com
18171473Svbart@nginx.com if (value == NULL) {
18181473Svbart@nginx.com goto error;
18191473Svbart@nginx.com }
18201473Svbart@nginx.com
18211473Svbart@nginx.com value = nxt_conf_get_object_member(value, &segments[2], NULL);
18221473Svbart@nginx.com
18231473Svbart@nginx.com if (value == NULL) {
18241473Svbart@nginx.com goto error;
18251473Svbart@nginx.com }
18261473Svbart@nginx.com }
18271473Svbart@nginx.com
1828965Svbart@nginx.com return NXT_OK;
1829965Svbart@nginx.com }
1830965Svbart@nginx.com
18311472Svbart@nginx.com if (nxt_str_eq(&segments[0], "upstreams", 9)) {
18321472Svbart@nginx.com
18331473Svbart@nginx.com if (segments[1].length == 0 || segments[2].length != 0) {
18341394Sigor@sysoev.ru goto error;
18351394Sigor@sysoev.ru }
18361394Sigor@sysoev.ru
18371472Svbart@nginx.com value = nxt_conf_get_object_member(vldt->conf, &segments[0], NULL);
18381472Svbart@nginx.com
18391472Svbart@nginx.com if (value == NULL) {
18401394Sigor@sysoev.ru goto error;
18411394Sigor@sysoev.ru }
18421394Sigor@sysoev.ru
18431472Svbart@nginx.com value = nxt_conf_get_object_member(value, &segments[1], NULL);
18441472Svbart@nginx.com
18451472Svbart@nginx.com if (value == NULL) {
18461394Sigor@sysoev.ru goto error;
18471394Sigor@sysoev.ru }
18481394Sigor@sysoev.ru
18491394Sigor@sysoev.ru return NXT_OK;
18501394Sigor@sysoev.ru }
18511394Sigor@sysoev.ru
18521472Svbart@nginx.com if (nxt_str_eq(&segments[0], "routes", 6)) {
18531473Svbart@nginx.com
18541473Svbart@nginx.com if (segments[2].length != 0) {
18551473Svbart@nginx.com goto error;
18561473Svbart@nginx.com }
18571473Svbart@nginx.com
18581472Svbart@nginx.com value = nxt_conf_get_object_member(vldt->conf, &segments[0], NULL);
18591472Svbart@nginx.com
18601472Svbart@nginx.com if (value == NULL) {
1861966Svbart@nginx.com goto error;
1862966Svbart@nginx.com }
1863966Svbart@nginx.com
18641472Svbart@nginx.com if (segments[1].length == 0) {
1865966Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_ARRAY) {
1866966Svbart@nginx.com goto error;
1867966Svbart@nginx.com }
1868966Svbart@nginx.com
1869966Svbart@nginx.com return NXT_OK;
1870966Svbart@nginx.com }
1871966Svbart@nginx.com
1872966Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
1873966Svbart@nginx.com goto error;
1874966Svbart@nginx.com }
1875966Svbart@nginx.com
18761472Svbart@nginx.com value = nxt_conf_get_object_member(value, &segments[1], NULL);
18771472Svbart@nginx.com
18781472Svbart@nginx.com if (value == NULL) {
1879966Svbart@nginx.com goto error;
1880966Svbart@nginx.com }
1881966Svbart@nginx.com
1882966Svbart@nginx.com return NXT_OK;
1883966Svbart@nginx.com }
1884966Svbart@nginx.com
1885965Svbart@nginx.com error:
1886965Svbart@nginx.com
1887965Svbart@nginx.com return nxt_conf_vldt_error(vldt, "Request \"pass\" points to invalid "
1888965Svbart@nginx.com "location \"%V\".", &pass);
1889965Svbart@nginx.com }
1890965Svbart@nginx.com
1891965Svbart@nginx.com
1892966Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_return(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)18931429Svbart@nginx.com nxt_conf_vldt_return(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
18941429Svbart@nginx.com void *data)
18951429Svbart@nginx.com {
18961429Svbart@nginx.com int64_t status;
18971429Svbart@nginx.com
18981439Svbart@nginx.com status = nxt_conf_get_number(value);
18991429Svbart@nginx.com
19001429Svbart@nginx.com if (status < NXT_HTTP_INVALID || status > NXT_HTTP_STATUS_MAX) {
19011429Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"return\" value is out of "
19021429Svbart@nginx.com "allowed HTTP status code range 0-999.");
19031429Svbart@nginx.com }
19041429Svbart@nginx.com
19051429Svbart@nginx.com return NXT_OK;
19061429Svbart@nginx.com }
19071429Svbart@nginx.com
19081429Svbart@nginx.com
19091429Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_share(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)19101961Sz.hong@f5.com nxt_conf_vldt_share(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
19111961Sz.hong@f5.com void *data)
19121961Sz.hong@f5.com {
19131961Sz.hong@f5.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
19141961Sz.hong@f5.com if (nxt_conf_array_elements_count(value) == 0) {
19151961Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"share\" array "
19161961Sz.hong@f5.com "must contain at least one element.");
19171961Sz.hong@f5.com }
19181961Sz.hong@f5.com
19191961Sz.hong@f5.com return nxt_conf_vldt_array_iterator(vldt, value,
19201961Sz.hong@f5.com &nxt_conf_vldt_share_element);
19211961Sz.hong@f5.com }
19221961Sz.hong@f5.com
19231961Sz.hong@f5.com /* NXT_CONF_STRING */
19241961Sz.hong@f5.com
19251961Sz.hong@f5.com return nxt_conf_vldt_share_element(vldt, value);
19261961Sz.hong@f5.com }
19271961Sz.hong@f5.com
19281961Sz.hong@f5.com
19291961Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_share_element(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)19301961Sz.hong@f5.com nxt_conf_vldt_share_element(nxt_conf_validation_t *vldt,
19311961Sz.hong@f5.com nxt_conf_value_t *value)
19321961Sz.hong@f5.com {
19331961Sz.hong@f5.com nxt_str_t str;
19341961Sz.hong@f5.com
19351961Sz.hong@f5.com static nxt_str_t share = nxt_string("share");
19361961Sz.hong@f5.com
19371961Sz.hong@f5.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
19381961Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"share\" array must "
19391961Sz.hong@f5.com "contain only string values.");
19401961Sz.hong@f5.com }
19411961Sz.hong@f5.com
19421961Sz.hong@f5.com nxt_conf_get_string(value, &str);
19431961Sz.hong@f5.com
19442247Sz.hong@f5.com if (nxt_is_tstr(&str)) {
19451961Sz.hong@f5.com return nxt_conf_vldt_var(vldt, &share, &str);
19461961Sz.hong@f5.com }
19471961Sz.hong@f5.com
19481961Sz.hong@f5.com return NXT_OK;
19491961Sz.hong@f5.com }
19501961Sz.hong@f5.com
19511961Sz.hong@f5.com
19521961Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_proxy(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)19531270Sigor@sysoev.ru nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
19541270Sigor@sysoev.ru void *data)
19551270Sigor@sysoev.ru {
19562634Salx@kernel.org nxt_str_t name, *ret;
19571270Sigor@sysoev.ru nxt_sockaddr_t *sa;
19581270Sigor@sysoev.ru
19592634Salx@kernel.org ret = nxt_conf_get_string_dup(value, vldt->pool, &name);
19602634Salx@kernel.org if (nxt_slow_path(ret == NULL)) {
19612634Salx@kernel.org return NXT_ERROR;
19622634Salx@kernel.org }
19631270Sigor@sysoev.ru
19641270Sigor@sysoev.ru if (nxt_str_start(&name, "http://", 7)) {
19651270Sigor@sysoev.ru name.length -= 7;
19661270Sigor@sysoev.ru name.start += 7;
19671270Sigor@sysoev.ru
19681270Sigor@sysoev.ru sa = nxt_sockaddr_parse(vldt->pool, &name);
19691270Sigor@sysoev.ru if (sa != NULL) {
19701270Sigor@sysoev.ru return NXT_OK;
19711270Sigor@sysoev.ru }
19721270Sigor@sysoev.ru }
19731270Sigor@sysoev.ru
19741270Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"proxy\" address is invalid \"%V\"",
19751270Sigor@sysoev.ru &name);
19761270Sigor@sysoev.ru }
19771270Sigor@sysoev.ru
19781270Sigor@sysoev.ru
19791270Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_python(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)19801872So.canty@f5.com nxt_conf_vldt_python(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
19811872So.canty@f5.com void *data)
19821872So.canty@f5.com {
19831872So.canty@f5.com nxt_conf_value_t *targets;
19841872So.canty@f5.com
19851872So.canty@f5.com static nxt_str_t targets_str = nxt_string("targets");
19861872So.canty@f5.com
19871872So.canty@f5.com targets = nxt_conf_get_object_member(value, &targets_str, NULL);
19881872So.canty@f5.com
19891872So.canty@f5.com if (targets != NULL) {
19901872So.canty@f5.com return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_python_members);
19911872So.canty@f5.com }
19921872So.canty@f5.com
19931872So.canty@f5.com return nxt_conf_vldt_object(vldt, value,
19941872So.canty@f5.com nxt_conf_vldt_python_notargets_members);
19951872So.canty@f5.com }
19961872So.canty@f5.com
19971872So.canty@f5.com
19981872So.canty@f5.com static nxt_int_t
nxt_conf_vldt_python_path(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)19991759Svbart@nginx.com nxt_conf_vldt_python_path(nxt_conf_validation_t *vldt,
20001759Svbart@nginx.com nxt_conf_value_t *value, void *data)
20011759Svbart@nginx.com {
20021759Svbart@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
20031759Svbart@nginx.com return nxt_conf_vldt_array_iterator(vldt, value,
20041759Svbart@nginx.com &nxt_conf_vldt_python_path_element);
20051759Svbart@nginx.com }
20061759Svbart@nginx.com
20071759Svbart@nginx.com /* NXT_CONF_STRING */
20081759Svbart@nginx.com
20091759Svbart@nginx.com return NXT_OK;
20101759Svbart@nginx.com }
20111759Svbart@nginx.com
20121759Svbart@nginx.com
20131759Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_python_path_element(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)20141759Svbart@nginx.com nxt_conf_vldt_python_path_element(nxt_conf_validation_t *vldt,
20151759Svbart@nginx.com nxt_conf_value_t *value)
20161759Svbart@nginx.com {
20171759Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
20181759Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"path\" array must contain "
20191759Svbart@nginx.com "only string values.");
20201759Svbart@nginx.com }
20211759Svbart@nginx.com
20221759Svbart@nginx.com return NXT_OK;
20231759Svbart@nginx.com }
20241759Svbart@nginx.com
20251759Svbart@nginx.com
20261759Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_python_protocol(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)20271697Smax.romanov@nginx.com nxt_conf_vldt_python_protocol(nxt_conf_validation_t *vldt,
20281697Smax.romanov@nginx.com nxt_conf_value_t *value, void *data)
20291697Smax.romanov@nginx.com {
20301697Smax.romanov@nginx.com nxt_str_t proto;
20311697Smax.romanov@nginx.com
20321697Smax.romanov@nginx.com static const nxt_str_t wsgi = nxt_string("wsgi");
20331697Smax.romanov@nginx.com static const nxt_str_t asgi = nxt_string("asgi");
20341697Smax.romanov@nginx.com
20351697Smax.romanov@nginx.com nxt_conf_get_string(value, &proto);
20361697Smax.romanov@nginx.com
20371697Smax.romanov@nginx.com if (nxt_strstr_eq(&proto, &wsgi) || nxt_strstr_eq(&proto, &asgi)) {
20381697Smax.romanov@nginx.com return NXT_OK;
20391697Smax.romanov@nginx.com }
20401697Smax.romanov@nginx.com
20411697Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"protocol\" can either be "
20421697Smax.romanov@nginx.com "\"wsgi\" or \"asgi\".");
20431697Smax.romanov@nginx.com }
20441697Smax.romanov@nginx.com
20451697Smax.romanov@nginx.com
20461697Smax.romanov@nginx.com static nxt_int_t
nxt_conf_vldt_python_prefix(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)20472273Sjeff.iadarola@gmail.com nxt_conf_vldt_python_prefix(nxt_conf_validation_t *vldt,
20482273Sjeff.iadarola@gmail.com nxt_conf_value_t *value, void *data)
20492273Sjeff.iadarola@gmail.com {
20502273Sjeff.iadarola@gmail.com nxt_str_t prefix;
20512273Sjeff.iadarola@gmail.com
20522273Sjeff.iadarola@gmail.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
20532273Sjeff.iadarola@gmail.com return nxt_conf_vldt_error(vldt, "The \"prefix\" must be a string "
20542273Sjeff.iadarola@gmail.com "beginning with \"/\".");
20552273Sjeff.iadarola@gmail.com }
20562273Sjeff.iadarola@gmail.com
20572273Sjeff.iadarola@gmail.com nxt_conf_get_string(value, &prefix);
20582273Sjeff.iadarola@gmail.com
20592273Sjeff.iadarola@gmail.com if (!nxt_strchr_start(&prefix, '/')) {
20602273Sjeff.iadarola@gmail.com return nxt_conf_vldt_error(vldt, "The \"prefix\" must be a string "
20612273Sjeff.iadarola@gmail.com "beginning with \"/\".");
20622273Sjeff.iadarola@gmail.com }
20632273Sjeff.iadarola@gmail.com
20642273Sjeff.iadarola@gmail.com return NXT_OK;
20652273Sjeff.iadarola@gmail.com }
20662273Sjeff.iadarola@gmail.com
20672273Sjeff.iadarola@gmail.com
20682273Sjeff.iadarola@gmail.com static nxt_int_t
nxt_conf_vldt_threads(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)20691681Smax.romanov@nginx.com nxt_conf_vldt_threads(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
20701681Smax.romanov@nginx.com void *data)
20711681Smax.romanov@nginx.com {
20721681Smax.romanov@nginx.com int64_t threads;
20731681Smax.romanov@nginx.com
20741681Smax.romanov@nginx.com threads = nxt_conf_get_number(value);
20751681Smax.romanov@nginx.com
20761681Smax.romanov@nginx.com if (threads < 1) {
20771681Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"threads\" number must be "
20781681Smax.romanov@nginx.com "equal to or greater than 1.");
20791681Smax.romanov@nginx.com }
20801681Smax.romanov@nginx.com
20811681Smax.romanov@nginx.com if (threads > NXT_INT32_T_MAX) {
20821681Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"threads\" number must "
20831681Smax.romanov@nginx.com "not exceed %d.", NXT_INT32_T_MAX);
20841681Smax.romanov@nginx.com }
20851681Smax.romanov@nginx.com
20861681Smax.romanov@nginx.com return NXT_OK;
20871681Smax.romanov@nginx.com }
20881681Smax.romanov@nginx.com
20891681Smax.romanov@nginx.com
20901681Smax.romanov@nginx.com static nxt_int_t
nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)20911681Smax.romanov@nginx.com nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
20921681Smax.romanov@nginx.com nxt_conf_value_t *value, void *data)
20931681Smax.romanov@nginx.com {
20941955Smax.romanov@nginx.com int64_t size, min_size;
20951681Smax.romanov@nginx.com
20961681Smax.romanov@nginx.com size = nxt_conf_get_number(value);
20971955Smax.romanov@nginx.com min_size = sysconf(_SC_THREAD_STACK_MIN);
20981955Smax.romanov@nginx.com
20991955Smax.romanov@nginx.com if (size < min_size) {
21001681Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"thread_stack_size\" number "
21011681Smax.romanov@nginx.com "must be equal to or greater than %d.",
21021955Smax.romanov@nginx.com min_size);
21031681Smax.romanov@nginx.com }
21041681Smax.romanov@nginx.com
21051681Smax.romanov@nginx.com if ((size % nxt_pagesize) != 0) {
21061681Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"thread_stack_size\" number "
21071681Smax.romanov@nginx.com "must be a multiple of the system page size (%d).",
21081681Smax.romanov@nginx.com nxt_pagesize);
21091681Smax.romanov@nginx.com }
21101681Smax.romanov@nginx.com
21111681Smax.romanov@nginx.com return NXT_OK;
21121681Smax.romanov@nginx.com }
21131681Smax.romanov@nginx.com
21141681Smax.romanov@nginx.com
21151681Smax.romanov@nginx.com static nxt_int_t
nxt_conf_vldt_routes(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2116966Svbart@nginx.com nxt_conf_vldt_routes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
2117966Svbart@nginx.com void *data)
2118966Svbart@nginx.com {
2119966Svbart@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
2120966Svbart@nginx.com return nxt_conf_vldt_array_iterator(vldt, value,
2121966Svbart@nginx.com &nxt_conf_vldt_route);
2122966Svbart@nginx.com }
2123966Svbart@nginx.com
2124966Svbart@nginx.com /* NXT_CONF_OBJECT */
2125966Svbart@nginx.com
2126966Svbart@nginx.com return nxt_conf_vldt_object_iterator(vldt, value,
2127966Svbart@nginx.com &nxt_conf_vldt_routes_member);
2128966Svbart@nginx.com }
2129966Svbart@nginx.com
2130966Svbart@nginx.com
2131966Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_routes_member(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)2132966Svbart@nginx.com nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt, nxt_str_t *name,
2133966Svbart@nginx.com nxt_conf_value_t *value)
2134966Svbart@nginx.com {
2135966Svbart@nginx.com nxt_int_t ret;
2136966Svbart@nginx.com
2137966Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, name, value, NXT_CONF_VLDT_ARRAY);
2138966Svbart@nginx.com
2139966Svbart@nginx.com if (ret != NXT_OK) {
2140966Svbart@nginx.com return ret;
2141966Svbart@nginx.com }
2142966Svbart@nginx.com
2143966Svbart@nginx.com return nxt_conf_vldt_array_iterator(vldt, value, &nxt_conf_vldt_route);
2144966Svbart@nginx.com }
2145966Svbart@nginx.com
2146966Svbart@nginx.com
2147966Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_route(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)2148966Svbart@nginx.com nxt_conf_vldt_route(nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
2149966Svbart@nginx.com {
2150966Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
2151966Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"routes\" array must contain "
2152966Svbart@nginx.com "only object values.");
2153966Svbart@nginx.com }
2154966Svbart@nginx.com
2155966Svbart@nginx.com return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_route_members);
2156966Svbart@nginx.com }
2157966Svbart@nginx.com
2158966Svbart@nginx.com
2159966Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_match_patterns(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2160966Svbart@nginx.com nxt_conf_vldt_match_patterns(nxt_conf_validation_t *vldt,
2161966Svbart@nginx.com nxt_conf_value_t *value, void *data)
2162966Svbart@nginx.com {
21631988Sz.hong@f5.com nxt_int_t ret;
21641988Sz.hong@f5.com
21651988Sz.hong@f5.com vldt->ctx = data;
21661988Sz.hong@f5.com
2167966Svbart@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
21681988Sz.hong@f5.com ret = nxt_conf_vldt_array_iterator(vldt, value,
21691988Sz.hong@f5.com &nxt_conf_vldt_match_pattern);
21701988Sz.hong@f5.com
21711988Sz.hong@f5.com } else {
21721988Sz.hong@f5.com /* NXT_CONF_STRING */
21731988Sz.hong@f5.com ret = nxt_conf_vldt_match_pattern(vldt, value);
2174966Svbart@nginx.com }
2175966Svbart@nginx.com
21761988Sz.hong@f5.com vldt->ctx = NULL;
21771988Sz.hong@f5.com
21781988Sz.hong@f5.com return ret;
2179966Svbart@nginx.com }
2180966Svbart@nginx.com
2181966Svbart@nginx.com
2182966Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_match_pattern(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)2183966Svbart@nginx.com nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
2184966Svbart@nginx.com nxt_conf_value_t *value)
2185966Svbart@nginx.com {
21861721Saxel.duch@nginx.com nxt_str_t pattern;
21871721Saxel.duch@nginx.com nxt_uint_t i, first, last;
21881721Saxel.duch@nginx.com #if (NXT_HAVE_REGEX)
21891721Saxel.duch@nginx.com nxt_regex_t *re;
21901721Saxel.duch@nginx.com nxt_regex_err_t err;
21911721Saxel.duch@nginx.com #endif
21921032Sigor@sysoev.ru
2193966Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
21941988Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern for \"%s\" "
21951988Sz.hong@f5.com "must be strings.", vldt->ctx);
2196966Svbart@nginx.com }
2197966Svbart@nginx.com
2198966Svbart@nginx.com nxt_conf_get_string(value, &pattern);
2199966Svbart@nginx.com
2200966Svbart@nginx.com if (pattern.length == 0) {
2201966Svbart@nginx.com return NXT_OK;
2202966Svbart@nginx.com }
2203966Svbart@nginx.com
2204966Svbart@nginx.com first = (pattern.start[0] == '!');
22051721Saxel.duch@nginx.com
22061721Saxel.duch@nginx.com if (first < pattern.length && pattern.start[first] == '~') {
22071721Saxel.duch@nginx.com #if (NXT_HAVE_REGEX)
22081721Saxel.duch@nginx.com pattern.start += first + 1;
22091721Saxel.duch@nginx.com pattern.length -= first + 1;
22101721Saxel.duch@nginx.com
22111721Saxel.duch@nginx.com re = nxt_regex_compile(vldt->pool, &pattern, &err);
22121721Saxel.duch@nginx.com if (nxt_slow_path(re == NULL)) {
22131721Saxel.duch@nginx.com if (err.offset < pattern.length) {
22141721Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "Invalid regular expression: "
22151721Saxel.duch@nginx.com "%s at offset %d",
22161721Saxel.duch@nginx.com err.msg, err.offset);
22171721Saxel.duch@nginx.com }
22181721Saxel.duch@nginx.com
22191721Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "Invalid regular expression: %s",
22201721Saxel.duch@nginx.com err.msg);
22211721Saxel.duch@nginx.com }
22221721Saxel.duch@nginx.com
22231721Saxel.duch@nginx.com return NXT_OK;
22241721Saxel.duch@nginx.com #else
22251721Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "Unit is built without support of "
22261721Saxel.duch@nginx.com "regular expressions: \"--no-regex\" "
22271721Saxel.duch@nginx.com "./configure option was set.");
22281721Saxel.duch@nginx.com #endif
22291721Saxel.duch@nginx.com }
22301721Saxel.duch@nginx.com
22311530Saxel.duch@nginx.com last = pattern.length - 1;
22321530Saxel.duch@nginx.com
22331530Saxel.duch@nginx.com for (i = first; i < last; i++) {
22341508Saxel.duch@nginx.com if (pattern.start[i] == '*' && pattern.start[i + 1] == '*') {
22351508Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
22361508Saxel.duch@nginx.com "not contain double \"*\" markers.");
2237966Svbart@nginx.com }
2238966Svbart@nginx.com }
2239966Svbart@nginx.com
2240966Svbart@nginx.com return NXT_OK;
2241966Svbart@nginx.com }
2242966Svbart@nginx.com
2243966Svbart@nginx.com
nxt_conf_vldt_match_encoded_patterns_sets(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)22441474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_patterns_sets(
22451474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data)
22461474Saxel.duch@nginx.com {
22471474Saxel.duch@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
22481474Saxel.duch@nginx.com return nxt_conf_vldt_array_iterator(vldt, value,
22491474Saxel.duch@nginx.com &nxt_conf_vldt_match_encoded_patterns_set);
22501474Saxel.duch@nginx.com }
22511474Saxel.duch@nginx.com
22521988Sz.hong@f5.com /* NXT_CONF_OBJECT */
22531474Saxel.duch@nginx.com
22541474Saxel.duch@nginx.com return nxt_conf_vldt_match_encoded_patterns_set(vldt, value);
22551474Saxel.duch@nginx.com }
22561474Saxel.duch@nginx.com
22571474Saxel.duch@nginx.com
nxt_conf_vldt_match_encoded_patterns_set(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)22581474Saxel.duch@nginx.com static nxt_int_t nxt_conf_vldt_match_encoded_patterns_set(
22591474Saxel.duch@nginx.com nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
22601474Saxel.duch@nginx.com {
22611474Saxel.duch@nginx.com if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
22621474Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern for "
22631474Saxel.duch@nginx.com "\"arguments\" must be an object.");
22641474Saxel.duch@nginx.com }
22651474Saxel.duch@nginx.com
22661474Saxel.duch@nginx.com return nxt_conf_vldt_object_iterator(vldt, value,
22671474Saxel.duch@nginx.com &nxt_conf_vldt_match_encoded_patterns_set_member);
22681474Saxel.duch@nginx.com }
22691474Saxel.duch@nginx.com
22701474Saxel.duch@nginx.com
22711474Saxel.duch@nginx.com static nxt_int_t
nxt_conf_vldt_match_encoded_patterns_set_member(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)22721474Saxel.duch@nginx.com nxt_conf_vldt_match_encoded_patterns_set_member(nxt_conf_validation_t *vldt,
22731474Saxel.duch@nginx.com nxt_str_t *name, nxt_conf_value_t *value)
22741474Saxel.duch@nginx.com {
22751474Saxel.duch@nginx.com u_char *p, *end;
22761474Saxel.duch@nginx.com
22771474Saxel.duch@nginx.com if (nxt_slow_path(name->length == 0)) {
22781474Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern objects must "
22791474Saxel.duch@nginx.com "not contain empty member names.");
22801474Saxel.duch@nginx.com }
22811474Saxel.duch@nginx.com
22821474Saxel.duch@nginx.com p = nxt_mp_nget(vldt->pool, name->length);
22831474Saxel.duch@nginx.com if (nxt_slow_path(p == NULL)) {
22841474Saxel.duch@nginx.com return NXT_ERROR;
22851474Saxel.duch@nginx.com }
22861474Saxel.duch@nginx.com
22871474Saxel.duch@nginx.com end = nxt_decode_uri(p, name->start, name->length);
22881474Saxel.duch@nginx.com if (nxt_slow_path(end == NULL)) {
22891474Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern for "
22901474Saxel.duch@nginx.com "\"arguments\" is encoded but is invalid.");
22911474Saxel.duch@nginx.com }
22921474Saxel.duch@nginx.com
22931988Sz.hong@f5.com return nxt_conf_vldt_match_encoded_patterns(vldt, value,
22941988Sz.hong@f5.com (void *) "arguments");
22951474Saxel.duch@nginx.com }
22961474Saxel.duch@nginx.com
22971474Saxel.duch@nginx.com
22981474Saxel.duch@nginx.com static nxt_int_t
nxt_conf_vldt_match_encoded_patterns(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)22991474Saxel.duch@nginx.com nxt_conf_vldt_match_encoded_patterns(nxt_conf_validation_t *vldt,
23001474Saxel.duch@nginx.com nxt_conf_value_t *value, void *data)
23011474Saxel.duch@nginx.com {
23021988Sz.hong@f5.com nxt_int_t ret;
23031988Sz.hong@f5.com
23041988Sz.hong@f5.com vldt->ctx = data;
23051988Sz.hong@f5.com
23061474Saxel.duch@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
23071988Sz.hong@f5.com ret = nxt_conf_vldt_array_iterator(vldt, value,
23081474Saxel.duch@nginx.com &nxt_conf_vldt_match_encoded_pattern);
23091988Sz.hong@f5.com
23101988Sz.hong@f5.com } else {
23111988Sz.hong@f5.com /* NXT_CONF_STRING */
23121988Sz.hong@f5.com ret = nxt_conf_vldt_match_encoded_pattern(vldt, value);
23131474Saxel.duch@nginx.com }
23141474Saxel.duch@nginx.com
23151988Sz.hong@f5.com vldt->ctx = NULL;
23161988Sz.hong@f5.com
23171988Sz.hong@f5.com return ret;
23181474Saxel.duch@nginx.com }
23191474Saxel.duch@nginx.com
23201474Saxel.duch@nginx.com
23211474Saxel.duch@nginx.com static nxt_int_t
nxt_conf_vldt_match_encoded_pattern(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)23221474Saxel.duch@nginx.com nxt_conf_vldt_match_encoded_pattern(nxt_conf_validation_t *vldt,
23231474Saxel.duch@nginx.com nxt_conf_value_t *value)
23241474Saxel.duch@nginx.com {
23251474Saxel.duch@nginx.com u_char *p, *end;
23261474Saxel.duch@nginx.com nxt_int_t ret;
23271474Saxel.duch@nginx.com nxt_str_t pattern;
23281474Saxel.duch@nginx.com
23291474Saxel.duch@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
23301988Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern for \"%s\" "
23311988Sz.hong@f5.com "must be a string.", vldt->ctx);
23321474Saxel.duch@nginx.com }
23331474Saxel.duch@nginx.com
23341474Saxel.duch@nginx.com ret = nxt_conf_vldt_match_pattern(vldt, value);
23351474Saxel.duch@nginx.com if (nxt_slow_path(ret != NXT_OK)) {
23361474Saxel.duch@nginx.com return ret;
23371474Saxel.duch@nginx.com }
23381474Saxel.duch@nginx.com
23391474Saxel.duch@nginx.com nxt_conf_get_string(value, &pattern);
23401474Saxel.duch@nginx.com
23411474Saxel.duch@nginx.com p = nxt_mp_nget(vldt->pool, pattern.length);
23421474Saxel.duch@nginx.com if (nxt_slow_path(p == NULL)) {
23431474Saxel.duch@nginx.com return NXT_ERROR;
23441474Saxel.duch@nginx.com }
23451474Saxel.duch@nginx.com
23461474Saxel.duch@nginx.com end = nxt_decode_uri(p, pattern.start, pattern.length);
23471474Saxel.duch@nginx.com if (nxt_slow_path(end == NULL)) {
23481988Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern for \"%s\" "
23491988Sz.hong@f5.com "is encoded but is invalid.", vldt->ctx);
23501474Saxel.duch@nginx.com }
23511474Saxel.duch@nginx.com
23521474Saxel.duch@nginx.com return NXT_OK;
23531474Saxel.duch@nginx.com }
23541474Saxel.duch@nginx.com
23551474Saxel.duch@nginx.com
23561059Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_match_addrs(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)23571324Saxel.duch@nginx.com nxt_conf_vldt_match_addrs(nxt_conf_validation_t *vldt,
23581324Saxel.duch@nginx.com nxt_conf_value_t *value, void *data)
23591324Saxel.duch@nginx.com {
23601324Saxel.duch@nginx.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
23611324Saxel.duch@nginx.com return nxt_conf_vldt_array_iterator(vldt, value,
23621324Saxel.duch@nginx.com &nxt_conf_vldt_match_addr);
23631324Saxel.duch@nginx.com }
23641324Saxel.duch@nginx.com
23651324Saxel.duch@nginx.com return nxt_conf_vldt_match_addr(vldt, value);
23661324Saxel.duch@nginx.com }
23671324Saxel.duch@nginx.com
23681324Saxel.duch@nginx.com
23691324Saxel.duch@nginx.com static nxt_int_t
nxt_conf_vldt_match_addr(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)23701324Saxel.duch@nginx.com nxt_conf_vldt_match_addr(nxt_conf_validation_t *vldt,
23711324Saxel.duch@nginx.com nxt_conf_value_t *value)
23721324Saxel.duch@nginx.com {
23731324Saxel.duch@nginx.com nxt_http_route_addr_pattern_t pattern;
23741324Saxel.duch@nginx.com
23751324Saxel.duch@nginx.com switch (nxt_http_route_addr_pattern_parse(vldt->pool, &pattern, value)) {
23761324Saxel.duch@nginx.com
23771324Saxel.duch@nginx.com case NXT_OK:
23781324Saxel.duch@nginx.com return NXT_OK;
23791324Saxel.duch@nginx.com
23801324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_PORT_ERROR:
23811324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" port an invalid "
23821324Saxel.duch@nginx.com "port.");
23831324Saxel.duch@nginx.com
23841324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_CV_TYPE_ERROR:
23851324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"match\" pattern for "
23861324Saxel.duch@nginx.com "\"address\" must be a string.");
23871324Saxel.duch@nginx.com
23881324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_LENGTH_ERROR:
23891324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" is too short.");
23901324Saxel.duch@nginx.com
23911324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_FORMAT_ERROR:
23921324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" format is invalid.");
23931324Saxel.duch@nginx.com
23941324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_RANGE_OVERLAP_ERROR:
23951324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" range is "
23961324Saxel.duch@nginx.com "overlapping.");
23971324Saxel.duch@nginx.com
23981324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_CIDR_ERROR:
23991324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" has an invalid CIDR "
24001324Saxel.duch@nginx.com "prefix.");
24011324Saxel.duch@nginx.com
24021324Saxel.duch@nginx.com case NXT_ADDR_PATTERN_NO_IPv6_ERROR:
24031324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" does not support "
24041324Saxel.duch@nginx.com "IPv6 with your configuration.");
24051324Saxel.duch@nginx.com
24062161Salx.manpages@gmail.com case NXT_ADDR_PATTERN_NO_UNIX_ERROR:
24072161Salx.manpages@gmail.com return nxt_conf_vldt_error(vldt, "The \"address\" does not support "
24082161Salx.manpages@gmail.com "UNIX domain sockets with your "
24092161Salx.manpages@gmail.com "configuration.");
24102161Salx.manpages@gmail.com
24111324Saxel.duch@nginx.com default:
24121324Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"address\" has an unknown "
24131324Saxel.duch@nginx.com "format.");
24141324Saxel.duch@nginx.com }
24151324Saxel.duch@nginx.com }
24161324Saxel.duch@nginx.com
24171324Saxel.duch@nginx.com
24181324Saxel.duch@nginx.com static nxt_int_t
nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)24191110Saxel.duch@nginx.com nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t *vldt,
24201110Saxel.duch@nginx.com nxt_conf_value_t *value, void *data)
24211110Saxel.duch@nginx.com {
24221110Saxel.duch@nginx.com nxt_str_t scheme;
24231110Saxel.duch@nginx.com
24241110Saxel.duch@nginx.com static const nxt_str_t http = nxt_string("http");
24251110Saxel.duch@nginx.com static const nxt_str_t https = nxt_string("https");
24261110Saxel.duch@nginx.com
24271110Saxel.duch@nginx.com nxt_conf_get_string(value, &scheme);
24281110Saxel.duch@nginx.com
24291110Saxel.duch@nginx.com if (nxt_strcasestr_eq(&scheme, &http)
24301110Saxel.duch@nginx.com || nxt_strcasestr_eq(&scheme, &https))
24311110Saxel.duch@nginx.com {
24321110Saxel.duch@nginx.com return NXT_OK;
24331110Saxel.duch@nginx.com }
24341110Saxel.duch@nginx.com
24351110Saxel.duch@nginx.com return nxt_conf_vldt_error(vldt, "The \"scheme\" can either be "
24361110Saxel.duch@nginx.com "\"http\" or \"https\".");
24371110Saxel.duch@nginx.com }
24381110Saxel.duch@nginx.com
24391110Saxel.duch@nginx.com
24401110Saxel.duch@nginx.com static nxt_int_t
nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)24411059Sigor@sysoev.ru nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t *vldt,
24421059Sigor@sysoev.ru nxt_conf_value_t *value, void *data)
24431059Sigor@sysoev.ru {
24441988Sz.hong@f5.com nxt_int_t ret;
24451988Sz.hong@f5.com
24461988Sz.hong@f5.com vldt->ctx = data;
24471988Sz.hong@f5.com
24481059Sigor@sysoev.ru if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
24491988Sz.hong@f5.com ret = nxt_conf_vldt_array_iterator(vldt, value,
24501988Sz.hong@f5.com &nxt_conf_vldt_match_patterns_set);
24511988Sz.hong@f5.com
24521988Sz.hong@f5.com } else {
24531988Sz.hong@f5.com /* NXT_CONF_OBJECT */
24541988Sz.hong@f5.com ret = nxt_conf_vldt_match_patterns_set(vldt, value);
24551059Sigor@sysoev.ru }
24561059Sigor@sysoev.ru
24571988Sz.hong@f5.com vldt->ctx = NULL;
24581988Sz.hong@f5.com
24591988Sz.hong@f5.com return ret;
24601059Sigor@sysoev.ru }
24611059Sigor@sysoev.ru
24621059Sigor@sysoev.ru
24631059Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)24641059Sigor@sysoev.ru nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t *vldt,
24651059Sigor@sysoev.ru nxt_conf_value_t *value)
24661059Sigor@sysoev.ru {
24671059Sigor@sysoev.ru if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
24681059Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"match\" patterns for "
24691988Sz.hong@f5.com "\"%s\" must be objects.", vldt->ctx);
24701059Sigor@sysoev.ru }
24711059Sigor@sysoev.ru
24721059Sigor@sysoev.ru return nxt_conf_vldt_object_iterator(vldt, value,
24731059Sigor@sysoev.ru &nxt_conf_vldt_match_patterns_set_member);
24741059Sigor@sysoev.ru }
24751059Sigor@sysoev.ru
24761059Sigor@sysoev.ru
24771059Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_match_patterns_set_member(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)24781059Sigor@sysoev.ru nxt_conf_vldt_match_patterns_set_member(nxt_conf_validation_t *vldt,
24791059Sigor@sysoev.ru nxt_str_t *name, nxt_conf_value_t *value)
24801059Sigor@sysoev.ru {
24811059Sigor@sysoev.ru if (name->length == 0) {
24821059Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"match\" pattern objects must "
24831059Sigor@sysoev.ru "not contain empty member names.");
24841059Sigor@sysoev.ru }
24851059Sigor@sysoev.ru
24861988Sz.hong@f5.com return nxt_conf_vldt_match_patterns(vldt, value, vldt->ctx);
24871059Sigor@sysoev.ru }
24881059Sigor@sysoev.ru
24891059Sigor@sysoev.ru
2490774Svbart@nginx.com #if (NXT_TLS)
2491774Svbart@nginx.com
2492774Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_certificate(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2493774Svbart@nginx.com nxt_conf_vldt_certificate(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
2494774Svbart@nginx.com void *data)
2495774Svbart@nginx.com {
24961828Sa.suvorov@f5.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
24971828Sa.suvorov@f5.com if (nxt_conf_array_elements_count(value) == 0) {
24981828Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "The \"certificate\" array "
24991828Sa.suvorov@f5.com "must contain at least one element.");
25001828Sa.suvorov@f5.com }
25011828Sa.suvorov@f5.com
25021828Sa.suvorov@f5.com return nxt_conf_vldt_array_iterator(vldt, value,
25031828Sa.suvorov@f5.com &nxt_conf_vldt_certificate_element);
25041828Sa.suvorov@f5.com }
25051828Sa.suvorov@f5.com
25061828Sa.suvorov@f5.com /* NXT_CONF_STRING */
25071828Sa.suvorov@f5.com
25081828Sa.suvorov@f5.com return nxt_conf_vldt_certificate_element(vldt, value);
25091828Sa.suvorov@f5.com }
25101828Sa.suvorov@f5.com
25111828Sa.suvorov@f5.com
25121828Sa.suvorov@f5.com static nxt_int_t
nxt_conf_vldt_certificate_element(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)25131828Sa.suvorov@f5.com nxt_conf_vldt_certificate_element(nxt_conf_validation_t *vldt,
25141828Sa.suvorov@f5.com nxt_conf_value_t *value)
25151828Sa.suvorov@f5.com {
2516774Svbart@nginx.com nxt_str_t name;
2517774Svbart@nginx.com nxt_conf_value_t *cert;
2518774Svbart@nginx.com
25191828Sa.suvorov@f5.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
25201828Sa.suvorov@f5.com return nxt_conf_vldt_error(vldt, "The \"certificate\" array must "
25211828Sa.suvorov@f5.com "contain only string values.");
25221828Sa.suvorov@f5.com }
25231828Sa.suvorov@f5.com
2524774Svbart@nginx.com nxt_conf_get_string(value, &name);
2525774Svbart@nginx.com
2526774Svbart@nginx.com cert = nxt_cert_info_get(&name);
2527774Svbart@nginx.com
2528774Svbart@nginx.com if (cert == NULL) {
2529774Svbart@nginx.com return nxt_conf_vldt_error(vldt, "Certificate \"%V\" is not found.",
2530774Svbart@nginx.com &name);
2531774Svbart@nginx.com }
2532774Svbart@nginx.com
2533774Svbart@nginx.com return NXT_OK;
2534774Svbart@nginx.com }
2535774Svbart@nginx.com
25361885Sa.suvorov@f5.com
25371885Sa.suvorov@f5.com #if (NXT_HAVE_OPENSSL_CONF_CMD)
25381885Sa.suvorov@f5.com
25391885Sa.suvorov@f5.com static nxt_int_t
nxt_conf_vldt_object_conf_commands(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)25401885Sa.suvorov@f5.com nxt_conf_vldt_object_conf_commands(nxt_conf_validation_t *vldt,
25411885Sa.suvorov@f5.com nxt_conf_value_t *value, void *data)
25421885Sa.suvorov@f5.com {
25431885Sa.suvorov@f5.com uint32_t index;
25441885Sa.suvorov@f5.com nxt_int_t ret;
25451885Sa.suvorov@f5.com nxt_str_t name;
25461885Sa.suvorov@f5.com nxt_conf_value_t *member;
25471885Sa.suvorov@f5.com
25481885Sa.suvorov@f5.com index = 0;
25491885Sa.suvorov@f5.com
25501885Sa.suvorov@f5.com for ( ;; ) {
25511885Sa.suvorov@f5.com member = nxt_conf_next_object_member(value, &name, &index);
25521885Sa.suvorov@f5.com
25531885Sa.suvorov@f5.com if (member == NULL) {
25541885Sa.suvorov@f5.com break;
25551885Sa.suvorov@f5.com }
25561885Sa.suvorov@f5.com
25571885Sa.suvorov@f5.com ret = nxt_conf_vldt_type(vldt, &name, member, NXT_CONF_VLDT_STRING);
25581885Sa.suvorov@f5.com if (ret != NXT_OK) {
25591885Sa.suvorov@f5.com return ret;
25601885Sa.suvorov@f5.com }
25611885Sa.suvorov@f5.com }
25621885Sa.suvorov@f5.com
25631885Sa.suvorov@f5.com return NXT_OK;
25641885Sa.suvorov@f5.com }
25651885Sa.suvorov@f5.com
25661885Sa.suvorov@f5.com #endif
25671885Sa.suvorov@f5.com
2568774Svbart@nginx.com #endif
2569774Svbart@nginx.com
2570774Svbart@nginx.com
2571357Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_response_header(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)25722512Sz.hong@f5.com nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt, nxt_str_t *name,
25732512Sz.hong@f5.com nxt_conf_value_t *value)
25742512Sz.hong@f5.com {
25752512Sz.hong@f5.com nxt_uint_t type;
25762512Sz.hong@f5.com
25772512Sz.hong@f5.com static nxt_str_t content_length = nxt_string("Content-Length");
25782512Sz.hong@f5.com
25792512Sz.hong@f5.com if (name->length == 0) {
25802512Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The response header name "
25812512Sz.hong@f5.com "must not be empty.");
25822512Sz.hong@f5.com }
25832512Sz.hong@f5.com
25842512Sz.hong@f5.com if (nxt_strstr_eq(name, &content_length)) {
25852512Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"Content-Length\" response "
25862512Sz.hong@f5.com "header value is not supported");
25872512Sz.hong@f5.com }
25882512Sz.hong@f5.com
25892512Sz.hong@f5.com type = nxt_conf_type(value);
25902512Sz.hong@f5.com
25912512Sz.hong@f5.com if (type == NXT_CONF_STRING || type == NXT_CONF_NULL) {
25922512Sz.hong@f5.com return NXT_OK;
25932512Sz.hong@f5.com }
25942512Sz.hong@f5.com
25952512Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"%V\" response header value "
25962512Sz.hong@f5.com "must either be a string or a null", name);
25972512Sz.hong@f5.com }
25982512Sz.hong@f5.com
25992512Sz.hong@f5.com
26002512Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_app_name(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2601357Svbart@nginx.com nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
2602137Svbart@nginx.com void *data)
2603116Svbart@nginx.com {
2604137Svbart@nginx.com nxt_str_t name;
2605137Svbart@nginx.com nxt_conf_value_t *apps, *app;
2606137Svbart@nginx.com
2607137Svbart@nginx.com static nxt_str_t apps_str = nxt_string("applications");
2608137Svbart@nginx.com
2609357Svbart@nginx.com nxt_conf_get_string(value, &name);
2610357Svbart@nginx.com
2611357Svbart@nginx.com apps = nxt_conf_get_object_member(vldt->conf, &apps_str, NULL);
2612137Svbart@nginx.com
2613137Svbart@nginx.com if (nxt_slow_path(apps == NULL)) {
2614357Svbart@nginx.com goto error;
2615137Svbart@nginx.com }
2616137Svbart@nginx.com
2617137Svbart@nginx.com app = nxt_conf_get_object_member(apps, &name, NULL);
2618137Svbart@nginx.com
2619137Svbart@nginx.com if (nxt_slow_path(app == NULL)) {
2620357Svbart@nginx.com goto error;
2621137Svbart@nginx.com }
2622137Svbart@nginx.com
2623137Svbart@nginx.com return NXT_OK;
2624357Svbart@nginx.com
2625357Svbart@nginx.com error:
2626357Svbart@nginx.com
2627357Svbart@nginx.com return nxt_conf_vldt_error(vldt, "Listening socket is assigned for "
2628357Svbart@nginx.com "a non existing application \"%V\".",
2629357Svbart@nginx.com &name);
2630116Svbart@nginx.com }
2631116Svbart@nginx.com
2632116Svbart@nginx.com
2633116Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_forwarded(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)26342133Sz.hong@f5.com nxt_conf_vldt_forwarded(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
26352133Sz.hong@f5.com void *data)
26362133Sz.hong@f5.com {
26372133Sz.hong@f5.com nxt_conf_value_t *client_ip, *protocol;
26382133Sz.hong@f5.com
26392133Sz.hong@f5.com static nxt_str_t client_ip_str = nxt_string("client_ip");
26402133Sz.hong@f5.com static nxt_str_t protocol_str = nxt_string("protocol");
26412133Sz.hong@f5.com
26422133Sz.hong@f5.com client_ip = nxt_conf_get_object_member(value, &client_ip_str, NULL);
26432133Sz.hong@f5.com protocol = nxt_conf_get_object_member(value, &protocol_str, NULL);
26442133Sz.hong@f5.com
26452133Sz.hong@f5.com if (client_ip == NULL && protocol == NULL) {
26462133Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"forwarded\" object must have "
26472133Sz.hong@f5.com "either \"client_ip\" or \"protocol\" "
26482133Sz.hong@f5.com "option set.");
26492133Sz.hong@f5.com }
26502133Sz.hong@f5.com
26512133Sz.hong@f5.com return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_forwarded_members);
26522133Sz.hong@f5.com }
26532133Sz.hong@f5.com
26542133Sz.hong@f5.com
26552133Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_app(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)2656357Svbart@nginx.com nxt_conf_vldt_app(nxt_conf_validation_t *vldt, nxt_str_t *name,
2657137Svbart@nginx.com nxt_conf_value_t *value)
2658116Svbart@nginx.com {
2659357Svbart@nginx.com nxt_int_t ret;
2660216Sigor@sysoev.ru nxt_str_t type;
2661216Sigor@sysoev.ru nxt_thread_t *thread;
2662216Sigor@sysoev.ru nxt_conf_value_t *type_value;
2663216Sigor@sysoev.ru nxt_app_lang_module_t *lang;
2664116Svbart@nginx.com
2665132Svbart@nginx.com static nxt_str_t type_str = nxt_string("type");
2666132Svbart@nginx.com
26671473Svbart@nginx.com static struct {
26681473Svbart@nginx.com nxt_conf_vldt_handler_t validator;
26691473Svbart@nginx.com nxt_conf_vldt_object_t *members;
26701473Svbart@nginx.com
26711473Svbart@nginx.com } types[] = {
26721473Svbart@nginx.com { nxt_conf_vldt_object, nxt_conf_vldt_external_members },
26731872So.canty@f5.com { nxt_conf_vldt_python, NULL },
26741473Svbart@nginx.com { nxt_conf_vldt_php, NULL },
26751473Svbart@nginx.com { nxt_conf_vldt_object, nxt_conf_vldt_perl_members },
26761473Svbart@nginx.com { nxt_conf_vldt_object, nxt_conf_vldt_ruby_members },
26771473Svbart@nginx.com { nxt_conf_vldt_object, nxt_conf_vldt_java_members },
26782518Sa.clayton@nginx.com { nxt_conf_vldt_object, nxt_conf_vldt_wasm_members },
2679*2686Sa.clayton@nginx.com { nxt_conf_vldt_object, nxt_conf_vldt_wasm_wc_members },
2680216Sigor@sysoev.ru };
2681216Sigor@sysoev.ru
2682487Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, name, value, NXT_CONF_VLDT_OBJECT);
2683357Svbart@nginx.com
2684357Svbart@nginx.com if (ret != NXT_OK) {
2685357Svbart@nginx.com return ret;
2686357Svbart@nginx.com }
2687357Svbart@nginx.com
2688132Svbart@nginx.com type_value = nxt_conf_get_object_member(value, &type_str, NULL);
2689132Svbart@nginx.com
2690357Svbart@nginx.com if (type_value == NULL) {
2691357Svbart@nginx.com return nxt_conf_vldt_error(vldt,
2692357Svbart@nginx.com "Application must have the \"type\" property set.");
2693132Svbart@nginx.com }
2694116Svbart@nginx.com
2695487Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, &type_str, type_value, NXT_CONF_VLDT_STRING);
2696357Svbart@nginx.com
2697357Svbart@nginx.com if (ret != NXT_OK) {
2698357Svbart@nginx.com return ret;
2699132Svbart@nginx.com }
2700132Svbart@nginx.com
2701132Svbart@nginx.com nxt_conf_get_string(type_value, &type);
2702132Svbart@nginx.com
2703216Sigor@sysoev.ru thread = nxt_thread();
2704216Sigor@sysoev.ru
2705216Sigor@sysoev.ru lang = nxt_app_lang_module(thread->runtime, &type);
2706216Sigor@sysoev.ru if (lang == NULL) {
2707357Svbart@nginx.com return nxt_conf_vldt_error(vldt,
2708357Svbart@nginx.com "The module to run \"%V\" is not found "
2709357Svbart@nginx.com "among the available application modules.",
2710357Svbart@nginx.com &type);
2711132Svbart@nginx.com }
2712132Svbart@nginx.com
27131473Svbart@nginx.com return types[lang->type].validator(vldt, value, types[lang->type].members);
2714116Svbart@nginx.com }
2715116Svbart@nginx.com
2716116Svbart@nginx.com
2717116Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_object(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2718357Svbart@nginx.com nxt_conf_vldt_object(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
2719137Svbart@nginx.com void *data)
2720116Svbart@nginx.com {
2721116Svbart@nginx.com uint32_t index;
2722357Svbart@nginx.com nxt_int_t ret;
27231959Sz.hong@f5.com nxt_str_t name, var;
2724116Svbart@nginx.com nxt_conf_value_t *member;
2725357Svbart@nginx.com nxt_conf_vldt_object_t *vals;
2726116Svbart@nginx.com
27271525Svbart@nginx.com vals = data;
27281525Svbart@nginx.com
27291525Svbart@nginx.com for ( ;; ) {
27301525Svbart@nginx.com if (vals->name.length == 0) {
27311525Svbart@nginx.com
27321651Sigor@sysoev.ru if (vals->u.members != NULL) {
27331651Sigor@sysoev.ru vals = vals->u.members;
27341525Svbart@nginx.com continue;
27351525Svbart@nginx.com }
27361525Svbart@nginx.com
27371525Svbart@nginx.com break;
27381525Svbart@nginx.com }
27391525Svbart@nginx.com
27401525Svbart@nginx.com if (vals->flags & NXT_CONF_VLDT_REQUIRED) {
27411525Svbart@nginx.com member = nxt_conf_get_object_member(value, &vals->name, NULL);
27421525Svbart@nginx.com
27431525Svbart@nginx.com if (member == NULL) {
27441525Svbart@nginx.com return nxt_conf_vldt_error(vldt, "Required parameter \"%V\" "
27451525Svbart@nginx.com "is missing.", &vals->name);
27461525Svbart@nginx.com }
27471525Svbart@nginx.com }
27481525Svbart@nginx.com
27491525Svbart@nginx.com vals++;
27501525Svbart@nginx.com }
27511525Svbart@nginx.com
2752116Svbart@nginx.com index = 0;
2753116Svbart@nginx.com
2754116Svbart@nginx.com for ( ;; ) {
2755116Svbart@nginx.com member = nxt_conf_next_object_member(value, &name, &index);
2756116Svbart@nginx.com
2757116Svbart@nginx.com if (member == NULL) {
2758116Svbart@nginx.com return NXT_OK;
2759116Svbart@nginx.com }
2760116Svbart@nginx.com
2761357Svbart@nginx.com vals = data;
2762116Svbart@nginx.com
2763116Svbart@nginx.com for ( ;; ) {
2764357Svbart@nginx.com if (vals->name.length == 0) {
2765486Smax.romanov@nginx.com
27661651Sigor@sysoev.ru if (vals->u.members != NULL) {
27671651Sigor@sysoev.ru vals = vals->u.members;
2768486Smax.romanov@nginx.com continue;
2769486Smax.romanov@nginx.com }
2770486Smax.romanov@nginx.com
2771357Svbart@nginx.com return nxt_conf_vldt_error(vldt, "Unknown parameter \"%V\".",
2772357Svbart@nginx.com &name);
2773116Svbart@nginx.com }
2774116Svbart@nginx.com
2775357Svbart@nginx.com if (!nxt_strstr_eq(&vals->name, &name)) {
2776357Svbart@nginx.com vals++;
2777116Svbart@nginx.com continue;
2778116Svbart@nginx.com }
2779116Svbart@nginx.com
27802247Sz.hong@f5.com if (vals->flags & NXT_CONF_VLDT_TSTR
27811959Sz.hong@f5.com && nxt_conf_type(member) == NXT_CONF_STRING)
27821959Sz.hong@f5.com {
27831959Sz.hong@f5.com nxt_conf_get_string(member, &var);
27841959Sz.hong@f5.com
27852247Sz.hong@f5.com if (nxt_is_tstr(&var)) {
27861959Sz.hong@f5.com ret = nxt_conf_vldt_var(vldt, &name, &var);
27871959Sz.hong@f5.com if (ret != NXT_OK) {
27881959Sz.hong@f5.com return ret;
27891959Sz.hong@f5.com }
27901959Sz.hong@f5.com
27911959Sz.hong@f5.com break;
27921959Sz.hong@f5.com }
27932078Salx.manpages@gmail.com }
27941959Sz.hong@f5.com
2795357Svbart@nginx.com ret = nxt_conf_vldt_type(vldt, &name, member, vals->type);
2796357Svbart@nginx.com if (ret != NXT_OK) {
2797357Svbart@nginx.com return ret;
2798116Svbart@nginx.com }
2799116Svbart@nginx.com
2800357Svbart@nginx.com if (vals->validator != NULL) {
28011651Sigor@sysoev.ru ret = vals->validator(vldt, member, vals->u.members);
2802357Svbart@nginx.com
2803357Svbart@nginx.com if (ret != NXT_OK) {
2804357Svbart@nginx.com return ret;
2805357Svbart@nginx.com }
2806116Svbart@nginx.com }
2807116Svbart@nginx.com
2808116Svbart@nginx.com break;
2809116Svbart@nginx.com }
2810116Svbart@nginx.com }
2811116Svbart@nginx.com }
2812116Svbart@nginx.com
2813116Svbart@nginx.com
2814507Smax.romanov@nginx.com typedef struct {
2815507Smax.romanov@nginx.com int64_t spare;
2816507Smax.romanov@nginx.com int64_t max;
2817507Smax.romanov@nginx.com int64_t idle_timeout;
2818507Smax.romanov@nginx.com } nxt_conf_vldt_processes_conf_t;
2819507Smax.romanov@nginx.com
2820507Smax.romanov@nginx.com
2821507Smax.romanov@nginx.com static nxt_conf_map_t nxt_conf_vldt_processes_conf_map[] = {
2822507Smax.romanov@nginx.com {
2823507Smax.romanov@nginx.com nxt_string("spare"),
2824507Smax.romanov@nginx.com NXT_CONF_MAP_INT64,
2825507Smax.romanov@nginx.com offsetof(nxt_conf_vldt_processes_conf_t, spare),
2826507Smax.romanov@nginx.com },
2827507Smax.romanov@nginx.com
2828507Smax.romanov@nginx.com {
2829507Smax.romanov@nginx.com nxt_string("max"),
2830507Smax.romanov@nginx.com NXT_CONF_MAP_INT64,
2831507Smax.romanov@nginx.com offsetof(nxt_conf_vldt_processes_conf_t, max),
2832507Smax.romanov@nginx.com },
2833507Smax.romanov@nginx.com
2834507Smax.romanov@nginx.com {
2835507Smax.romanov@nginx.com nxt_string("idle_timeout"),
2836507Smax.romanov@nginx.com NXT_CONF_MAP_INT64,
2837507Smax.romanov@nginx.com offsetof(nxt_conf_vldt_processes_conf_t, idle_timeout),
2838507Smax.romanov@nginx.com },
2839507Smax.romanov@nginx.com };
2840507Smax.romanov@nginx.com
2841507Smax.romanov@nginx.com
2842507Smax.romanov@nginx.com static nxt_int_t
nxt_conf_vldt_processes(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2843507Smax.romanov@nginx.com nxt_conf_vldt_processes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
2844507Smax.romanov@nginx.com void *data)
2845507Smax.romanov@nginx.com {
2846507Smax.romanov@nginx.com int64_t int_value;
2847507Smax.romanov@nginx.com nxt_int_t ret;
2848507Smax.romanov@nginx.com nxt_conf_vldt_processes_conf_t proc;
2849507Smax.romanov@nginx.com
28502635Salx@kernel.org if (nxt_conf_type(value) == NXT_CONF_INTEGER) {
28511439Svbart@nginx.com int_value = nxt_conf_get_number(value);
2852507Smax.romanov@nginx.com
2853507Smax.romanov@nginx.com if (int_value < 1) {
2854507Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"processes\" number must be "
2855507Smax.romanov@nginx.com "equal to or greater than 1.");
2856507Smax.romanov@nginx.com }
2857507Smax.romanov@nginx.com
2858507Smax.romanov@nginx.com if (int_value > NXT_INT32_T_MAX) {
2859507Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"processes\" number must "
2860507Smax.romanov@nginx.com "not exceed %d.", NXT_INT32_T_MAX);
2861507Smax.romanov@nginx.com }
2862507Smax.romanov@nginx.com
2863507Smax.romanov@nginx.com return NXT_OK;
2864507Smax.romanov@nginx.com }
2865507Smax.romanov@nginx.com
2866507Smax.romanov@nginx.com ret = nxt_conf_vldt_object(vldt, value, data);
2867507Smax.romanov@nginx.com if (ret != NXT_OK) {
2868507Smax.romanov@nginx.com return ret;
2869507Smax.romanov@nginx.com }
2870507Smax.romanov@nginx.com
2871537Svbart@nginx.com proc.spare = 0;
2872507Smax.romanov@nginx.com proc.max = 1;
2873507Smax.romanov@nginx.com proc.idle_timeout = 15;
2874507Smax.romanov@nginx.com
2875507Smax.romanov@nginx.com ret = nxt_conf_map_object(vldt->pool, value,
2876507Smax.romanov@nginx.com nxt_conf_vldt_processes_conf_map,
2877507Smax.romanov@nginx.com nxt_nitems(nxt_conf_vldt_processes_conf_map),
2878507Smax.romanov@nginx.com &proc);
2879507Smax.romanov@nginx.com if (ret != NXT_OK) {
2880507Smax.romanov@nginx.com return ret;
2881507Smax.romanov@nginx.com }
2882507Smax.romanov@nginx.com
2883507Smax.romanov@nginx.com if (proc.spare < 0) {
2884507Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"spare\" number must not be "
2885507Smax.romanov@nginx.com "negative.");
2886507Smax.romanov@nginx.com }
2887507Smax.romanov@nginx.com
2888507Smax.romanov@nginx.com if (proc.spare > NXT_INT32_T_MAX) {
2889507Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"spare\" number must not "
2890521Szelenkov@nginx.com "exceed %d.", NXT_INT32_T_MAX);
2891507Smax.romanov@nginx.com }
2892507Smax.romanov@nginx.com
2893518Szelenkov@nginx.com if (proc.max < 1) {
2894518Szelenkov@nginx.com return nxt_conf_vldt_error(vldt, "The \"max\" number must be equal "
2895518Szelenkov@nginx.com "to or greater than 1.");
2896518Szelenkov@nginx.com }
2897507Smax.romanov@nginx.com
2898518Szelenkov@nginx.com if (proc.max > NXT_INT32_T_MAX) {
2899518Szelenkov@nginx.com return nxt_conf_vldt_error(vldt, "The \"max\" number must not "
2900521Szelenkov@nginx.com "exceed %d.", NXT_INT32_T_MAX);
2901518Szelenkov@nginx.com }
2902507Smax.romanov@nginx.com
2903518Szelenkov@nginx.com if (proc.max < proc.spare) {
2904518Szelenkov@nginx.com return nxt_conf_vldt_error(vldt, "The \"spare\" number must be "
2905711Svbart@nginx.com "less than or equal to \"max\".");
2906507Smax.romanov@nginx.com }
2907507Smax.romanov@nginx.com
2908507Smax.romanov@nginx.com if (proc.idle_timeout < 0) {
2909507Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"idle_timeout\" number must not "
2910507Smax.romanov@nginx.com "be negative.");
2911507Smax.romanov@nginx.com }
2912507Smax.romanov@nginx.com
2913507Smax.romanov@nginx.com if (proc.idle_timeout > NXT_INT32_T_MAX / 1000) {
2914507Smax.romanov@nginx.com return nxt_conf_vldt_error(vldt, "The \"idle_timeout\" number must not "
2915521Szelenkov@nginx.com "exceed %d.", NXT_INT32_T_MAX / 1000);
2916507Smax.romanov@nginx.com }
2917507Smax.romanov@nginx.com
2918507Smax.romanov@nginx.com return NXT_OK;
2919507Smax.romanov@nginx.com }
2920507Smax.romanov@nginx.com
2921507Smax.romanov@nginx.com
2922116Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_object_iterator(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2923357Svbart@nginx.com nxt_conf_vldt_object_iterator(nxt_conf_validation_t *vldt,
2924357Svbart@nginx.com nxt_conf_value_t *value, void *data)
2925116Svbart@nginx.com {
2926116Svbart@nginx.com uint32_t index;
2927357Svbart@nginx.com nxt_int_t ret;
2928116Svbart@nginx.com nxt_str_t name;
2929116Svbart@nginx.com nxt_conf_value_t *member;
2930116Svbart@nginx.com nxt_conf_vldt_member_t validator;
2931116Svbart@nginx.com
2932180Smax.romanov@nginx.com validator = (nxt_conf_vldt_member_t) data;
2933116Svbart@nginx.com index = 0;
2934116Svbart@nginx.com
2935116Svbart@nginx.com for ( ;; ) {
2936116Svbart@nginx.com member = nxt_conf_next_object_member(value, &name, &index);
2937116Svbart@nginx.com if (member == NULL) {
2938116Svbart@nginx.com return NXT_OK;
2939116Svbart@nginx.com }
2940116Svbart@nginx.com
2941357Svbart@nginx.com ret = validator(vldt, &name, member);
2942357Svbart@nginx.com if (ret != NXT_OK) {
2943357Svbart@nginx.com return ret;
2944116Svbart@nginx.com }
2945116Svbart@nginx.com }
2946116Svbart@nginx.com }
2947276Sigor@sysoev.ru
2948276Sigor@sysoev.ru
2949276Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_array_iterator(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)2950685Svbart@nginx.com nxt_conf_vldt_array_iterator(nxt_conf_validation_t *vldt,
2951685Svbart@nginx.com nxt_conf_value_t *value, void *data)
2952685Svbart@nginx.com {
2953685Svbart@nginx.com uint32_t index;
2954685Svbart@nginx.com nxt_int_t ret;
2955685Svbart@nginx.com nxt_conf_value_t *element;
2956685Svbart@nginx.com nxt_conf_vldt_element_t validator;
2957685Svbart@nginx.com
2958685Svbart@nginx.com validator = (nxt_conf_vldt_element_t) data;
2959685Svbart@nginx.com
2960685Svbart@nginx.com for (index = 0; /* void */ ; index++) {
2961685Svbart@nginx.com element = nxt_conf_get_array_element(value, index);
2962685Svbart@nginx.com
2963685Svbart@nginx.com if (element == NULL) {
2964685Svbart@nginx.com return NXT_OK;
2965685Svbart@nginx.com }
2966685Svbart@nginx.com
2967685Svbart@nginx.com ret = validator(vldt, element);
2968685Svbart@nginx.com
2969685Svbart@nginx.com if (ret != NXT_OK) {
2970685Svbart@nginx.com return ret;
2971685Svbart@nginx.com }
2972685Svbart@nginx.com }
2973685Svbart@nginx.com }
2974685Svbart@nginx.com
2975685Svbart@nginx.com
2976685Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_environment(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)2977678Svbart@nginx.com nxt_conf_vldt_environment(nxt_conf_validation_t *vldt, nxt_str_t *name,
2978678Svbart@nginx.com nxt_conf_value_t *value)
2979678Svbart@nginx.com {
2980678Svbart@nginx.com nxt_str_t str;
2981678Svbart@nginx.com
2982678Svbart@nginx.com if (name->length == 0) {
2983678Svbart@nginx.com return nxt_conf_vldt_error(vldt,
2984678Svbart@nginx.com "The environment name must not be empty.");
2985678Svbart@nginx.com }
2986678Svbart@nginx.com
29872232Salx@nginx.com if (memchr(name->start, '\0', name->length) != NULL) {
2988678Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The environment name must not "
2989678Svbart@nginx.com "contain null character.");
2990678Svbart@nginx.com }
2991678Svbart@nginx.com
29922232Salx@nginx.com if (memchr(name->start, '=', name->length) != NULL) {
2993678Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The environment name must not "
2994678Svbart@nginx.com "contain '=' character.");
2995678Svbart@nginx.com }
2996678Svbart@nginx.com
2997678Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
2998678Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"%V\" environment value must be "
2999678Svbart@nginx.com "a string.", name);
3000678Svbart@nginx.com }
3001678Svbart@nginx.com
3002678Svbart@nginx.com nxt_conf_get_string(value, &str);
3003678Svbart@nginx.com
30042232Salx@nginx.com if (memchr(str.start, '\0', str.length) != NULL) {
3005678Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"%V\" environment value must "
3006678Svbart@nginx.com "not contain null character.", name);
3007678Svbart@nginx.com }
3008678Svbart@nginx.com
3009678Svbart@nginx.com return NXT_OK;
3010678Svbart@nginx.com }
3011685Svbart@nginx.com
3012685Svbart@nginx.com
3013685Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_targets_exclusive(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)30141879So.canty@f5.com nxt_conf_vldt_targets_exclusive(nxt_conf_validation_t *vldt,
30151879So.canty@f5.com nxt_conf_value_t *value, void *data)
30161879So.canty@f5.com {
30171879So.canty@f5.com return nxt_conf_vldt_error(vldt, "The \"%s\" option is mutually exclusive "
30181879So.canty@f5.com "with the \"targets\" object.", data);
30191879So.canty@f5.com }
30201879So.canty@f5.com
30211879So.canty@f5.com
30221879So.canty@f5.com static nxt_int_t
nxt_conf_vldt_targets(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)30231879So.canty@f5.com nxt_conf_vldt_targets(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
30241879So.canty@f5.com void *data)
30251879So.canty@f5.com {
30261879So.canty@f5.com nxt_int_t ret;
30271879So.canty@f5.com nxt_uint_t n;
30281879So.canty@f5.com
30291879So.canty@f5.com n = nxt_conf_object_members_count(value);
30301879So.canty@f5.com
30311879So.canty@f5.com if (n > 254) {
30321879So.canty@f5.com return nxt_conf_vldt_error(vldt, "The \"targets\" object must not "
30331879So.canty@f5.com "contain more than 254 members.");
30341879So.canty@f5.com }
30351879So.canty@f5.com
30361879So.canty@f5.com vldt->ctx = data;
30371879So.canty@f5.com
30381879So.canty@f5.com ret = nxt_conf_vldt_object_iterator(vldt, value, &nxt_conf_vldt_target);
30391879So.canty@f5.com
30401879So.canty@f5.com vldt->ctx = NULL;
30411879So.canty@f5.com
30421879So.canty@f5.com return ret;
30431879So.canty@f5.com }
30441879So.canty@f5.com
30451879So.canty@f5.com
30461879So.canty@f5.com static nxt_int_t
nxt_conf_vldt_target(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)30471879So.canty@f5.com nxt_conf_vldt_target(nxt_conf_validation_t *vldt, nxt_str_t *name,
30481879So.canty@f5.com nxt_conf_value_t *value)
30491879So.canty@f5.com {
30501879So.canty@f5.com if (name->length == 0) {
30511879So.canty@f5.com return nxt_conf_vldt_error(vldt,
30521879So.canty@f5.com "The target name must not be empty.");
30531879So.canty@f5.com }
30541879So.canty@f5.com
30551879So.canty@f5.com if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
30561879So.canty@f5.com return nxt_conf_vldt_error(vldt, "The \"%V\" target must be "
30571879So.canty@f5.com "an object.", name);
30581879So.canty@f5.com }
30591879So.canty@f5.com
30601879So.canty@f5.com return nxt_conf_vldt_object(vldt, value, vldt->ctx);
30611879So.canty@f5.com }
30621879So.canty@f5.com
30631879So.canty@f5.com
30642262Sa.clayton@nginx.com #if (NXT_HAVE_CGROUP)
30652262Sa.clayton@nginx.com
30662262Sa.clayton@nginx.com static nxt_int_t
nxt_conf_vldt_cgroup_path(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)30672262Sa.clayton@nginx.com nxt_conf_vldt_cgroup_path(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
30682262Sa.clayton@nginx.com void *data)
30692262Sa.clayton@nginx.com {
30702262Sa.clayton@nginx.com char path[NXT_MAX_PATH_LEN];
30712262Sa.clayton@nginx.com nxt_str_t cgpath;
30722262Sa.clayton@nginx.com
30732262Sa.clayton@nginx.com nxt_conf_get_string(value, &cgpath);
30742262Sa.clayton@nginx.com if (cgpath.length >= NXT_MAX_PATH_LEN - strlen(NXT_CGROUP_ROOT) - 1) {
30752262Sa.clayton@nginx.com return nxt_conf_vldt_error(vldt, "The cgroup path \"%V\" is too long.",
30762262Sa.clayton@nginx.com &cgpath);
30772262Sa.clayton@nginx.com }
30782262Sa.clayton@nginx.com
30792262Sa.clayton@nginx.com sprintf(path, "/%*s/", (int) cgpath.length, cgpath.start);
30802262Sa.clayton@nginx.com
30812262Sa.clayton@nginx.com if (cgpath.length == 0 || strstr(path, "/../") != NULL) {
30822262Sa.clayton@nginx.com return nxt_conf_vldt_error(vldt,
30832262Sa.clayton@nginx.com "The cgroup path \"%V\" is invalid.",
30842262Sa.clayton@nginx.com &cgpath);
30852262Sa.clayton@nginx.com }
30862262Sa.clayton@nginx.com
30872262Sa.clayton@nginx.com return NXT_OK;
30882262Sa.clayton@nginx.com }
30892262Sa.clayton@nginx.com
30902262Sa.clayton@nginx.com #endif
30912262Sa.clayton@nginx.com
30922262Sa.clayton@nginx.com
30931879So.canty@f5.com static nxt_int_t
nxt_conf_vldt_clone_namespaces(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)30941235Sigor@sysoev.ru nxt_conf_vldt_clone_namespaces(nxt_conf_validation_t *vldt,
30951235Sigor@sysoev.ru nxt_conf_value_t *value, void *data)
30961182St.nateldemoura@f5.com {
30971182St.nateldemoura@f5.com return nxt_conf_vldt_object(vldt, value, data);
30981182St.nateldemoura@f5.com }
30991182St.nateldemoura@f5.com
31001182St.nateldemoura@f5.com
31011182St.nateldemoura@f5.com static nxt_int_t
nxt_conf_vldt_isolation(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)31021182St.nateldemoura@f5.com nxt_conf_vldt_isolation(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
31031182St.nateldemoura@f5.com void *data)
31041182St.nateldemoura@f5.com {
31051182St.nateldemoura@f5.com return nxt_conf_vldt_object(vldt, value, data);
31061182St.nateldemoura@f5.com }
31071182St.nateldemoura@f5.com
31081182St.nateldemoura@f5.com
31091182St.nateldemoura@f5.com #if (NXT_HAVE_CLONE_NEWUSER)
31101182St.nateldemoura@f5.com
31111182St.nateldemoura@f5.com static nxt_int_t
nxt_conf_vldt_clone_uidmap(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)31121182St.nateldemoura@f5.com nxt_conf_vldt_clone_uidmap(nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
31131182St.nateldemoura@f5.com {
31141182St.nateldemoura@f5.com nxt_int_t ret;
31151182St.nateldemoura@f5.com
31161182St.nateldemoura@f5.com if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
31171182St.nateldemoura@f5.com return nxt_conf_vldt_error(vldt, "The \"uidmap\" array "
31181182St.nateldemoura@f5.com "must contain only object values.");
31191182St.nateldemoura@f5.com }
31201182St.nateldemoura@f5.com
31211182St.nateldemoura@f5.com ret = nxt_conf_vldt_object(vldt, value,
31221182St.nateldemoura@f5.com (void *) nxt_conf_vldt_app_procmap_members);
31231182St.nateldemoura@f5.com if (nxt_slow_path(ret != NXT_OK)) {
31241182St.nateldemoura@f5.com return ret;
31251182St.nateldemoura@f5.com }
31261182St.nateldemoura@f5.com
31272631Sa.clayton@nginx.com return NXT_OK;
31281182St.nateldemoura@f5.com }
31291182St.nateldemoura@f5.com
31301182St.nateldemoura@f5.com
31311182St.nateldemoura@f5.com static nxt_int_t
nxt_conf_vldt_clone_gidmap(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)31321182St.nateldemoura@f5.com nxt_conf_vldt_clone_gidmap(nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
31331182St.nateldemoura@f5.com {
31341182St.nateldemoura@f5.com nxt_int_t ret;
31351182St.nateldemoura@f5.com
31361182St.nateldemoura@f5.com if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
31371182St.nateldemoura@f5.com return nxt_conf_vldt_error(vldt, "The \"gidmap\" array "
31381182St.nateldemoura@f5.com "must contain only object values.");
31391182St.nateldemoura@f5.com }
31401182St.nateldemoura@f5.com
31411182St.nateldemoura@f5.com ret = nxt_conf_vldt_object(vldt, value,
31421182St.nateldemoura@f5.com (void *) nxt_conf_vldt_app_procmap_members);
31431182St.nateldemoura@f5.com if (nxt_slow_path(ret != NXT_OK)) {
31441182St.nateldemoura@f5.com return ret;
31451182St.nateldemoura@f5.com }
31461182St.nateldemoura@f5.com
31472631Sa.clayton@nginx.com return NXT_OK;
31481182St.nateldemoura@f5.com }
31491182St.nateldemoura@f5.com
31501182St.nateldemoura@f5.com #endif
31511182St.nateldemoura@f5.com
31521182St.nateldemoura@f5.com
31531182St.nateldemoura@f5.com static nxt_int_t
nxt_conf_vldt_argument(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)3154685Svbart@nginx.com nxt_conf_vldt_argument(nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
3155685Svbart@nginx.com {
3156685Svbart@nginx.com nxt_str_t str;
3157685Svbart@nginx.com
3158685Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
3159685Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"arguments\" array "
3160685Svbart@nginx.com "must contain only string values.");
3161685Svbart@nginx.com }
3162685Svbart@nginx.com
3163685Svbart@nginx.com nxt_conf_get_string(value, &str);
3164685Svbart@nginx.com
31652232Salx@nginx.com if (memchr(str.start, '\0', str.length) != NULL) {
3166685Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"arguments\" array must not "
3167685Svbart@nginx.com "contain strings with null character.");
3168685Svbart@nginx.com }
3169685Svbart@nginx.com
3170685Svbart@nginx.com return NXT_OK;
3171685Svbart@nginx.com }
3172688Svbart@nginx.com
3173688Svbart@nginx.com
3174688Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_php(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)31751473Svbart@nginx.com nxt_conf_vldt_php(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
31761473Svbart@nginx.com void *data)
31771473Svbart@nginx.com {
31781473Svbart@nginx.com nxt_conf_value_t *targets;
31791473Svbart@nginx.com
31801473Svbart@nginx.com static nxt_str_t targets_str = nxt_string("targets");
31811473Svbart@nginx.com
31821473Svbart@nginx.com targets = nxt_conf_get_object_member(value, &targets_str, NULL);
31831473Svbart@nginx.com
31841473Svbart@nginx.com if (targets != NULL) {
31851473Svbart@nginx.com return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_php_members);
31861473Svbart@nginx.com }
31871473Svbart@nginx.com
31881473Svbart@nginx.com return nxt_conf_vldt_object(vldt, value,
31891473Svbart@nginx.com nxt_conf_vldt_php_notargets_members);
31901473Svbart@nginx.com }
31911473Svbart@nginx.com
31921473Svbart@nginx.com
31931473Svbart@nginx.com static nxt_int_t
nxt_conf_vldt_php_option(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)3194688Svbart@nginx.com nxt_conf_vldt_php_option(nxt_conf_validation_t *vldt, nxt_str_t *name,
3195688Svbart@nginx.com nxt_conf_value_t *value)
3196688Svbart@nginx.com {
3197688Svbart@nginx.com if (name->length == 0) {
3198688Svbart@nginx.com return nxt_conf_vldt_error(vldt,
3199688Svbart@nginx.com "The PHP option name must not be empty.");
3200688Svbart@nginx.com }
3201688Svbart@nginx.com
3202688Svbart@nginx.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
3203688Svbart@nginx.com return nxt_conf_vldt_error(vldt, "The \"%V\" PHP option must be "
3204688Svbart@nginx.com "a string.", name);
3205688Svbart@nginx.com }
3206688Svbart@nginx.com
3207688Svbart@nginx.com return NXT_OK;
3208688Svbart@nginx.com }
3209977Smax.romanov@gmail.com
3210977Smax.romanov@gmail.com
3211977Smax.romanov@gmail.com static nxt_int_t
nxt_conf_vldt_java_classpath(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)32121235Sigor@sysoev.ru nxt_conf_vldt_java_classpath(nxt_conf_validation_t *vldt,
32131235Sigor@sysoev.ru nxt_conf_value_t *value)
3214977Smax.romanov@gmail.com {
3215977Smax.romanov@gmail.com nxt_str_t str;
3216977Smax.romanov@gmail.com
3217977Smax.romanov@gmail.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
3218977Smax.romanov@gmail.com return nxt_conf_vldt_error(vldt, "The \"classpath\" array "
3219977Smax.romanov@gmail.com "must contain only string values.");
3220977Smax.romanov@gmail.com }
3221977Smax.romanov@gmail.com
3222977Smax.romanov@gmail.com nxt_conf_get_string(value, &str);
3223977Smax.romanov@gmail.com
32242232Salx@nginx.com if (memchr(str.start, '\0', str.length) != NULL) {
3225977Smax.romanov@gmail.com return nxt_conf_vldt_error(vldt, "The \"classpath\" array must not "
3226977Smax.romanov@gmail.com "contain strings with null character.");
3227977Smax.romanov@gmail.com }
3228977Smax.romanov@gmail.com
3229977Smax.romanov@gmail.com return NXT_OK;
3230977Smax.romanov@gmail.com }
3231977Smax.romanov@gmail.com
32321012Smax.romanov@nginx.com
3233977Smax.romanov@gmail.com static nxt_int_t
nxt_conf_vldt_java_option(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)3234977Smax.romanov@gmail.com nxt_conf_vldt_java_option(nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
3235977Smax.romanov@gmail.com {
3236977Smax.romanov@gmail.com nxt_str_t str;
3237977Smax.romanov@gmail.com
3238977Smax.romanov@gmail.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
3239977Smax.romanov@gmail.com return nxt_conf_vldt_error(vldt, "The \"options\" array "
3240977Smax.romanov@gmail.com "must contain only string values.");
3241977Smax.romanov@gmail.com }
3242977Smax.romanov@gmail.com
3243977Smax.romanov@gmail.com nxt_conf_get_string(value, &str);
3244977Smax.romanov@gmail.com
32452232Salx@nginx.com if (memchr(str.start, '\0', str.length) != NULL) {
3246977Smax.romanov@gmail.com return nxt_conf_vldt_error(vldt, "The \"options\" array must not "
3247977Smax.romanov@gmail.com "contain strings with null character.");
3248977Smax.romanov@gmail.com }
3249977Smax.romanov@gmail.com
3250977Smax.romanov@gmail.com return NXT_OK;
3251977Smax.romanov@gmail.com }
32521394Sigor@sysoev.ru
32531394Sigor@sysoev.ru
32541394Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_upstream(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)32551394Sigor@sysoev.ru nxt_conf_vldt_upstream(nxt_conf_validation_t *vldt, nxt_str_t *name,
32561394Sigor@sysoev.ru nxt_conf_value_t *value)
32571394Sigor@sysoev.ru {
32581394Sigor@sysoev.ru nxt_int_t ret;
32591394Sigor@sysoev.ru nxt_conf_value_t *conf;
32601394Sigor@sysoev.ru
32611394Sigor@sysoev.ru static nxt_str_t servers = nxt_string("servers");
32621394Sigor@sysoev.ru
32631394Sigor@sysoev.ru ret = nxt_conf_vldt_type(vldt, name, value, NXT_CONF_VLDT_OBJECT);
32641394Sigor@sysoev.ru
32651394Sigor@sysoev.ru if (ret != NXT_OK) {
32661394Sigor@sysoev.ru return ret;
32671394Sigor@sysoev.ru }
32681394Sigor@sysoev.ru
32691394Sigor@sysoev.ru ret = nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_upstream_members);
32701394Sigor@sysoev.ru
32711394Sigor@sysoev.ru if (ret != NXT_OK) {
32721394Sigor@sysoev.ru return ret;
32731394Sigor@sysoev.ru }
32741394Sigor@sysoev.ru
32751394Sigor@sysoev.ru conf = nxt_conf_get_object_member(value, &servers, NULL);
32761394Sigor@sysoev.ru if (conf == NULL) {
32771394Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"%V\" upstream must contain "
32781394Sigor@sysoev.ru "\"servers\" object value.", name);
32791394Sigor@sysoev.ru }
32801394Sigor@sysoev.ru
32811394Sigor@sysoev.ru return NXT_OK;
32821394Sigor@sysoev.ru }
32831394Sigor@sysoev.ru
32841394Sigor@sysoev.ru
32851394Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_server(nxt_conf_validation_t * vldt,nxt_str_t * name,nxt_conf_value_t * value)32861394Sigor@sysoev.ru nxt_conf_vldt_server(nxt_conf_validation_t *vldt, nxt_str_t *name,
32871394Sigor@sysoev.ru nxt_conf_value_t *value)
32881394Sigor@sysoev.ru {
32891394Sigor@sysoev.ru nxt_int_t ret;
32902634Salx@kernel.org nxt_str_t str;
32911394Sigor@sysoev.ru nxt_sockaddr_t *sa;
32921394Sigor@sysoev.ru
32931394Sigor@sysoev.ru ret = nxt_conf_vldt_type(vldt, name, value, NXT_CONF_VLDT_OBJECT);
32941394Sigor@sysoev.ru if (ret != NXT_OK) {
32951394Sigor@sysoev.ru return ret;
32961394Sigor@sysoev.ru }
32971394Sigor@sysoev.ru
32982634Salx@kernel.org if (nxt_slow_path(nxt_str_dup(vldt->pool, &str, name) == NULL)) {
32992634Salx@kernel.org return NXT_ERROR;
33002634Salx@kernel.org }
33012634Salx@kernel.org
33022634Salx@kernel.org sa = nxt_sockaddr_parse(vldt->pool, &str);
33031394Sigor@sysoev.ru if (sa == NULL) {
33041394Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"%V\" is not valid "
33051394Sigor@sysoev.ru "server address.", name);
33061394Sigor@sysoev.ru }
33071394Sigor@sysoev.ru
33081394Sigor@sysoev.ru return nxt_conf_vldt_object(vldt, value,
33091394Sigor@sysoev.ru nxt_conf_vldt_upstream_server_members);
33101394Sigor@sysoev.ru }
33111394Sigor@sysoev.ru
33121394Sigor@sysoev.ru
33131394Sigor@sysoev.ru static nxt_int_t
nxt_conf_vldt_server_weight(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)33141394Sigor@sysoev.ru nxt_conf_vldt_server_weight(nxt_conf_validation_t *vldt,
33151394Sigor@sysoev.ru nxt_conf_value_t *value, void *data)
33161394Sigor@sysoev.ru {
33171440Sigor@sysoev.ru double num_value;
33181440Sigor@sysoev.ru
33191440Sigor@sysoev.ru num_value = nxt_conf_get_number(value);
33201440Sigor@sysoev.ru
33211440Sigor@sysoev.ru if (num_value < 0) {
33221394Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"weight\" number must be "
33231440Sigor@sysoev.ru "positive.");
33241394Sigor@sysoev.ru }
33251394Sigor@sysoev.ru
33261440Sigor@sysoev.ru if (num_value > 1000000) {
33271394Sigor@sysoev.ru return nxt_conf_vldt_error(vldt, "The \"weight\" number must "
33281440Sigor@sysoev.ru "not exceed 1,000,000");
33291394Sigor@sysoev.ru }
33301394Sigor@sysoev.ru
33311394Sigor@sysoev.ru return NXT_OK;
33321394Sigor@sysoev.ru }
33332166Sz.hong@f5.com
33342166Sz.hong@f5.com
33352450Sz.hong@f5.com #if (NXT_HAVE_NJS)
33362450Sz.hong@f5.com
33372450Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_js_module(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)33382450Sz.hong@f5.com nxt_conf_vldt_js_module(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
33392450Sz.hong@f5.com void *data)
33402450Sz.hong@f5.com {
33412450Sz.hong@f5.com if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
33422450Sz.hong@f5.com return nxt_conf_vldt_array_iterator(vldt, value,
33432450Sz.hong@f5.com &nxt_conf_vldt_js_module_element);
33442450Sz.hong@f5.com }
33452450Sz.hong@f5.com
33462450Sz.hong@f5.com /* NXT_CONF_STRING */
33472450Sz.hong@f5.com
33482450Sz.hong@f5.com return nxt_conf_vldt_js_module_element(vldt, value);
33492450Sz.hong@f5.com }
33502450Sz.hong@f5.com
33512450Sz.hong@f5.com
33522450Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_js_module_element(nxt_conf_validation_t * vldt,nxt_conf_value_t * value)33532450Sz.hong@f5.com nxt_conf_vldt_js_module_element(nxt_conf_validation_t *vldt,
33542450Sz.hong@f5.com nxt_conf_value_t *value)
33552450Sz.hong@f5.com {
33562450Sz.hong@f5.com nxt_str_t name;
33572450Sz.hong@f5.com nxt_conf_value_t *module;
33582450Sz.hong@f5.com
33592450Sz.hong@f5.com if (nxt_conf_type(value) != NXT_CONF_STRING) {
33602450Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "The \"js_module\" array must "
33612450Sz.hong@f5.com "contain only string values.");
33622450Sz.hong@f5.com }
33632450Sz.hong@f5.com
33642450Sz.hong@f5.com nxt_conf_get_string(value, &name);
33652450Sz.hong@f5.com
33662450Sz.hong@f5.com module = nxt_script_info_get(&name);
33672450Sz.hong@f5.com if (module == NULL) {
33682450Sz.hong@f5.com return nxt_conf_vldt_error(vldt, "JS module \"%V\" is not found.",
33692450Sz.hong@f5.com &name);
33702450Sz.hong@f5.com }
33712450Sz.hong@f5.com
33722450Sz.hong@f5.com return NXT_OK;
33732450Sz.hong@f5.com }
33742450Sz.hong@f5.com
33752450Sz.hong@f5.com #endif
33762450Sz.hong@f5.com
33772450Sz.hong@f5.com
33782166Sz.hong@f5.com typedef struct {
33792166Sz.hong@f5.com nxt_str_t path;
33802166Sz.hong@f5.com nxt_str_t format;
33812166Sz.hong@f5.com } nxt_conf_vldt_access_log_conf_t;
33822166Sz.hong@f5.com
33832166Sz.hong@f5.com
33842166Sz.hong@f5.com static nxt_conf_map_t nxt_conf_vldt_access_log_map[] = {
33852166Sz.hong@f5.com {
33862166Sz.hong@f5.com nxt_string("path"),
33872166Sz.hong@f5.com NXT_CONF_MAP_STR,
33882166Sz.hong@f5.com offsetof(nxt_conf_vldt_access_log_conf_t, path),
33892166Sz.hong@f5.com },
33902166Sz.hong@f5.com
33912166Sz.hong@f5.com {
33922166Sz.hong@f5.com nxt_string("format"),
33932166Sz.hong@f5.com NXT_CONF_MAP_STR,
33942166Sz.hong@f5.com offsetof(nxt_conf_vldt_access_log_conf_t, format),
33952166Sz.hong@f5.com },
33962166Sz.hong@f5.com };
33972166Sz.hong@f5.com
33982166Sz.hong@f5.com
33992166Sz.hong@f5.com static nxt_int_t
nxt_conf_vldt_access_log(nxt_conf_validation_t * vldt,nxt_conf_value_t * value,void * data)34002166Sz.hong@f5.com nxt_conf_vldt_access_log(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
34012166Sz.hong@f5.com void *data)
34022166Sz.hong@f5.com {
34032166Sz.hong@f5.com nxt_int_t ret;
34042166Sz.hong@f5.com nxt_conf_vldt_access_log_conf_t conf;
34052166Sz.hong@f5.com
34062166Sz.hong@f5.com static nxt_str_t format_str = nxt_string("format");
34072166Sz.hong@f5.com
34082166Sz.hong@f5.com if (nxt_conf_type(value) == NXT_CONF_STRING) {
34092166Sz.hong@f5.com return NXT_OK;
34102166Sz.hong@f5.com }
34112166Sz.hong@f5.com
34122166Sz.hong@f5.com ret = nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_access_log_members);
34132166Sz.hong@f5.com if (ret != NXT_OK) {
34142166Sz.hong@f5.com return ret;
34152166Sz.hong@f5.com }
34162166Sz.hong@f5.com
34172166Sz.hong@f5.com nxt_memzero(&conf, sizeof(nxt_conf_vldt_access_log_conf_t));
34182166Sz.hong@f5.com
34192166Sz.hong@f5.com ret = nxt_conf_map_object(vldt->pool, value,
34202166Sz.hong@f5.com nxt_conf_vldt_access_log_map,
34212166Sz.hong@f5.com nxt_nitems(nxt_conf_vldt_access_log_map),
34222166Sz.hong@f5.com &conf);
34232166Sz.hong@f5.com if (ret != NXT_OK) {
34242166Sz.hong@f5.com return ret;
34252166Sz.hong@f5.com }
34262166Sz.hong@f5.com
34272166Sz.hong@f5.com if (conf.path.length == 0) {
34282166Sz.hong@f5.com return nxt_conf_vldt_error(vldt,
34292166Sz.hong@f5.com "The \"path\" string must not be empty.");
34302166Sz.hong@f5.com }
34312166Sz.hong@f5.com
34322247Sz.hong@f5.com if (nxt_is_tstr(&conf.format)) {
34332166Sz.hong@f5.com return nxt_conf_vldt_var(vldt, &format_str, &conf.format);
34342166Sz.hong@f5.com }
34352166Sz.hong@f5.com
34362166Sz.hong@f5.com return NXT_OK;
34372166Sz.hong@f5.com }
3438