Deleted
Added
1 2/* 3 * Copyright (C) Valentin V. Bartenev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> 8#include <nxt_conf.h> 9#include <nxt_cert.h> 10#include <nxt_router.h> 11#include <nxt_http.h> |
12#include <nxt_sockaddr.h> 13#include <nxt_http_route_addr.h> |
14 15 16typedef enum { 17 NXT_CONF_VLDT_NULL = 1 << NXT_CONF_NULL, 18 NXT_CONF_VLDT_BOOLEAN = 1 << NXT_CONF_BOOLEAN, 19 NXT_CONF_VLDT_INTEGER = 1 << NXT_CONF_INTEGER, 20 NXT_CONF_VLDT_NUMBER = 1 << NXT_CONF_NUMBER, 21 NXT_CONF_VLDT_STRING = 1 << NXT_CONF_STRING, --- 57 unchanged lines hidden (view full) --- 79static nxt_int_t nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t *vldt, 80 nxt_conf_value_t *value, void *data); 81static nxt_int_t nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t *vldt, 82 nxt_conf_value_t *value); 83static nxt_int_t nxt_conf_vldt_match_patterns_set_member( 84 nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value); 85static nxt_int_t nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t *vldt, 86 nxt_conf_value_t *value, void *data); |
87static nxt_int_t nxt_conf_vldt_match_addrs(nxt_conf_validation_t *vldt, 88 nxt_conf_value_t *value, void *data); 89static nxt_int_t nxt_conf_vldt_match_addr(nxt_conf_validation_t *vldt, 90 nxt_conf_value_t *value); |
91static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt, 92 nxt_conf_value_t *value, void *data); 93static nxt_int_t nxt_conf_vldt_app(nxt_conf_validation_t *vldt, 94 nxt_str_t *name, nxt_conf_value_t *value); 95static nxt_int_t nxt_conf_vldt_object(nxt_conf_validation_t *vldt, 96 nxt_conf_value_t *value, void *data); 97static nxt_int_t nxt_conf_vldt_processes(nxt_conf_validation_t *vldt, 98 nxt_conf_value_t *value, void *data); --- 185 unchanged lines hidden (view full) --- 284 &nxt_conf_vldt_match_scheme_pattern, 285 NULL }, 286 287 { nxt_string("host"), 288 NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY, 289 &nxt_conf_vldt_match_patterns, 290 NULL }, 291 |
292 { nxt_string("source"), 293 NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY, 294 &nxt_conf_vldt_match_addrs, 295 NULL }, 296 |
297 { nxt_string("uri"), 298 NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY, 299 &nxt_conf_vldt_match_patterns, 300 NULL }, 301 302 { nxt_string("arguments"), 303 NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY, 304 &nxt_conf_vldt_match_patterns_sets, --- 856 unchanged lines hidden (view full) --- 1161 } 1162 } 1163 1164 return NXT_OK; 1165} 1166 1167 1168static nxt_int_t |
1169nxt_conf_vldt_match_addrs(nxt_conf_validation_t *vldt, 1170 nxt_conf_value_t *value, void *data) 1171{ 1172 if (nxt_conf_type(value) == NXT_CONF_ARRAY) { 1173 return nxt_conf_vldt_array_iterator(vldt, value, 1174 &nxt_conf_vldt_match_addr); 1175 } 1176 1177 return nxt_conf_vldt_match_addr(vldt, value); 1178} 1179 1180 1181static nxt_int_t 1182nxt_conf_vldt_match_addr(nxt_conf_validation_t *vldt, 1183 nxt_conf_value_t *value) 1184{ 1185 nxt_http_route_addr_pattern_t pattern; 1186 1187 switch (nxt_http_route_addr_pattern_parse(vldt->pool, &pattern, value)) { 1188 1189 case NXT_OK: 1190 return NXT_OK; 1191 1192 case NXT_ADDR_PATTERN_PORT_ERROR: 1193 return nxt_conf_vldt_error(vldt, "The \"address\" port an invalid " 1194 "port."); 1195 1196 case NXT_ADDR_PATTERN_CV_TYPE_ERROR: 1197 return nxt_conf_vldt_error(vldt, "The \"match\" pattern for " 1198 "\"address\" must be a string."); 1199 1200 case NXT_ADDR_PATTERN_LENGTH_ERROR: 1201 return nxt_conf_vldt_error(vldt, "The \"address\" is too short."); 1202 1203 case NXT_ADDR_PATTERN_FORMAT_ERROR: 1204 return nxt_conf_vldt_error(vldt, "The \"address\" format is invalid."); 1205 1206 case NXT_ADDR_PATTERN_RANGE_OVERLAP_ERROR: 1207 return nxt_conf_vldt_error(vldt, "The \"address\" range is " 1208 "overlapping."); 1209 1210 case NXT_ADDR_PATTERN_CIDR_ERROR: 1211 return nxt_conf_vldt_error(vldt, "The \"address\" has an invalid CIDR " 1212 "prefix."); 1213 1214 case NXT_ADDR_PATTERN_NO_IPv6_ERROR: 1215 return nxt_conf_vldt_error(vldt, "The \"address\" does not support " 1216 "IPv6 with your configuration."); 1217 1218 default: 1219 return nxt_conf_vldt_error(vldt, "The \"address\" has an unknown " 1220 "format."); 1221 } 1222} 1223 1224 1225static nxt_int_t |
1226nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t *vldt, 1227 nxt_conf_value_t *value, void *data) 1228{ 1229 nxt_str_t scheme; 1230 1231 static const nxt_str_t http = nxt_string("http"); 1232 static const nxt_str_t https = nxt_string("https"); 1233 --- 635 unchanged lines hidden --- |