1 /* 2 * configparser.y -- yacc grammar for unbound configuration files 3 * 4 * Copyright (c) 2001-2006, NLnet Labs. All rights reserved. 5 * 6 * Copyright (c) 2007, NLnet Labs. All rights reserved. 7 * 8 * This software is open source. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 17 * Redistributions in binary form must reproduce the above copyright notice, 18 * this list of conditions and the following disclaimer in the documentation 19 * and/or other materials provided with the distribution. 20 * 21 * Neither the name of the NLNET LABS nor the names of its contributors may 22 * be used to endorse or promote products derived from this software without 23 * specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 31 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 */ 37 38 %{ 39 #include "config.h" 40 41 #include <stdarg.h> 42 #include <stdio.h> 43 #include <string.h> 44 #include <stdlib.h> 45 #include <assert.h> 46 47 #include "util/configyyrename.h" 48 #include "util/config_file.h" 49 #include "util/net_help.h" 50 51 int ub_c_lex(void); 52 void ub_c_error(const char *message); 53 54 static void validate_respip_action(const char* action); 55 56 /* these need to be global, otherwise they cannot be used inside yacc */ 57 extern struct config_parser_state* cfg_parser; 58 59 #if 0 60 #define OUTYY(s) printf s /* used ONLY when debugging */ 61 #else 62 #define OUTYY(s) 63 #endif 64 65 %} 66 %union { 67 char* str; 68 }; 69 70 %token SPACE LETTER NEWLINE COMMENT COLON ANY ZONESTR 71 %token <str> STRING_ARG 72 %token VAR_FORCE_TOPLEVEL 73 %token VAR_SERVER VAR_VERBOSITY VAR_NUM_THREADS VAR_PORT 74 %token VAR_OUTGOING_RANGE VAR_INTERFACE VAR_PREFER_IP4 75 %token VAR_DO_IP4 VAR_DO_IP6 VAR_PREFER_IP6 VAR_DO_UDP VAR_DO_TCP 76 %token VAR_TCP_MSS VAR_OUTGOING_TCP_MSS VAR_TCP_IDLE_TIMEOUT 77 %token VAR_EDNS_TCP_KEEPALIVE VAR_EDNS_TCP_KEEPALIVE_TIMEOUT 78 %token VAR_CHROOT VAR_USERNAME VAR_DIRECTORY VAR_LOGFILE VAR_PIDFILE 79 %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD 80 %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP 81 %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS 82 %token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME 83 %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY 84 %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES 85 %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR 86 %token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION 87 %token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF 88 %token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE 89 %token VAR_BOGUS_TTL VAR_VAL_CLEAN_ADDITIONAL VAR_VAL_PERMISSIVE_MODE 90 %token VAR_INCOMING_NUM_TCP VAR_MSG_BUFFER_SIZE VAR_KEY_CACHE_SIZE 91 %token VAR_KEY_CACHE_SLABS VAR_TRUSTED_KEYS_FILE 92 %token VAR_VAL_NSEC3_KEYSIZE_ITERATIONS VAR_USE_SYSLOG 93 %token VAR_OUTGOING_INTERFACE VAR_ROOT_HINTS VAR_DO_NOT_QUERY_LOCALHOST 94 %token VAR_CACHE_MAX_TTL VAR_HARDEN_DNSSEC_STRIPPED VAR_ACCESS_CONTROL 95 %token VAR_LOCAL_ZONE VAR_LOCAL_DATA VAR_INTERFACE_AUTOMATIC 96 %token VAR_STATISTICS_INTERVAL VAR_DO_DAEMONIZE VAR_USE_CAPS_FOR_ID 97 %token VAR_STATISTICS_CUMULATIVE VAR_OUTGOING_PORT_PERMIT 98 %token VAR_OUTGOING_PORT_AVOID VAR_DLV_ANCHOR_FILE VAR_DLV_ANCHOR 99 %token VAR_NEG_CACHE_SIZE VAR_HARDEN_REFERRAL_PATH VAR_PRIVATE_ADDRESS 100 %token VAR_PRIVATE_DOMAIN VAR_REMOTE_CONTROL VAR_CONTROL_ENABLE 101 %token VAR_CONTROL_INTERFACE VAR_CONTROL_PORT VAR_SERVER_KEY_FILE 102 %token VAR_SERVER_CERT_FILE VAR_CONTROL_KEY_FILE VAR_CONTROL_CERT_FILE 103 %token VAR_CONTROL_USE_CERT 104 %token VAR_EXTENDED_STATISTICS VAR_LOCAL_DATA_PTR VAR_JOSTLE_TIMEOUT 105 %token VAR_STUB_PRIME VAR_UNWANTED_REPLY_THRESHOLD VAR_LOG_TIME_ASCII 106 %token VAR_DOMAIN_INSECURE VAR_PYTHON VAR_PYTHON_SCRIPT VAR_VAL_SIG_SKEW_MIN 107 %token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL 108 %token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN 109 %token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE VAR_PREFETCH 110 %token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_SO_REUSEPORT VAR_HARDEN_BELOW_NXDOMAIN 111 %token VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES VAR_LOG_REPLIES VAR_LOG_LOCAL_ACTIONS 112 %token VAR_TCP_UPSTREAM VAR_SSL_UPSTREAM 113 %token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST 114 %token VAR_STUB_SSL_UPSTREAM VAR_FORWARD_SSL_UPSTREAM VAR_TLS_CERT_BUNDLE 115 %token VAR_HTTPS_PORT VAR_HTTP_ENDPOINT VAR_HTTP_MAX_STREAMS 116 %token VAR_HTTP_QUERY_BUFFER_SIZE VAR_HTTP_RESPONSE_BUFFER_SIZE 117 %token VAR_HTTP_NODELAY 118 %token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN 119 %token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE 120 %token VAR_UNBLOCK_LAN_ZONES VAR_INSECURE_LAN_ZONES 121 %token VAR_INFRA_CACHE_MIN_RTT 122 %token VAR_DNS64_PREFIX VAR_DNS64_SYNTHALL VAR_DNS64_IGNORE_AAAA 123 %token VAR_DNSTAP VAR_DNSTAP_ENABLE VAR_DNSTAP_SOCKET_PATH VAR_DNSTAP_IP 124 %token VAR_DNSTAP_TLS VAR_DNSTAP_TLS_SERVER_NAME VAR_DNSTAP_TLS_CERT_BUNDLE 125 %token VAR_DNSTAP_TLS_CLIENT_KEY_FILE VAR_DNSTAP_TLS_CLIENT_CERT_FILE 126 %token VAR_DNSTAP_SEND_IDENTITY VAR_DNSTAP_SEND_VERSION VAR_DNSTAP_BIDIRECTIONAL 127 %token VAR_DNSTAP_IDENTITY VAR_DNSTAP_VERSION 128 %token VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES 129 %token VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES 130 %token VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES 131 %token VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES 132 %token VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES 133 %token VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES 134 %token VAR_RESPONSE_IP_TAG VAR_RESPONSE_IP VAR_RESPONSE_IP_DATA 135 %token VAR_HARDEN_ALGO_DOWNGRADE VAR_IP_TRANSPARENT 136 %token VAR_IP_DSCP 137 %token VAR_DISABLE_DNSSEC_LAME_CHECK 138 %token VAR_IP_RATELIMIT VAR_IP_RATELIMIT_SLABS VAR_IP_RATELIMIT_SIZE 139 %token VAR_RATELIMIT VAR_RATELIMIT_SLABS VAR_RATELIMIT_SIZE 140 %token VAR_RATELIMIT_FOR_DOMAIN VAR_RATELIMIT_BELOW_DOMAIN 141 %token VAR_IP_RATELIMIT_FACTOR VAR_RATELIMIT_FACTOR 142 %token VAR_SEND_CLIENT_SUBNET VAR_CLIENT_SUBNET_ZONE 143 %token VAR_CLIENT_SUBNET_ALWAYS_FORWARD VAR_CLIENT_SUBNET_OPCODE 144 %token VAR_MAX_CLIENT_SUBNET_IPV4 VAR_MAX_CLIENT_SUBNET_IPV6 145 %token VAR_MIN_CLIENT_SUBNET_IPV4 VAR_MIN_CLIENT_SUBNET_IPV6 146 %token VAR_MAX_ECS_TREE_SIZE_IPV4 VAR_MAX_ECS_TREE_SIZE_IPV6 147 %token VAR_CAPS_WHITELIST VAR_CACHE_MAX_NEGATIVE_TTL VAR_PERMIT_SMALL_HOLDDOWN 148 %token VAR_QNAME_MINIMISATION VAR_QNAME_MINIMISATION_STRICT VAR_IP_FREEBIND 149 %token VAR_DEFINE_TAG VAR_LOCAL_ZONE_TAG VAR_ACCESS_CONTROL_TAG 150 %token VAR_LOCAL_ZONE_OVERRIDE VAR_ACCESS_CONTROL_TAG_ACTION 151 %token VAR_ACCESS_CONTROL_TAG_DATA VAR_VIEW VAR_ACCESS_CONTROL_VIEW 152 %token VAR_VIEW_FIRST VAR_SERVE_EXPIRED VAR_SERVE_EXPIRED_TTL 153 %token VAR_SERVE_EXPIRED_TTL_RESET VAR_SERVE_EXPIRED_REPLY_TTL 154 %token VAR_SERVE_EXPIRED_CLIENT_TIMEOUT VAR_FAKE_DSA 155 %token VAR_FAKE_SHA1 VAR_LOG_IDENTITY VAR_HIDE_TRUSTANCHOR 156 %token VAR_TRUST_ANCHOR_SIGNALING VAR_AGGRESSIVE_NSEC VAR_USE_SYSTEMD 157 %token VAR_SHM_ENABLE VAR_SHM_KEY VAR_ROOT_KEY_SENTINEL 158 %token VAR_DNSCRYPT VAR_DNSCRYPT_ENABLE VAR_DNSCRYPT_PORT VAR_DNSCRYPT_PROVIDER 159 %token VAR_DNSCRYPT_SECRET_KEY VAR_DNSCRYPT_PROVIDER_CERT 160 %token VAR_DNSCRYPT_PROVIDER_CERT_ROTATED 161 %token VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE 162 %token VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS 163 %token VAR_DNSCRYPT_NONCE_CACHE_SIZE 164 %token VAR_DNSCRYPT_NONCE_CACHE_SLABS 165 %token VAR_IPSECMOD_ENABLED VAR_IPSECMOD_HOOK VAR_IPSECMOD_IGNORE_BOGUS 166 %token VAR_IPSECMOD_MAX_TTL VAR_IPSECMOD_WHITELIST VAR_IPSECMOD_STRICT 167 %token VAR_CACHEDB VAR_CACHEDB_BACKEND VAR_CACHEDB_SECRETSEED 168 %token VAR_CACHEDB_REDISHOST VAR_CACHEDB_REDISPORT VAR_CACHEDB_REDISTIMEOUT 169 %token VAR_CACHEDB_REDISEXPIRERECORDS 170 %token VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM VAR_FOR_UPSTREAM 171 %token VAR_AUTH_ZONE VAR_ZONEFILE VAR_MASTER VAR_URL VAR_FOR_DOWNSTREAM 172 %token VAR_FALLBACK_ENABLED VAR_TLS_ADDITIONAL_PORT VAR_LOW_RTT VAR_LOW_RTT_PERMIL 173 %token VAR_FAST_SERVER_PERMIL VAR_FAST_SERVER_NUM 174 %token VAR_ALLOW_NOTIFY VAR_TLS_WIN_CERT VAR_TCP_CONNECTION_LIMIT 175 %token VAR_FORWARD_NO_CACHE VAR_STUB_NO_CACHE VAR_LOG_SERVFAIL VAR_DENY_ANY 176 %token VAR_UNKNOWN_SERVER_TIME_LIMIT VAR_LOG_TAG_QUERYREPLY 177 %token VAR_STREAM_WAIT_SIZE VAR_TLS_CIPHERS VAR_TLS_CIPHERSUITES VAR_TLS_USE_SNI 178 %token VAR_IPSET VAR_IPSET_NAME_V4 VAR_IPSET_NAME_V6 179 %token VAR_TLS_SESSION_TICKET_KEYS VAR_RPZ VAR_TAGS VAR_RPZ_ACTION_OVERRIDE 180 %token VAR_RPZ_CNAME_OVERRIDE VAR_RPZ_LOG VAR_RPZ_LOG_NAME 181 %token VAR_DYNLIB VAR_DYNLIB_FILE VAR_EDNS_CLIENT_TAG VAR_EDNS_CLIENT_TAG_OPCODE 182 183 %% 184 toplevelvars: /* empty */ | toplevelvars toplevelvar ; 185 toplevelvar: serverstart contents_server | stubstart contents_stub | 186 forwardstart contents_forward | pythonstart contents_py | 187 rcstart contents_rc | dtstart contents_dt | viewstart contents_view | 188 dnscstart contents_dnsc | cachedbstart contents_cachedb | 189 ipsetstart contents_ipset | authstart contents_auth | 190 rpzstart contents_rpz | dynlibstart contents_dl | 191 force_toplevel 192 ; 193 force_toplevel: VAR_FORCE_TOPLEVEL 194 { 195 OUTYY(("\nP(force-toplevel)\n")); 196 } 197 ; 198 /* server: declaration */ 199 serverstart: VAR_SERVER 200 { 201 OUTYY(("\nP(server:)\n")); 202 } 203 ; 204 contents_server: contents_server content_server 205 | ; 206 content_server: server_num_threads | server_verbosity | server_port | 207 server_outgoing_range | server_do_ip4 | 208 server_do_ip6 | server_prefer_ip4 | server_prefer_ip6 | 209 server_do_udp | server_do_tcp | 210 server_tcp_mss | server_outgoing_tcp_mss | server_tcp_idle_timeout | 211 server_tcp_keepalive | server_tcp_keepalive_timeout | 212 server_interface | server_chroot | server_username | 213 server_directory | server_logfile | server_pidfile | 214 server_msg_cache_size | server_msg_cache_slabs | 215 server_num_queries_per_thread | server_rrset_cache_size | 216 server_rrset_cache_slabs | server_outgoing_num_tcp | 217 server_infra_host_ttl | server_infra_lame_ttl | 218 server_infra_cache_slabs | server_infra_cache_numhosts | 219 server_infra_cache_lame_size | server_target_fetch_policy | 220 server_harden_short_bufsize | server_harden_large_queries | 221 server_do_not_query_address | server_hide_identity | 222 server_hide_version | server_identity | server_version | 223 server_harden_glue | server_module_conf | server_trust_anchor_file | 224 server_trust_anchor | server_val_override_date | server_bogus_ttl | 225 server_val_clean_additional | server_val_permissive_mode | 226 server_incoming_num_tcp | server_msg_buffer_size | 227 server_key_cache_size | server_key_cache_slabs | 228 server_trusted_keys_file | server_val_nsec3_keysize_iterations | 229 server_use_syslog | server_outgoing_interface | server_root_hints | 230 server_do_not_query_localhost | server_cache_max_ttl | 231 server_harden_dnssec_stripped | server_access_control | 232 server_local_zone | server_local_data | server_interface_automatic | 233 server_statistics_interval | server_do_daemonize | 234 server_use_caps_for_id | server_statistics_cumulative | 235 server_outgoing_port_permit | server_outgoing_port_avoid | 236 server_dlv_anchor_file | server_dlv_anchor | server_neg_cache_size | 237 server_harden_referral_path | server_private_address | 238 server_private_domain | server_extended_statistics | 239 server_local_data_ptr | server_jostle_timeout | 240 server_unwanted_reply_threshold | server_log_time_ascii | 241 server_domain_insecure | server_val_sig_skew_min | 242 server_val_sig_skew_max | server_cache_min_ttl | server_val_log_level | 243 server_auto_trust_anchor_file | server_add_holddown | 244 server_del_holddown | server_keep_missing | server_so_rcvbuf | 245 server_edns_buffer_size | server_prefetch | server_prefetch_key | 246 server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag | 247 server_log_queries | server_log_replies | server_tcp_upstream | server_ssl_upstream | 248 server_log_local_actions | 249 server_ssl_service_key | server_ssl_service_pem | server_ssl_port | 250 server_https_port | server_http_endpoint | server_http_max_streams | 251 server_http_query_buffer_size | server_http_response_buffer_size | 252 server_http_nodelay | 253 server_minimal_responses | server_rrset_roundrobin | server_max_udp_size | 254 server_so_reuseport | server_delay_close | 255 server_unblock_lan_zones | server_insecure_lan_zones | 256 server_dns64_prefix | server_dns64_synthall | server_dns64_ignore_aaaa | 257 server_infra_cache_min_rtt | server_harden_algo_downgrade | 258 server_ip_transparent | server_ip_ratelimit | server_ratelimit | 259 server_ip_dscp | 260 server_ip_ratelimit_slabs | server_ratelimit_slabs | 261 server_ip_ratelimit_size | server_ratelimit_size | 262 server_ratelimit_for_domain | 263 server_ratelimit_below_domain | server_ratelimit_factor | 264 server_ip_ratelimit_factor | server_send_client_subnet | 265 server_client_subnet_zone | server_client_subnet_always_forward | 266 server_client_subnet_opcode | 267 server_max_client_subnet_ipv4 | server_max_client_subnet_ipv6 | 268 server_min_client_subnet_ipv4 | server_min_client_subnet_ipv6 | 269 server_max_ecs_tree_size_ipv4 | server_max_ecs_tree_size_ipv6 | 270 server_caps_whitelist | server_cache_max_negative_ttl | 271 server_permit_small_holddown | server_qname_minimisation | 272 server_ip_freebind | server_define_tag | server_local_zone_tag | 273 server_disable_dnssec_lame_check | server_access_control_tag | 274 server_local_zone_override | server_access_control_tag_action | 275 server_access_control_tag_data | server_access_control_view | 276 server_qname_minimisation_strict | server_serve_expired | 277 server_serve_expired_ttl | server_serve_expired_ttl_reset | 278 server_serve_expired_reply_ttl | server_serve_expired_client_timeout | 279 server_fake_dsa | server_log_identity | server_use_systemd | 280 server_response_ip_tag | server_response_ip | server_response_ip_data | 281 server_shm_enable | server_shm_key | server_fake_sha1 | 282 server_hide_trustanchor | server_trust_anchor_signaling | 283 server_root_key_sentinel | 284 server_ipsecmod_enabled | server_ipsecmod_hook | 285 server_ipsecmod_ignore_bogus | server_ipsecmod_max_ttl | 286 server_ipsecmod_whitelist | server_ipsecmod_strict | 287 server_udp_upstream_without_downstream | server_aggressive_nsec | 288 server_tls_cert_bundle | server_tls_additional_port | server_low_rtt | 289 server_fast_server_permil | server_fast_server_num | server_tls_win_cert | 290 server_tcp_connection_limit | server_log_servfail | server_deny_any | 291 server_unknown_server_time_limit | server_log_tag_queryreply | 292 server_stream_wait_size | server_tls_ciphers | 293 server_tls_ciphersuites | server_tls_session_ticket_keys | 294 server_tls_use_sni | server_edns_client_tag | 295 server_edns_client_tag_opcode 296 ; 297 stubstart: VAR_STUB_ZONE 298 { 299 struct config_stub* s; 300 OUTYY(("\nP(stub_zone:)\n")); 301 s = (struct config_stub*)calloc(1, sizeof(struct config_stub)); 302 if(s) { 303 s->next = cfg_parser->cfg->stubs; 304 cfg_parser->cfg->stubs = s; 305 } else 306 yyerror("out of memory"); 307 } 308 ; 309 contents_stub: contents_stub content_stub 310 | ; 311 content_stub: stub_name | stub_host | stub_addr | stub_prime | stub_first | 312 stub_no_cache | stub_ssl_upstream 313 ; 314 forwardstart: VAR_FORWARD_ZONE 315 { 316 struct config_stub* s; 317 OUTYY(("\nP(forward_zone:)\n")); 318 s = (struct config_stub*)calloc(1, sizeof(struct config_stub)); 319 if(s) { 320 s->next = cfg_parser->cfg->forwards; 321 cfg_parser->cfg->forwards = s; 322 } else 323 yyerror("out of memory"); 324 } 325 ; 326 contents_forward: contents_forward content_forward 327 | ; 328 content_forward: forward_name | forward_host | forward_addr | forward_first | 329 forward_no_cache | forward_ssl_upstream 330 ; 331 viewstart: VAR_VIEW 332 { 333 struct config_view* s; 334 OUTYY(("\nP(view:)\n")); 335 s = (struct config_view*)calloc(1, sizeof(struct config_view)); 336 if(s) { 337 s->next = cfg_parser->cfg->views; 338 if(s->next && !s->next->name) 339 yyerror("view without name"); 340 cfg_parser->cfg->views = s; 341 } else 342 yyerror("out of memory"); 343 } 344 ; 345 contents_view: contents_view content_view 346 | ; 347 content_view: view_name | view_local_zone | view_local_data | view_first | 348 view_response_ip | view_response_ip_data | view_local_data_ptr 349 ; 350 authstart: VAR_AUTH_ZONE 351 { 352 struct config_auth* s; 353 OUTYY(("\nP(auth_zone:)\n")); 354 s = (struct config_auth*)calloc(1, sizeof(struct config_auth)); 355 if(s) { 356 s->next = cfg_parser->cfg->auths; 357 cfg_parser->cfg->auths = s; 358 /* defaults for auth zone */ 359 s->for_downstream = 1; 360 s->for_upstream = 1; 361 s->fallback_enabled = 0; 362 s->isrpz = 0; 363 } else 364 yyerror("out of memory"); 365 } 366 ; 367 contents_auth: contents_auth content_auth 368 | ; 369 content_auth: auth_name | auth_zonefile | auth_master | auth_url | 370 auth_for_downstream | auth_for_upstream | auth_fallback_enabled | 371 auth_allow_notify 372 ; 373 374 rpz_tag: VAR_TAGS STRING_ARG 375 { 376 uint8_t* bitlist; 377 size_t len = 0; 378 OUTYY(("P(server_local_zone_tag:%s)\n", $2)); 379 bitlist = config_parse_taglist(cfg_parser->cfg, $2, 380 &len); 381 free($2); 382 if(!bitlist) { 383 yyerror("could not parse tags, (define-tag them first)"); 384 } 385 if(bitlist) { 386 cfg_parser->cfg->auths->rpz_taglist = bitlist; 387 cfg_parser->cfg->auths->rpz_taglistlen = len; 388 389 } 390 } 391 ; 392 393 rpz_action_override: VAR_RPZ_ACTION_OVERRIDE STRING_ARG 394 { 395 OUTYY(("P(rpz_action_override:%s)\n", $2)); 396 if(strcmp($2, "nxdomain")!=0 && strcmp($2, "nodata")!=0 && 397 strcmp($2, "passthru")!=0 && strcmp($2, "drop")!=0 && 398 strcmp($2, "cname")!=0 && strcmp($2, "disabled")!=0) { 399 yyerror("rpz-action-override action: expected nxdomain, " 400 "nodata, passthru, drop, cname or disabled"); 401 free($2); 402 cfg_parser->cfg->auths->rpz_action_override = NULL; 403 } 404 else { 405 cfg_parser->cfg->auths->rpz_action_override = $2; 406 } 407 } 408 ; 409 410 rpz_cname_override: VAR_RPZ_CNAME_OVERRIDE STRING_ARG 411 { 412 OUTYY(("P(rpz_cname_override:%s)\n", $2)); 413 free(cfg_parser->cfg->auths->rpz_cname); 414 cfg_parser->cfg->auths->rpz_cname = $2; 415 } 416 ; 417 418 rpz_log: VAR_RPZ_LOG STRING_ARG 419 { 420 OUTYY(("P(rpz_log:%s)\n", $2)); 421 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 422 yyerror("expected yes or no."); 423 else cfg_parser->cfg->auths->rpz_log = (strcmp($2, "yes")==0); 424 free($2); 425 } 426 ; 427 428 rpz_log_name: VAR_RPZ_LOG_NAME STRING_ARG 429 { 430 OUTYY(("P(rpz_log_name:%s)\n", $2)); 431 free(cfg_parser->cfg->auths->rpz_log_name); 432 cfg_parser->cfg->auths->rpz_log_name = $2; 433 } 434 ; 435 436 rpzstart: VAR_RPZ 437 { 438 struct config_auth* s; 439 OUTYY(("\nP(rpz:)\n")); 440 s = (struct config_auth*)calloc(1, sizeof(struct config_auth)); 441 if(s) { 442 s->next = cfg_parser->cfg->auths; 443 cfg_parser->cfg->auths = s; 444 /* defaults for RPZ auth zone */ 445 s->for_downstream = 0; 446 s->for_upstream = 0; 447 s->fallback_enabled = 0; 448 s->isrpz = 1; 449 } else 450 yyerror("out of memory"); 451 } 452 ; 453 contents_rpz: contents_rpz content_rpz 454 | ; 455 content_rpz: auth_name | auth_zonefile | rpz_tag | auth_master | auth_url | 456 auth_allow_notify | rpz_action_override | rpz_cname_override | 457 rpz_log | rpz_log_name 458 ; 459 server_num_threads: VAR_NUM_THREADS STRING_ARG 460 { 461 OUTYY(("P(server_num_threads:%s)\n", $2)); 462 if(atoi($2) == 0 && strcmp($2, "0") != 0) 463 yyerror("number expected"); 464 else cfg_parser->cfg->num_threads = atoi($2); 465 free($2); 466 } 467 ; 468 server_verbosity: VAR_VERBOSITY STRING_ARG 469 { 470 OUTYY(("P(server_verbosity:%s)\n", $2)); 471 if(atoi($2) == 0 && strcmp($2, "0") != 0) 472 yyerror("number expected"); 473 else cfg_parser->cfg->verbosity = atoi($2); 474 free($2); 475 } 476 ; 477 server_statistics_interval: VAR_STATISTICS_INTERVAL STRING_ARG 478 { 479 OUTYY(("P(server_statistics_interval:%s)\n", $2)); 480 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0) 481 cfg_parser->cfg->stat_interval = 0; 482 else if(atoi($2) == 0) 483 yyerror("number expected"); 484 else cfg_parser->cfg->stat_interval = atoi($2); 485 free($2); 486 } 487 ; 488 server_statistics_cumulative: VAR_STATISTICS_CUMULATIVE STRING_ARG 489 { 490 OUTYY(("P(server_statistics_cumulative:%s)\n", $2)); 491 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 492 yyerror("expected yes or no."); 493 else cfg_parser->cfg->stat_cumulative = (strcmp($2, "yes")==0); 494 free($2); 495 } 496 ; 497 server_extended_statistics: VAR_EXTENDED_STATISTICS STRING_ARG 498 { 499 OUTYY(("P(server_extended_statistics:%s)\n", $2)); 500 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 501 yyerror("expected yes or no."); 502 else cfg_parser->cfg->stat_extended = (strcmp($2, "yes")==0); 503 free($2); 504 } 505 ; 506 server_shm_enable: VAR_SHM_ENABLE STRING_ARG 507 { 508 OUTYY(("P(server_shm_enable:%s)\n", $2)); 509 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 510 yyerror("expected yes or no."); 511 else cfg_parser->cfg->shm_enable = (strcmp($2, "yes")==0); 512 free($2); 513 } 514 ; 515 server_shm_key: VAR_SHM_KEY STRING_ARG 516 { 517 OUTYY(("P(server_shm_key:%s)\n", $2)); 518 if(strcmp($2, "") == 0 || strcmp($2, "0") == 0) 519 cfg_parser->cfg->shm_key = 0; 520 else if(atoi($2) == 0) 521 yyerror("number expected"); 522 else cfg_parser->cfg->shm_key = atoi($2); 523 free($2); 524 } 525 ; 526 server_port: VAR_PORT STRING_ARG 527 { 528 OUTYY(("P(server_port:%s)\n", $2)); 529 if(atoi($2) == 0) 530 yyerror("port number expected"); 531 else cfg_parser->cfg->port = atoi($2); 532 free($2); 533 } 534 ; 535 server_send_client_subnet: VAR_SEND_CLIENT_SUBNET STRING_ARG 536 { 537 #ifdef CLIENT_SUBNET 538 OUTYY(("P(server_send_client_subnet:%s)\n", $2)); 539 if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet, $2)) 540 fatal_exit("out of memory adding client-subnet"); 541 #else 542 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 543 free($2); 544 #endif 545 } 546 ; 547 server_client_subnet_zone: VAR_CLIENT_SUBNET_ZONE STRING_ARG 548 { 549 #ifdef CLIENT_SUBNET 550 OUTYY(("P(server_client_subnet_zone:%s)\n", $2)); 551 if(!cfg_strlist_insert(&cfg_parser->cfg->client_subnet_zone, 552 $2)) 553 fatal_exit("out of memory adding client-subnet-zone"); 554 #else 555 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 556 free($2); 557 #endif 558 } 559 ; 560 server_client_subnet_always_forward: 561 VAR_CLIENT_SUBNET_ALWAYS_FORWARD STRING_ARG 562 { 563 #ifdef CLIENT_SUBNET 564 OUTYY(("P(server_client_subnet_always_forward:%s)\n", $2)); 565 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 566 yyerror("expected yes or no."); 567 else 568 cfg_parser->cfg->client_subnet_always_forward = 569 (strcmp($2, "yes")==0); 570 #else 571 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 572 #endif 573 free($2); 574 } 575 ; 576 server_client_subnet_opcode: VAR_CLIENT_SUBNET_OPCODE STRING_ARG 577 { 578 #ifdef CLIENT_SUBNET 579 OUTYY(("P(client_subnet_opcode:%s)\n", $2)); 580 OUTYY(("P(Deprecated option, ignoring)\n")); 581 #else 582 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 583 #endif 584 free($2); 585 } 586 ; 587 server_max_client_subnet_ipv4: VAR_MAX_CLIENT_SUBNET_IPV4 STRING_ARG 588 { 589 #ifdef CLIENT_SUBNET 590 OUTYY(("P(max_client_subnet_ipv4:%s)\n", $2)); 591 if(atoi($2) == 0 && strcmp($2, "0") != 0) 592 yyerror("IPv4 subnet length expected"); 593 else if (atoi($2) > 32) 594 cfg_parser->cfg->max_client_subnet_ipv4 = 32; 595 else if (atoi($2) < 0) 596 cfg_parser->cfg->max_client_subnet_ipv4 = 0; 597 else cfg_parser->cfg->max_client_subnet_ipv4 = (uint8_t)atoi($2); 598 #else 599 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 600 #endif 601 free($2); 602 } 603 ; 604 server_max_client_subnet_ipv6: VAR_MAX_CLIENT_SUBNET_IPV6 STRING_ARG 605 { 606 #ifdef CLIENT_SUBNET 607 OUTYY(("P(max_client_subnet_ipv6:%s)\n", $2)); 608 if(atoi($2) == 0 && strcmp($2, "0") != 0) 609 yyerror("Ipv6 subnet length expected"); 610 else if (atoi($2) > 128) 611 cfg_parser->cfg->max_client_subnet_ipv6 = 128; 612 else if (atoi($2) < 0) 613 cfg_parser->cfg->max_client_subnet_ipv6 = 0; 614 else cfg_parser->cfg->max_client_subnet_ipv6 = (uint8_t)atoi($2); 615 #else 616 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 617 #endif 618 free($2); 619 } 620 ; 621 server_min_client_subnet_ipv4: VAR_MIN_CLIENT_SUBNET_IPV4 STRING_ARG 622 { 623 #ifdef CLIENT_SUBNET 624 OUTYY(("P(min_client_subnet_ipv4:%s)\n", $2)); 625 if(atoi($2) == 0 && strcmp($2, "0") != 0) 626 yyerror("IPv4 subnet length expected"); 627 else if (atoi($2) > 32) 628 cfg_parser->cfg->min_client_subnet_ipv4 = 32; 629 else if (atoi($2) < 0) 630 cfg_parser->cfg->min_client_subnet_ipv4 = 0; 631 else cfg_parser->cfg->min_client_subnet_ipv4 = (uint8_t)atoi($2); 632 #else 633 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 634 #endif 635 free($2); 636 } 637 ; 638 server_min_client_subnet_ipv6: VAR_MIN_CLIENT_SUBNET_IPV6 STRING_ARG 639 { 640 #ifdef CLIENT_SUBNET 641 OUTYY(("P(min_client_subnet_ipv6:%s)\n", $2)); 642 if(atoi($2) == 0 && strcmp($2, "0") != 0) 643 yyerror("Ipv6 subnet length expected"); 644 else if (atoi($2) > 128) 645 cfg_parser->cfg->min_client_subnet_ipv6 = 128; 646 else if (atoi($2) < 0) 647 cfg_parser->cfg->min_client_subnet_ipv6 = 0; 648 else cfg_parser->cfg->min_client_subnet_ipv6 = (uint8_t)atoi($2); 649 #else 650 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 651 #endif 652 free($2); 653 } 654 ; 655 server_max_ecs_tree_size_ipv4: VAR_MAX_ECS_TREE_SIZE_IPV4 STRING_ARG 656 { 657 #ifdef CLIENT_SUBNET 658 OUTYY(("P(max_ecs_tree_size_ipv4:%s)\n", $2)); 659 if(atoi($2) == 0 && strcmp($2, "0") != 0) 660 yyerror("IPv4 ECS tree size expected"); 661 else if (atoi($2) < 0) 662 cfg_parser->cfg->max_ecs_tree_size_ipv4 = 0; 663 else cfg_parser->cfg->max_ecs_tree_size_ipv4 = (uint32_t)atoi($2); 664 #else 665 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 666 #endif 667 free($2); 668 } 669 ; 670 server_max_ecs_tree_size_ipv6: VAR_MAX_ECS_TREE_SIZE_IPV6 STRING_ARG 671 { 672 #ifdef CLIENT_SUBNET 673 OUTYY(("P(max_ecs_tree_size_ipv6:%s)\n", $2)); 674 if(atoi($2) == 0 && strcmp($2, "0") != 0) 675 yyerror("IPv6 ECS tree size expected"); 676 else if (atoi($2) < 0) 677 cfg_parser->cfg->max_ecs_tree_size_ipv6 = 0; 678 else cfg_parser->cfg->max_ecs_tree_size_ipv6 = (uint32_t)atoi($2); 679 #else 680 OUTYY(("P(Compiled without edns subnet option, ignoring)\n")); 681 #endif 682 free($2); 683 } 684 ; 685 server_interface: VAR_INTERFACE STRING_ARG 686 { 687 OUTYY(("P(server_interface:%s)\n", $2)); 688 if(cfg_parser->cfg->num_ifs == 0) 689 cfg_parser->cfg->ifs = calloc(1, sizeof(char*)); 690 else cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs, 691 (cfg_parser->cfg->num_ifs+1)*sizeof(char*)); 692 if(!cfg_parser->cfg->ifs) 693 yyerror("out of memory"); 694 else 695 cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = $2; 696 } 697 ; 698 server_outgoing_interface: VAR_OUTGOING_INTERFACE STRING_ARG 699 { 700 OUTYY(("P(server_outgoing_interface:%s)\n", $2)); 701 if(cfg_parser->cfg->num_out_ifs == 0) 702 cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*)); 703 else cfg_parser->cfg->out_ifs = realloc( 704 cfg_parser->cfg->out_ifs, 705 (cfg_parser->cfg->num_out_ifs+1)*sizeof(char*)); 706 if(!cfg_parser->cfg->out_ifs) 707 yyerror("out of memory"); 708 else 709 cfg_parser->cfg->out_ifs[ 710 cfg_parser->cfg->num_out_ifs++] = $2; 711 } 712 ; 713 server_outgoing_range: VAR_OUTGOING_RANGE STRING_ARG 714 { 715 OUTYY(("P(server_outgoing_range:%s)\n", $2)); 716 if(atoi($2) == 0) 717 yyerror("number expected"); 718 else cfg_parser->cfg->outgoing_num_ports = atoi($2); 719 free($2); 720 } 721 ; 722 server_outgoing_port_permit: VAR_OUTGOING_PORT_PERMIT STRING_ARG 723 { 724 OUTYY(("P(server_outgoing_port_permit:%s)\n", $2)); 725 if(!cfg_mark_ports($2, 1, 726 cfg_parser->cfg->outgoing_avail_ports, 65536)) 727 yyerror("port number or range (\"low-high\") expected"); 728 free($2); 729 } 730 ; 731 server_outgoing_port_avoid: VAR_OUTGOING_PORT_AVOID STRING_ARG 732 { 733 OUTYY(("P(server_outgoing_port_avoid:%s)\n", $2)); 734 if(!cfg_mark_ports($2, 0, 735 cfg_parser->cfg->outgoing_avail_ports, 65536)) 736 yyerror("port number or range (\"low-high\") expected"); 737 free($2); 738 } 739 ; 740 server_outgoing_num_tcp: VAR_OUTGOING_NUM_TCP STRING_ARG 741 { 742 OUTYY(("P(server_outgoing_num_tcp:%s)\n", $2)); 743 if(atoi($2) == 0 && strcmp($2, "0") != 0) 744 yyerror("number expected"); 745 else cfg_parser->cfg->outgoing_num_tcp = atoi($2); 746 free($2); 747 } 748 ; 749 server_incoming_num_tcp: VAR_INCOMING_NUM_TCP STRING_ARG 750 { 751 OUTYY(("P(server_incoming_num_tcp:%s)\n", $2)); 752 if(atoi($2) == 0 && strcmp($2, "0") != 0) 753 yyerror("number expected"); 754 else cfg_parser->cfg->incoming_num_tcp = atoi($2); 755 free($2); 756 } 757 ; 758 server_interface_automatic: VAR_INTERFACE_AUTOMATIC STRING_ARG 759 { 760 OUTYY(("P(server_interface_automatic:%s)\n", $2)); 761 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 762 yyerror("expected yes or no."); 763 else cfg_parser->cfg->if_automatic = (strcmp($2, "yes")==0); 764 free($2); 765 } 766 ; 767 server_do_ip4: VAR_DO_IP4 STRING_ARG 768 { 769 OUTYY(("P(server_do_ip4:%s)\n", $2)); 770 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 771 yyerror("expected yes or no."); 772 else cfg_parser->cfg->do_ip4 = (strcmp($2, "yes")==0); 773 free($2); 774 } 775 ; 776 server_do_ip6: VAR_DO_IP6 STRING_ARG 777 { 778 OUTYY(("P(server_do_ip6:%s)\n", $2)); 779 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 780 yyerror("expected yes or no."); 781 else cfg_parser->cfg->do_ip6 = (strcmp($2, "yes")==0); 782 free($2); 783 } 784 ; 785 server_do_udp: VAR_DO_UDP STRING_ARG 786 { 787 OUTYY(("P(server_do_udp:%s)\n", $2)); 788 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 789 yyerror("expected yes or no."); 790 else cfg_parser->cfg->do_udp = (strcmp($2, "yes")==0); 791 free($2); 792 } 793 ; 794 server_do_tcp: VAR_DO_TCP STRING_ARG 795 { 796 OUTYY(("P(server_do_tcp:%s)\n", $2)); 797 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 798 yyerror("expected yes or no."); 799 else cfg_parser->cfg->do_tcp = (strcmp($2, "yes")==0); 800 free($2); 801 } 802 ; 803 server_prefer_ip4: VAR_PREFER_IP4 STRING_ARG 804 { 805 OUTYY(("P(server_prefer_ip4:%s)\n", $2)); 806 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 807 yyerror("expected yes or no."); 808 else cfg_parser->cfg->prefer_ip4 = (strcmp($2, "yes")==0); 809 free($2); 810 } 811 ; 812 server_prefer_ip6: VAR_PREFER_IP6 STRING_ARG 813 { 814 OUTYY(("P(server_prefer_ip6:%s)\n", $2)); 815 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 816 yyerror("expected yes or no."); 817 else cfg_parser->cfg->prefer_ip6 = (strcmp($2, "yes")==0); 818 free($2); 819 } 820 ; 821 server_tcp_mss: VAR_TCP_MSS STRING_ARG 822 { 823 OUTYY(("P(server_tcp_mss:%s)\n", $2)); 824 if(atoi($2) == 0 && strcmp($2, "0") != 0) 825 yyerror("number expected"); 826 else cfg_parser->cfg->tcp_mss = atoi($2); 827 free($2); 828 } 829 ; 830 server_outgoing_tcp_mss: VAR_OUTGOING_TCP_MSS STRING_ARG 831 { 832 OUTYY(("P(server_outgoing_tcp_mss:%s)\n", $2)); 833 if(atoi($2) == 0 && strcmp($2, "0") != 0) 834 yyerror("number expected"); 835 else cfg_parser->cfg->outgoing_tcp_mss = atoi($2); 836 free($2); 837 } 838 ; 839 server_tcp_idle_timeout: VAR_TCP_IDLE_TIMEOUT STRING_ARG 840 { 841 OUTYY(("P(server_tcp_idle_timeout:%s)\n", $2)); 842 if(atoi($2) == 0 && strcmp($2, "0") != 0) 843 yyerror("number expected"); 844 else if (atoi($2) > 120000) 845 cfg_parser->cfg->tcp_idle_timeout = 120000; 846 else if (atoi($2) < 1) 847 cfg_parser->cfg->tcp_idle_timeout = 1; 848 else cfg_parser->cfg->tcp_idle_timeout = atoi($2); 849 free($2); 850 } 851 ; 852 server_tcp_keepalive: VAR_EDNS_TCP_KEEPALIVE STRING_ARG 853 { 854 OUTYY(("P(server_tcp_keepalive:%s)\n", $2)); 855 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 856 yyerror("expected yes or no."); 857 else cfg_parser->cfg->do_tcp_keepalive = (strcmp($2, "yes")==0); 858 free($2); 859 } 860 ; 861 server_tcp_keepalive_timeout: VAR_EDNS_TCP_KEEPALIVE_TIMEOUT STRING_ARG 862 { 863 OUTYY(("P(server_tcp_keepalive_timeout:%s)\n", $2)); 864 if(atoi($2) == 0 && strcmp($2, "0") != 0) 865 yyerror("number expected"); 866 else if (atoi($2) > 6553500) 867 cfg_parser->cfg->tcp_keepalive_timeout = 6553500; 868 else if (atoi($2) < 1) 869 cfg_parser->cfg->tcp_keepalive_timeout = 0; 870 else cfg_parser->cfg->tcp_keepalive_timeout = atoi($2); 871 free($2); 872 } 873 ; 874 server_tcp_upstream: VAR_TCP_UPSTREAM STRING_ARG 875 { 876 OUTYY(("P(server_tcp_upstream:%s)\n", $2)); 877 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 878 yyerror("expected yes or no."); 879 else cfg_parser->cfg->tcp_upstream = (strcmp($2, "yes")==0); 880 free($2); 881 } 882 ; 883 server_udp_upstream_without_downstream: VAR_UDP_UPSTREAM_WITHOUT_DOWNSTREAM STRING_ARG 884 { 885 OUTYY(("P(server_udp_upstream_without_downstream:%s)\n", $2)); 886 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 887 yyerror("expected yes or no."); 888 else cfg_parser->cfg->udp_upstream_without_downstream = (strcmp($2, "yes")==0); 889 free($2); 890 } 891 ; 892 server_ssl_upstream: VAR_SSL_UPSTREAM STRING_ARG 893 { 894 OUTYY(("P(server_ssl_upstream:%s)\n", $2)); 895 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 896 yyerror("expected yes or no."); 897 else cfg_parser->cfg->ssl_upstream = (strcmp($2, "yes")==0); 898 free($2); 899 } 900 ; 901 server_ssl_service_key: VAR_SSL_SERVICE_KEY STRING_ARG 902 { 903 OUTYY(("P(server_ssl_service_key:%s)\n", $2)); 904 free(cfg_parser->cfg->ssl_service_key); 905 cfg_parser->cfg->ssl_service_key = $2; 906 } 907 ; 908 server_ssl_service_pem: VAR_SSL_SERVICE_PEM STRING_ARG 909 { 910 OUTYY(("P(server_ssl_service_pem:%s)\n", $2)); 911 free(cfg_parser->cfg->ssl_service_pem); 912 cfg_parser->cfg->ssl_service_pem = $2; 913 } 914 ; 915 server_ssl_port: VAR_SSL_PORT STRING_ARG 916 { 917 OUTYY(("P(server_ssl_port:%s)\n", $2)); 918 if(atoi($2) == 0) 919 yyerror("port number expected"); 920 else cfg_parser->cfg->ssl_port = atoi($2); 921 free($2); 922 } 923 ; 924 server_tls_cert_bundle: VAR_TLS_CERT_BUNDLE STRING_ARG 925 { 926 OUTYY(("P(server_tls_cert_bundle:%s)\n", $2)); 927 free(cfg_parser->cfg->tls_cert_bundle); 928 cfg_parser->cfg->tls_cert_bundle = $2; 929 } 930 ; 931 server_tls_win_cert: VAR_TLS_WIN_CERT STRING_ARG 932 { 933 OUTYY(("P(server_tls_win_cert:%s)\n", $2)); 934 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 935 yyerror("expected yes or no."); 936 else cfg_parser->cfg->tls_win_cert = (strcmp($2, "yes")==0); 937 free($2); 938 } 939 ; 940 server_tls_additional_port: VAR_TLS_ADDITIONAL_PORT STRING_ARG 941 { 942 OUTYY(("P(server_tls_additional_port:%s)\n", $2)); 943 if(!cfg_strlist_insert(&cfg_parser->cfg->tls_additional_port, 944 $2)) 945 yyerror("out of memory"); 946 } 947 ; 948 server_tls_ciphers: VAR_TLS_CIPHERS STRING_ARG 949 { 950 OUTYY(("P(server_tls_ciphers:%s)\n", $2)); 951 free(cfg_parser->cfg->tls_ciphers); 952 cfg_parser->cfg->tls_ciphers = $2; 953 } 954 ; 955 server_tls_ciphersuites: VAR_TLS_CIPHERSUITES STRING_ARG 956 { 957 OUTYY(("P(server_tls_ciphersuites:%s)\n", $2)); 958 free(cfg_parser->cfg->tls_ciphersuites); 959 cfg_parser->cfg->tls_ciphersuites = $2; 960 } 961 ; 962 server_tls_session_ticket_keys: VAR_TLS_SESSION_TICKET_KEYS STRING_ARG 963 { 964 OUTYY(("P(server_tls_session_ticket_keys:%s)\n", $2)); 965 if(!cfg_strlist_append(&cfg_parser->cfg->tls_session_ticket_keys, 966 $2)) 967 yyerror("out of memory"); 968 } 969 ; 970 server_tls_use_sni: VAR_TLS_USE_SNI STRING_ARG 971 { 972 OUTYY(("P(server_tls_use_sni:%s)\n", $2)); 973 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 974 yyerror("expected yes or no."); 975 else cfg_parser->cfg->tls_use_sni = (strcmp($2, "yes")==0); 976 free($2); 977 } 978 ; 979 server_https_port: VAR_HTTPS_PORT STRING_ARG 980 { 981 OUTYY(("P(server_https_port:%s)\n", $2)); 982 if(atoi($2) == 0) 983 yyerror("port number expected"); 984 else cfg_parser->cfg->https_port = atoi($2); 985 }; 986 server_http_endpoint: VAR_HTTP_ENDPOINT STRING_ARG 987 { 988 OUTYY(("P(server_http_endpoint:%s)\n", $2)); 989 free(cfg_parser->cfg->http_endpoint); 990 if($2 && $2[0] != '/') { 991 cfg_parser->cfg->http_endpoint = malloc(strlen($2)+2); 992 if(!cfg_parser->cfg->http_endpoint) 993 yyerror("out of memory"); 994 cfg_parser->cfg->http_endpoint[0] = '/'; 995 memmove(cfg_parser->cfg->http_endpoint+1, $2, 996 strlen($2)+1); 997 free($2); 998 } else { 999 cfg_parser->cfg->http_endpoint = $2; 1000 } 1001 }; 1002 server_http_max_streams: VAR_HTTP_MAX_STREAMS STRING_ARG 1003 { 1004 OUTYY(("P(server_http_max_streams:%s)\n", $2)); 1005 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1006 yyerror("number expected"); 1007 else cfg_parser->cfg->http_max_streams = atoi($2); 1008 free($2); 1009 }; 1010 server_http_query_buffer_size: VAR_HTTP_QUERY_BUFFER_SIZE STRING_ARG 1011 { 1012 OUTYY(("P(server_http_query_buffer_size:%s)\n", $2)); 1013 if(!cfg_parse_memsize($2, 1014 &cfg_parser->cfg->http_query_buffer_size)) 1015 yyerror("memory size expected"); 1016 free($2); 1017 }; 1018 server_http_response_buffer_size: VAR_HTTP_RESPONSE_BUFFER_SIZE STRING_ARG 1019 { 1020 OUTYY(("P(server_http_response_buffer_size:%s)\n", $2)); 1021 if(!cfg_parse_memsize($2, 1022 &cfg_parser->cfg->http_response_buffer_size)) 1023 yyerror("memory size expected"); 1024 free($2); 1025 }; 1026 server_http_nodelay: VAR_HTTP_NODELAY STRING_ARG 1027 { 1028 OUTYY(("P(server_http_nodelay:%s)\n", $2)); 1029 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1030 yyerror("expected yes or no."); 1031 else cfg_parser->cfg->http_nodelay = (strcmp($2, "yes")==0); 1032 free($2); 1033 }; 1034 server_use_systemd: VAR_USE_SYSTEMD STRING_ARG 1035 { 1036 OUTYY(("P(server_use_systemd:%s)\n", $2)); 1037 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1038 yyerror("expected yes or no."); 1039 else cfg_parser->cfg->use_systemd = (strcmp($2, "yes")==0); 1040 free($2); 1041 } 1042 ; 1043 server_do_daemonize: VAR_DO_DAEMONIZE STRING_ARG 1044 { 1045 OUTYY(("P(server_do_daemonize:%s)\n", $2)); 1046 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1047 yyerror("expected yes or no."); 1048 else cfg_parser->cfg->do_daemonize = (strcmp($2, "yes")==0); 1049 free($2); 1050 } 1051 ; 1052 server_use_syslog: VAR_USE_SYSLOG STRING_ARG 1053 { 1054 OUTYY(("P(server_use_syslog:%s)\n", $2)); 1055 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1056 yyerror("expected yes or no."); 1057 else cfg_parser->cfg->use_syslog = (strcmp($2, "yes")==0); 1058 #if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS) 1059 if(strcmp($2, "yes") == 0) 1060 yyerror("no syslog services are available. " 1061 "(reconfigure and compile to add)"); 1062 #endif 1063 free($2); 1064 } 1065 ; 1066 server_log_time_ascii: VAR_LOG_TIME_ASCII STRING_ARG 1067 { 1068 OUTYY(("P(server_log_time_ascii:%s)\n", $2)); 1069 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1070 yyerror("expected yes or no."); 1071 else cfg_parser->cfg->log_time_ascii = (strcmp($2, "yes")==0); 1072 free($2); 1073 } 1074 ; 1075 server_log_queries: VAR_LOG_QUERIES STRING_ARG 1076 { 1077 OUTYY(("P(server_log_queries:%s)\n", $2)); 1078 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1079 yyerror("expected yes or no."); 1080 else cfg_parser->cfg->log_queries = (strcmp($2, "yes")==0); 1081 free($2); 1082 } 1083 ; 1084 server_log_replies: VAR_LOG_REPLIES STRING_ARG 1085 { 1086 OUTYY(("P(server_log_replies:%s)\n", $2)); 1087 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1088 yyerror("expected yes or no."); 1089 else cfg_parser->cfg->log_replies = (strcmp($2, "yes")==0); 1090 free($2); 1091 } 1092 ; 1093 server_log_tag_queryreply: VAR_LOG_TAG_QUERYREPLY STRING_ARG 1094 { 1095 OUTYY(("P(server_log_tag_queryreply:%s)\n", $2)); 1096 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1097 yyerror("expected yes or no."); 1098 else cfg_parser->cfg->log_tag_queryreply = (strcmp($2, "yes")==0); 1099 free($2); 1100 } 1101 ; 1102 server_log_servfail: VAR_LOG_SERVFAIL STRING_ARG 1103 { 1104 OUTYY(("P(server_log_servfail:%s)\n", $2)); 1105 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1106 yyerror("expected yes or no."); 1107 else cfg_parser->cfg->log_servfail = (strcmp($2, "yes")==0); 1108 free($2); 1109 } 1110 ; 1111 server_log_local_actions: VAR_LOG_LOCAL_ACTIONS STRING_ARG 1112 { 1113 OUTYY(("P(server_log_local_actions:%s)\n", $2)); 1114 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1115 yyerror("expected yes or no."); 1116 else cfg_parser->cfg->log_local_actions = (strcmp($2, "yes")==0); 1117 free($2); 1118 } 1119 ; 1120 server_chroot: VAR_CHROOT STRING_ARG 1121 { 1122 OUTYY(("P(server_chroot:%s)\n", $2)); 1123 free(cfg_parser->cfg->chrootdir); 1124 cfg_parser->cfg->chrootdir = $2; 1125 } 1126 ; 1127 server_username: VAR_USERNAME STRING_ARG 1128 { 1129 OUTYY(("P(server_username:%s)\n", $2)); 1130 free(cfg_parser->cfg->username); 1131 cfg_parser->cfg->username = $2; 1132 } 1133 ; 1134 server_directory: VAR_DIRECTORY STRING_ARG 1135 { 1136 OUTYY(("P(server_directory:%s)\n", $2)); 1137 free(cfg_parser->cfg->directory); 1138 cfg_parser->cfg->directory = $2; 1139 /* change there right away for includes relative to this */ 1140 if($2[0]) { 1141 char* d; 1142 #ifdef UB_ON_WINDOWS 1143 w_config_adjust_directory(cfg_parser->cfg); 1144 #endif 1145 d = cfg_parser->cfg->directory; 1146 /* adjust directory if we have already chroot, 1147 * like, we reread after sighup */ 1148 if(cfg_parser->chroot && cfg_parser->chroot[0] && 1149 strncmp(d, cfg_parser->chroot, strlen( 1150 cfg_parser->chroot)) == 0) 1151 d += strlen(cfg_parser->chroot); 1152 if(d[0]) { 1153 if(chdir(d)) 1154 log_err("cannot chdir to directory: %s (%s)", 1155 d, strerror(errno)); 1156 } 1157 } 1158 } 1159 ; 1160 server_logfile: VAR_LOGFILE STRING_ARG 1161 { 1162 OUTYY(("P(server_logfile:%s)\n", $2)); 1163 free(cfg_parser->cfg->logfile); 1164 cfg_parser->cfg->logfile = $2; 1165 cfg_parser->cfg->use_syslog = 0; 1166 } 1167 ; 1168 server_pidfile: VAR_PIDFILE STRING_ARG 1169 { 1170 OUTYY(("P(server_pidfile:%s)\n", $2)); 1171 free(cfg_parser->cfg->pidfile); 1172 cfg_parser->cfg->pidfile = $2; 1173 } 1174 ; 1175 server_root_hints: VAR_ROOT_HINTS STRING_ARG 1176 { 1177 OUTYY(("P(server_root_hints:%s)\n", $2)); 1178 if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, $2)) 1179 yyerror("out of memory"); 1180 } 1181 ; 1182 server_dlv_anchor_file: VAR_DLV_ANCHOR_FILE STRING_ARG 1183 { 1184 OUTYY(("P(server_dlv_anchor_file:%s)\n", $2)); 1185 log_warn("option dlv-anchor-file ignored: DLV is decommissioned"); 1186 free($2); 1187 } 1188 ; 1189 server_dlv_anchor: VAR_DLV_ANCHOR STRING_ARG 1190 { 1191 OUTYY(("P(server_dlv_anchor:%s)\n", $2)); 1192 log_warn("option dlv-anchor ignored: DLV is decommissioned"); 1193 free($2); 1194 } 1195 ; 1196 server_auto_trust_anchor_file: VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG 1197 { 1198 OUTYY(("P(server_auto_trust_anchor_file:%s)\n", $2)); 1199 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1200 auto_trust_anchor_file_list, $2)) 1201 yyerror("out of memory"); 1202 } 1203 ; 1204 server_trust_anchor_file: VAR_TRUST_ANCHOR_FILE STRING_ARG 1205 { 1206 OUTYY(("P(server_trust_anchor_file:%s)\n", $2)); 1207 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1208 trust_anchor_file_list, $2)) 1209 yyerror("out of memory"); 1210 } 1211 ; 1212 server_trusted_keys_file: VAR_TRUSTED_KEYS_FILE STRING_ARG 1213 { 1214 OUTYY(("P(server_trusted_keys_file:%s)\n", $2)); 1215 if(!cfg_strlist_insert(&cfg_parser->cfg-> 1216 trusted_keys_file_list, $2)) 1217 yyerror("out of memory"); 1218 } 1219 ; 1220 server_trust_anchor: VAR_TRUST_ANCHOR STRING_ARG 1221 { 1222 OUTYY(("P(server_trust_anchor:%s)\n", $2)); 1223 if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, $2)) 1224 yyerror("out of memory"); 1225 } 1226 ; 1227 server_trust_anchor_signaling: VAR_TRUST_ANCHOR_SIGNALING STRING_ARG 1228 { 1229 OUTYY(("P(server_trust_anchor_signaling:%s)\n", $2)); 1230 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1231 yyerror("expected yes or no."); 1232 else 1233 cfg_parser->cfg->trust_anchor_signaling = 1234 (strcmp($2, "yes")==0); 1235 free($2); 1236 } 1237 ; 1238 server_root_key_sentinel: VAR_ROOT_KEY_SENTINEL STRING_ARG 1239 { 1240 OUTYY(("P(server_root_key_sentinel:%s)\n", $2)); 1241 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1242 yyerror("expected yes or no."); 1243 else 1244 cfg_parser->cfg->root_key_sentinel = 1245 (strcmp($2, "yes")==0); 1246 free($2); 1247 } 1248 ; 1249 server_domain_insecure: VAR_DOMAIN_INSECURE STRING_ARG 1250 { 1251 OUTYY(("P(server_domain_insecure:%s)\n", $2)); 1252 if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, $2)) 1253 yyerror("out of memory"); 1254 } 1255 ; 1256 server_hide_identity: VAR_HIDE_IDENTITY STRING_ARG 1257 { 1258 OUTYY(("P(server_hide_identity:%s)\n", $2)); 1259 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1260 yyerror("expected yes or no."); 1261 else cfg_parser->cfg->hide_identity = (strcmp($2, "yes")==0); 1262 free($2); 1263 } 1264 ; 1265 server_hide_version: VAR_HIDE_VERSION STRING_ARG 1266 { 1267 OUTYY(("P(server_hide_version:%s)\n", $2)); 1268 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1269 yyerror("expected yes or no."); 1270 else cfg_parser->cfg->hide_version = (strcmp($2, "yes")==0); 1271 free($2); 1272 } 1273 ; 1274 server_hide_trustanchor: VAR_HIDE_TRUSTANCHOR STRING_ARG 1275 { 1276 OUTYY(("P(server_hide_trustanchor:%s)\n", $2)); 1277 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1278 yyerror("expected yes or no."); 1279 else cfg_parser->cfg->hide_trustanchor = (strcmp($2, "yes")==0); 1280 free($2); 1281 } 1282 ; 1283 server_identity: VAR_IDENTITY STRING_ARG 1284 { 1285 OUTYY(("P(server_identity:%s)\n", $2)); 1286 free(cfg_parser->cfg->identity); 1287 cfg_parser->cfg->identity = $2; 1288 } 1289 ; 1290 server_version: VAR_VERSION STRING_ARG 1291 { 1292 OUTYY(("P(server_version:%s)\n", $2)); 1293 free(cfg_parser->cfg->version); 1294 cfg_parser->cfg->version = $2; 1295 } 1296 ; 1297 server_so_rcvbuf: VAR_SO_RCVBUF STRING_ARG 1298 { 1299 OUTYY(("P(server_so_rcvbuf:%s)\n", $2)); 1300 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_rcvbuf)) 1301 yyerror("buffer size expected"); 1302 free($2); 1303 } 1304 ; 1305 server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG 1306 { 1307 OUTYY(("P(server_so_sndbuf:%s)\n", $2)); 1308 if(!cfg_parse_memsize($2, &cfg_parser->cfg->so_sndbuf)) 1309 yyerror("buffer size expected"); 1310 free($2); 1311 } 1312 ; 1313 server_so_reuseport: VAR_SO_REUSEPORT STRING_ARG 1314 { 1315 OUTYY(("P(server_so_reuseport:%s)\n", $2)); 1316 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1317 yyerror("expected yes or no."); 1318 else cfg_parser->cfg->so_reuseport = 1319 (strcmp($2, "yes")==0); 1320 free($2); 1321 } 1322 ; 1323 server_ip_transparent: VAR_IP_TRANSPARENT STRING_ARG 1324 { 1325 OUTYY(("P(server_ip_transparent:%s)\n", $2)); 1326 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1327 yyerror("expected yes or no."); 1328 else cfg_parser->cfg->ip_transparent = 1329 (strcmp($2, "yes")==0); 1330 free($2); 1331 } 1332 ; 1333 server_ip_freebind: VAR_IP_FREEBIND STRING_ARG 1334 { 1335 OUTYY(("P(server_ip_freebind:%s)\n", $2)); 1336 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1337 yyerror("expected yes or no."); 1338 else cfg_parser->cfg->ip_freebind = 1339 (strcmp($2, "yes")==0); 1340 free($2); 1341 } 1342 ; 1343 server_ip_dscp: VAR_IP_DSCP STRING_ARG 1344 { 1345 OUTYY(("P(server_ip_dscp:%s)\n", $2)); 1346 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1347 yyerror("number expected"); 1348 else if (atoi($2) > 63) 1349 yyerror("value too large (max 63)"); 1350 else if (atoi($2) < 0) 1351 yyerror("value too small (min 0)"); 1352 else 1353 cfg_parser->cfg->ip_dscp = atoi($2); 1354 free($2); 1355 } 1356 ; 1357 server_stream_wait_size: VAR_STREAM_WAIT_SIZE STRING_ARG 1358 { 1359 OUTYY(("P(server_stream_wait_size:%s)\n", $2)); 1360 if(!cfg_parse_memsize($2, &cfg_parser->cfg->stream_wait_size)) 1361 yyerror("memory size expected"); 1362 free($2); 1363 } 1364 ; 1365 server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG 1366 { 1367 OUTYY(("P(server_edns_buffer_size:%s)\n", $2)); 1368 if(atoi($2) == 0) 1369 yyerror("number expected"); 1370 else if (atoi($2) < 12) 1371 yyerror("edns buffer size too small"); 1372 else if (atoi($2) > 65535) 1373 cfg_parser->cfg->edns_buffer_size = 65535; 1374 else cfg_parser->cfg->edns_buffer_size = atoi($2); 1375 free($2); 1376 } 1377 ; 1378 server_msg_buffer_size: VAR_MSG_BUFFER_SIZE STRING_ARG 1379 { 1380 OUTYY(("P(server_msg_buffer_size:%s)\n", $2)); 1381 if(atoi($2) == 0) 1382 yyerror("number expected"); 1383 else if (atoi($2) < 4096) 1384 yyerror("message buffer size too small (use 4096)"); 1385 else cfg_parser->cfg->msg_buffer_size = atoi($2); 1386 free($2); 1387 } 1388 ; 1389 server_msg_cache_size: VAR_MSG_CACHE_SIZE STRING_ARG 1390 { 1391 OUTYY(("P(server_msg_cache_size:%s)\n", $2)); 1392 if(!cfg_parse_memsize($2, &cfg_parser->cfg->msg_cache_size)) 1393 yyerror("memory size expected"); 1394 free($2); 1395 } 1396 ; 1397 server_msg_cache_slabs: VAR_MSG_CACHE_SLABS STRING_ARG 1398 { 1399 OUTYY(("P(server_msg_cache_slabs:%s)\n", $2)); 1400 if(atoi($2) == 0) 1401 yyerror("number expected"); 1402 else { 1403 cfg_parser->cfg->msg_cache_slabs = atoi($2); 1404 if(!is_pow2(cfg_parser->cfg->msg_cache_slabs)) 1405 yyerror("must be a power of 2"); 1406 } 1407 free($2); 1408 } 1409 ; 1410 server_num_queries_per_thread: VAR_NUM_QUERIES_PER_THREAD STRING_ARG 1411 { 1412 OUTYY(("P(server_num_queries_per_thread:%s)\n", $2)); 1413 if(atoi($2) == 0) 1414 yyerror("number expected"); 1415 else cfg_parser->cfg->num_queries_per_thread = atoi($2); 1416 free($2); 1417 } 1418 ; 1419 server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG 1420 { 1421 OUTYY(("P(server_jostle_timeout:%s)\n", $2)); 1422 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1423 yyerror("number expected"); 1424 else cfg_parser->cfg->jostle_time = atoi($2); 1425 free($2); 1426 } 1427 ; 1428 server_delay_close: VAR_DELAY_CLOSE STRING_ARG 1429 { 1430 OUTYY(("P(server_delay_close:%s)\n", $2)); 1431 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1432 yyerror("number expected"); 1433 else cfg_parser->cfg->delay_close = atoi($2); 1434 free($2); 1435 } 1436 ; 1437 server_unblock_lan_zones: VAR_UNBLOCK_LAN_ZONES STRING_ARG 1438 { 1439 OUTYY(("P(server_unblock_lan_zones:%s)\n", $2)); 1440 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1441 yyerror("expected yes or no."); 1442 else cfg_parser->cfg->unblock_lan_zones = 1443 (strcmp($2, "yes")==0); 1444 free($2); 1445 } 1446 ; 1447 server_insecure_lan_zones: VAR_INSECURE_LAN_ZONES STRING_ARG 1448 { 1449 OUTYY(("P(server_insecure_lan_zones:%s)\n", $2)); 1450 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1451 yyerror("expected yes or no."); 1452 else cfg_parser->cfg->insecure_lan_zones = 1453 (strcmp($2, "yes")==0); 1454 free($2); 1455 } 1456 ; 1457 server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG 1458 { 1459 OUTYY(("P(server_rrset_cache_size:%s)\n", $2)); 1460 if(!cfg_parse_memsize($2, &cfg_parser->cfg->rrset_cache_size)) 1461 yyerror("memory size expected"); 1462 free($2); 1463 } 1464 ; 1465 server_rrset_cache_slabs: VAR_RRSET_CACHE_SLABS STRING_ARG 1466 { 1467 OUTYY(("P(server_rrset_cache_slabs:%s)\n", $2)); 1468 if(atoi($2) == 0) 1469 yyerror("number expected"); 1470 else { 1471 cfg_parser->cfg->rrset_cache_slabs = atoi($2); 1472 if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs)) 1473 yyerror("must be a power of 2"); 1474 } 1475 free($2); 1476 } 1477 ; 1478 server_infra_host_ttl: VAR_INFRA_HOST_TTL STRING_ARG 1479 { 1480 OUTYY(("P(server_infra_host_ttl:%s)\n", $2)); 1481 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1482 yyerror("number expected"); 1483 else cfg_parser->cfg->host_ttl = atoi($2); 1484 free($2); 1485 } 1486 ; 1487 server_infra_lame_ttl: VAR_INFRA_LAME_TTL STRING_ARG 1488 { 1489 OUTYY(("P(server_infra_lame_ttl:%s)\n", $2)); 1490 verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option " 1491 "removed, use infra-host-ttl)", $2); 1492 free($2); 1493 } 1494 ; 1495 server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING_ARG 1496 { 1497 OUTYY(("P(server_infra_cache_numhosts:%s)\n", $2)); 1498 if(atoi($2) == 0) 1499 yyerror("number expected"); 1500 else cfg_parser->cfg->infra_cache_numhosts = atoi($2); 1501 free($2); 1502 } 1503 ; 1504 server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING_ARG 1505 { 1506 OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2)); 1507 verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s " 1508 "(option removed, use infra-cache-numhosts)", $2); 1509 free($2); 1510 } 1511 ; 1512 server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG 1513 { 1514 OUTYY(("P(server_infra_cache_slabs:%s)\n", $2)); 1515 if(atoi($2) == 0) 1516 yyerror("number expected"); 1517 else { 1518 cfg_parser->cfg->infra_cache_slabs = atoi($2); 1519 if(!is_pow2(cfg_parser->cfg->infra_cache_slabs)) 1520 yyerror("must be a power of 2"); 1521 } 1522 free($2); 1523 } 1524 ; 1525 server_infra_cache_min_rtt: VAR_INFRA_CACHE_MIN_RTT STRING_ARG 1526 { 1527 OUTYY(("P(server_infra_cache_min_rtt:%s)\n", $2)); 1528 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1529 yyerror("number expected"); 1530 else cfg_parser->cfg->infra_cache_min_rtt = atoi($2); 1531 free($2); 1532 } 1533 ; 1534 server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG 1535 { 1536 OUTYY(("P(server_target_fetch_policy:%s)\n", $2)); 1537 free(cfg_parser->cfg->target_fetch_policy); 1538 cfg_parser->cfg->target_fetch_policy = $2; 1539 } 1540 ; 1541 server_harden_short_bufsize: VAR_HARDEN_SHORT_BUFSIZE STRING_ARG 1542 { 1543 OUTYY(("P(server_harden_short_bufsize:%s)\n", $2)); 1544 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1545 yyerror("expected yes or no."); 1546 else cfg_parser->cfg->harden_short_bufsize = 1547 (strcmp($2, "yes")==0); 1548 free($2); 1549 } 1550 ; 1551 server_harden_large_queries: VAR_HARDEN_LARGE_QUERIES STRING_ARG 1552 { 1553 OUTYY(("P(server_harden_large_queries:%s)\n", $2)); 1554 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1555 yyerror("expected yes or no."); 1556 else cfg_parser->cfg->harden_large_queries = 1557 (strcmp($2, "yes")==0); 1558 free($2); 1559 } 1560 ; 1561 server_harden_glue: VAR_HARDEN_GLUE STRING_ARG 1562 { 1563 OUTYY(("P(server_harden_glue:%s)\n", $2)); 1564 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1565 yyerror("expected yes or no."); 1566 else cfg_parser->cfg->harden_glue = 1567 (strcmp($2, "yes")==0); 1568 free($2); 1569 } 1570 ; 1571 server_harden_dnssec_stripped: VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG 1572 { 1573 OUTYY(("P(server_harden_dnssec_stripped:%s)\n", $2)); 1574 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1575 yyerror("expected yes or no."); 1576 else cfg_parser->cfg->harden_dnssec_stripped = 1577 (strcmp($2, "yes")==0); 1578 free($2); 1579 } 1580 ; 1581 server_harden_below_nxdomain: VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG 1582 { 1583 OUTYY(("P(server_harden_below_nxdomain:%s)\n", $2)); 1584 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1585 yyerror("expected yes or no."); 1586 else cfg_parser->cfg->harden_below_nxdomain = 1587 (strcmp($2, "yes")==0); 1588 free($2); 1589 } 1590 ; 1591 server_harden_referral_path: VAR_HARDEN_REFERRAL_PATH STRING_ARG 1592 { 1593 OUTYY(("P(server_harden_referral_path:%s)\n", $2)); 1594 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1595 yyerror("expected yes or no."); 1596 else cfg_parser->cfg->harden_referral_path = 1597 (strcmp($2, "yes")==0); 1598 free($2); 1599 } 1600 ; 1601 server_harden_algo_downgrade: VAR_HARDEN_ALGO_DOWNGRADE STRING_ARG 1602 { 1603 OUTYY(("P(server_harden_algo_downgrade:%s)\n", $2)); 1604 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1605 yyerror("expected yes or no."); 1606 else cfg_parser->cfg->harden_algo_downgrade = 1607 (strcmp($2, "yes")==0); 1608 free($2); 1609 } 1610 ; 1611 server_use_caps_for_id: VAR_USE_CAPS_FOR_ID STRING_ARG 1612 { 1613 OUTYY(("P(server_use_caps_for_id:%s)\n", $2)); 1614 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1615 yyerror("expected yes or no."); 1616 else cfg_parser->cfg->use_caps_bits_for_id = 1617 (strcmp($2, "yes")==0); 1618 free($2); 1619 } 1620 ; 1621 server_caps_whitelist: VAR_CAPS_WHITELIST STRING_ARG 1622 { 1623 OUTYY(("P(server_caps_whitelist:%s)\n", $2)); 1624 if(!cfg_strlist_insert(&cfg_parser->cfg->caps_whitelist, $2)) 1625 yyerror("out of memory"); 1626 } 1627 ; 1628 server_private_address: VAR_PRIVATE_ADDRESS STRING_ARG 1629 { 1630 OUTYY(("P(server_private_address:%s)\n", $2)); 1631 if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, $2)) 1632 yyerror("out of memory"); 1633 } 1634 ; 1635 server_private_domain: VAR_PRIVATE_DOMAIN STRING_ARG 1636 { 1637 OUTYY(("P(server_private_domain:%s)\n", $2)); 1638 if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, $2)) 1639 yyerror("out of memory"); 1640 } 1641 ; 1642 server_prefetch: VAR_PREFETCH STRING_ARG 1643 { 1644 OUTYY(("P(server_prefetch:%s)\n", $2)); 1645 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1646 yyerror("expected yes or no."); 1647 else cfg_parser->cfg->prefetch = (strcmp($2, "yes")==0); 1648 free($2); 1649 } 1650 ; 1651 server_prefetch_key: VAR_PREFETCH_KEY STRING_ARG 1652 { 1653 OUTYY(("P(server_prefetch_key:%s)\n", $2)); 1654 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1655 yyerror("expected yes or no."); 1656 else cfg_parser->cfg->prefetch_key = (strcmp($2, "yes")==0); 1657 free($2); 1658 } 1659 ; 1660 server_deny_any: VAR_DENY_ANY STRING_ARG 1661 { 1662 OUTYY(("P(server_deny_any:%s)\n", $2)); 1663 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1664 yyerror("expected yes or no."); 1665 else cfg_parser->cfg->deny_any = (strcmp($2, "yes")==0); 1666 free($2); 1667 } 1668 ; 1669 server_unwanted_reply_threshold: VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG 1670 { 1671 OUTYY(("P(server_unwanted_reply_threshold:%s)\n", $2)); 1672 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1673 yyerror("number expected"); 1674 else cfg_parser->cfg->unwanted_threshold = atoi($2); 1675 free($2); 1676 } 1677 ; 1678 server_do_not_query_address: VAR_DO_NOT_QUERY_ADDRESS STRING_ARG 1679 { 1680 OUTYY(("P(server_do_not_query_address:%s)\n", $2)); 1681 if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, $2)) 1682 yyerror("out of memory"); 1683 } 1684 ; 1685 server_do_not_query_localhost: VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG 1686 { 1687 OUTYY(("P(server_do_not_query_localhost:%s)\n", $2)); 1688 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1689 yyerror("expected yes or no."); 1690 else cfg_parser->cfg->donotquery_localhost = 1691 (strcmp($2, "yes")==0); 1692 free($2); 1693 } 1694 ; 1695 server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG 1696 { 1697 OUTYY(("P(server_access_control:%s %s)\n", $2, $3)); 1698 if(strcmp($3, "deny")!=0 && strcmp($3, "refuse")!=0 && 1699 strcmp($3, "deny_non_local")!=0 && 1700 strcmp($3, "refuse_non_local")!=0 && 1701 strcmp($3, "allow_setrd")!=0 && 1702 strcmp($3, "allow")!=0 && 1703 strcmp($3, "allow_snoop")!=0) { 1704 yyerror("expected deny, refuse, deny_non_local, " 1705 "refuse_non_local, allow, allow_setrd or " 1706 "allow_snoop in access control action"); 1707 free($2); 1708 free($3); 1709 } else { 1710 if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3)) 1711 fatal_exit("out of memory adding acl"); 1712 } 1713 } 1714 ; 1715 server_module_conf: VAR_MODULE_CONF STRING_ARG 1716 { 1717 OUTYY(("P(server_module_conf:%s)\n", $2)); 1718 free(cfg_parser->cfg->module_conf); 1719 cfg_parser->cfg->module_conf = $2; 1720 } 1721 ; 1722 server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING_ARG 1723 { 1724 OUTYY(("P(server_val_override_date:%s)\n", $2)); 1725 if(*$2 == '\0' || strcmp($2, "0") == 0) { 1726 cfg_parser->cfg->val_date_override = 0; 1727 } else if(strlen($2) == 14) { 1728 cfg_parser->cfg->val_date_override = 1729 cfg_convert_timeval($2); 1730 if(!cfg_parser->cfg->val_date_override) 1731 yyerror("bad date/time specification"); 1732 } else { 1733 if(atoi($2) == 0) 1734 yyerror("number expected"); 1735 cfg_parser->cfg->val_date_override = atoi($2); 1736 } 1737 free($2); 1738 } 1739 ; 1740 server_val_sig_skew_min: VAR_VAL_SIG_SKEW_MIN STRING_ARG 1741 { 1742 OUTYY(("P(server_val_sig_skew_min:%s)\n", $2)); 1743 if(*$2 == '\0' || strcmp($2, "0") == 0) { 1744 cfg_parser->cfg->val_sig_skew_min = 0; 1745 } else { 1746 cfg_parser->cfg->val_sig_skew_min = atoi($2); 1747 if(!cfg_parser->cfg->val_sig_skew_min) 1748 yyerror("number expected"); 1749 } 1750 free($2); 1751 } 1752 ; 1753 server_val_sig_skew_max: VAR_VAL_SIG_SKEW_MAX STRING_ARG 1754 { 1755 OUTYY(("P(server_val_sig_skew_max:%s)\n", $2)); 1756 if(*$2 == '\0' || strcmp($2, "0") == 0) { 1757 cfg_parser->cfg->val_sig_skew_max = 0; 1758 } else { 1759 cfg_parser->cfg->val_sig_skew_max = atoi($2); 1760 if(!cfg_parser->cfg->val_sig_skew_max) 1761 yyerror("number expected"); 1762 } 1763 free($2); 1764 } 1765 ; 1766 server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG 1767 { 1768 OUTYY(("P(server_cache_max_ttl:%s)\n", $2)); 1769 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1770 yyerror("number expected"); 1771 else cfg_parser->cfg->max_ttl = atoi($2); 1772 free($2); 1773 } 1774 ; 1775 server_cache_max_negative_ttl: VAR_CACHE_MAX_NEGATIVE_TTL STRING_ARG 1776 { 1777 OUTYY(("P(server_cache_max_negative_ttl:%s)\n", $2)); 1778 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1779 yyerror("number expected"); 1780 else cfg_parser->cfg->max_negative_ttl = atoi($2); 1781 free($2); 1782 } 1783 ; 1784 server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG 1785 { 1786 OUTYY(("P(server_cache_min_ttl:%s)\n", $2)); 1787 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1788 yyerror("number expected"); 1789 else cfg_parser->cfg->min_ttl = atoi($2); 1790 free($2); 1791 } 1792 ; 1793 server_bogus_ttl: VAR_BOGUS_TTL STRING_ARG 1794 { 1795 OUTYY(("P(server_bogus_ttl:%s)\n", $2)); 1796 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1797 yyerror("number expected"); 1798 else cfg_parser->cfg->bogus_ttl = atoi($2); 1799 free($2); 1800 } 1801 ; 1802 server_val_clean_additional: VAR_VAL_CLEAN_ADDITIONAL STRING_ARG 1803 { 1804 OUTYY(("P(server_val_clean_additional:%s)\n", $2)); 1805 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1806 yyerror("expected yes or no."); 1807 else cfg_parser->cfg->val_clean_additional = 1808 (strcmp($2, "yes")==0); 1809 free($2); 1810 } 1811 ; 1812 server_val_permissive_mode: VAR_VAL_PERMISSIVE_MODE STRING_ARG 1813 { 1814 OUTYY(("P(server_val_permissive_mode:%s)\n", $2)); 1815 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1816 yyerror("expected yes or no."); 1817 else cfg_parser->cfg->val_permissive_mode = 1818 (strcmp($2, "yes")==0); 1819 free($2); 1820 } 1821 ; 1822 server_aggressive_nsec: VAR_AGGRESSIVE_NSEC STRING_ARG 1823 { 1824 OUTYY(("P(server_aggressive_nsec:%s)\n", $2)); 1825 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1826 yyerror("expected yes or no."); 1827 else 1828 cfg_parser->cfg->aggressive_nsec = 1829 (strcmp($2, "yes")==0); 1830 free($2); 1831 } 1832 ; 1833 server_ignore_cd_flag: VAR_IGNORE_CD_FLAG STRING_ARG 1834 { 1835 OUTYY(("P(server_ignore_cd_flag:%s)\n", $2)); 1836 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1837 yyerror("expected yes or no."); 1838 else cfg_parser->cfg->ignore_cd = (strcmp($2, "yes")==0); 1839 free($2); 1840 } 1841 ; 1842 server_serve_expired: VAR_SERVE_EXPIRED STRING_ARG 1843 { 1844 OUTYY(("P(server_serve_expired:%s)\n", $2)); 1845 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1846 yyerror("expected yes or no."); 1847 else cfg_parser->cfg->serve_expired = (strcmp($2, "yes")==0); 1848 free($2); 1849 } 1850 ; 1851 server_serve_expired_ttl: VAR_SERVE_EXPIRED_TTL STRING_ARG 1852 { 1853 OUTYY(("P(server_serve_expired_ttl:%s)\n", $2)); 1854 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1855 yyerror("number expected"); 1856 else cfg_parser->cfg->serve_expired_ttl = atoi($2); 1857 free($2); 1858 } 1859 ; 1860 server_serve_expired_ttl_reset: VAR_SERVE_EXPIRED_TTL_RESET STRING_ARG 1861 { 1862 OUTYY(("P(server_serve_expired_ttl_reset:%s)\n", $2)); 1863 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1864 yyerror("expected yes or no."); 1865 else cfg_parser->cfg->serve_expired_ttl_reset = (strcmp($2, "yes")==0); 1866 free($2); 1867 } 1868 ; 1869 server_serve_expired_reply_ttl: VAR_SERVE_EXPIRED_REPLY_TTL STRING_ARG 1870 { 1871 OUTYY(("P(server_serve_expired_reply_ttl:%s)\n", $2)); 1872 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1873 yyerror("number expected"); 1874 else cfg_parser->cfg->serve_expired_reply_ttl = atoi($2); 1875 free($2); 1876 } 1877 ; 1878 server_serve_expired_client_timeout: VAR_SERVE_EXPIRED_CLIENT_TIMEOUT STRING_ARG 1879 { 1880 OUTYY(("P(server_serve_expired_client_timeout:%s)\n", $2)); 1881 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1882 yyerror("number expected"); 1883 else cfg_parser->cfg->serve_expired_client_timeout = atoi($2); 1884 free($2); 1885 } 1886 ; 1887 server_fake_dsa: VAR_FAKE_DSA STRING_ARG 1888 { 1889 OUTYY(("P(server_fake_dsa:%s)\n", $2)); 1890 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1891 yyerror("expected yes or no."); 1892 #if defined(HAVE_SSL) || defined(HAVE_NETTLE) 1893 else fake_dsa = (strcmp($2, "yes")==0); 1894 if(fake_dsa) 1895 log_warn("test option fake_dsa is enabled"); 1896 #endif 1897 free($2); 1898 } 1899 ; 1900 server_fake_sha1: VAR_FAKE_SHA1 STRING_ARG 1901 { 1902 OUTYY(("P(server_fake_sha1:%s)\n", $2)); 1903 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1904 yyerror("expected yes or no."); 1905 #if defined(HAVE_SSL) || defined(HAVE_NETTLE) 1906 else fake_sha1 = (strcmp($2, "yes")==0); 1907 if(fake_sha1) 1908 log_warn("test option fake_sha1 is enabled"); 1909 #endif 1910 free($2); 1911 } 1912 ; 1913 server_val_log_level: VAR_VAL_LOG_LEVEL STRING_ARG 1914 { 1915 OUTYY(("P(server_val_log_level:%s)\n", $2)); 1916 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1917 yyerror("number expected"); 1918 else cfg_parser->cfg->val_log_level = atoi($2); 1919 free($2); 1920 } 1921 ; 1922 server_val_nsec3_keysize_iterations: VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG 1923 { 1924 OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", $2)); 1925 free(cfg_parser->cfg->val_nsec3_key_iterations); 1926 cfg_parser->cfg->val_nsec3_key_iterations = $2; 1927 } 1928 ; 1929 server_add_holddown: VAR_ADD_HOLDDOWN STRING_ARG 1930 { 1931 OUTYY(("P(server_add_holddown:%s)\n", $2)); 1932 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1933 yyerror("number expected"); 1934 else cfg_parser->cfg->add_holddown = atoi($2); 1935 free($2); 1936 } 1937 ; 1938 server_del_holddown: VAR_DEL_HOLDDOWN STRING_ARG 1939 { 1940 OUTYY(("P(server_del_holddown:%s)\n", $2)); 1941 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1942 yyerror("number expected"); 1943 else cfg_parser->cfg->del_holddown = atoi($2); 1944 free($2); 1945 } 1946 ; 1947 server_keep_missing: VAR_KEEP_MISSING STRING_ARG 1948 { 1949 OUTYY(("P(server_keep_missing:%s)\n", $2)); 1950 if(atoi($2) == 0 && strcmp($2, "0") != 0) 1951 yyerror("number expected"); 1952 else cfg_parser->cfg->keep_missing = atoi($2); 1953 free($2); 1954 } 1955 ; 1956 server_permit_small_holddown: VAR_PERMIT_SMALL_HOLDDOWN STRING_ARG 1957 { 1958 OUTYY(("P(server_permit_small_holddown:%s)\n", $2)); 1959 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 1960 yyerror("expected yes or no."); 1961 else cfg_parser->cfg->permit_small_holddown = 1962 (strcmp($2, "yes")==0); 1963 free($2); 1964 } 1965 server_key_cache_size: VAR_KEY_CACHE_SIZE STRING_ARG 1966 { 1967 OUTYY(("P(server_key_cache_size:%s)\n", $2)); 1968 if(!cfg_parse_memsize($2, &cfg_parser->cfg->key_cache_size)) 1969 yyerror("memory size expected"); 1970 free($2); 1971 } 1972 ; 1973 server_key_cache_slabs: VAR_KEY_CACHE_SLABS STRING_ARG 1974 { 1975 OUTYY(("P(server_key_cache_slabs:%s)\n", $2)); 1976 if(atoi($2) == 0) 1977 yyerror("number expected"); 1978 else { 1979 cfg_parser->cfg->key_cache_slabs = atoi($2); 1980 if(!is_pow2(cfg_parser->cfg->key_cache_slabs)) 1981 yyerror("must be a power of 2"); 1982 } 1983 free($2); 1984 } 1985 ; 1986 server_neg_cache_size: VAR_NEG_CACHE_SIZE STRING_ARG 1987 { 1988 OUTYY(("P(server_neg_cache_size:%s)\n", $2)); 1989 if(!cfg_parse_memsize($2, &cfg_parser->cfg->neg_cache_size)) 1990 yyerror("memory size expected"); 1991 free($2); 1992 } 1993 ; 1994 server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG 1995 { 1996 OUTYY(("P(server_local_zone:%s %s)\n", $2, $3)); 1997 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && 1998 strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && 1999 strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 2000 && strcmp($3, "typetransparent")!=0 2001 && strcmp($3, "always_transparent")!=0 2002 && strcmp($3, "always_refuse")!=0 2003 && strcmp($3, "always_nxdomain")!=0 2004 && strcmp($3, "noview")!=0 2005 && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0 2006 && strcmp($3, "inform_redirect") != 0 2007 && strcmp($3, "ipset") != 0) { 2008 yyerror("local-zone type: expected static, deny, " 2009 "refuse, redirect, transparent, " 2010 "typetransparent, inform, inform_deny, " 2011 "inform_redirect, always_transparent, " 2012 "always_refuse, always_nxdomain, noview " 2013 ", nodefault or ipset"); 2014 free($2); 2015 free($3); 2016 } else if(strcmp($3, "nodefault")==0) { 2017 if(!cfg_strlist_insert(&cfg_parser->cfg-> 2018 local_zones_nodefault, $2)) 2019 fatal_exit("out of memory adding local-zone"); 2020 free($3); 2021 #ifdef USE_IPSET 2022 } else if(strcmp($3, "ipset")==0) { 2023 if(!cfg_strlist_insert(&cfg_parser->cfg-> 2024 local_zones_ipset, $2)) 2025 fatal_exit("out of memory adding local-zone"); 2026 free($3); 2027 #endif 2028 } else { 2029 if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones, 2030 $2, $3)) 2031 fatal_exit("out of memory adding local-zone"); 2032 } 2033 } 2034 ; 2035 server_local_data: VAR_LOCAL_DATA STRING_ARG 2036 { 2037 OUTYY(("P(server_local_data:%s)\n", $2)); 2038 if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, $2)) 2039 fatal_exit("out of memory adding local-data"); 2040 } 2041 ; 2042 server_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG 2043 { 2044 char* ptr; 2045 OUTYY(("P(server_local_data_ptr:%s)\n", $2)); 2046 ptr = cfg_ptr_reverse($2); 2047 free($2); 2048 if(ptr) { 2049 if(!cfg_strlist_insert(&cfg_parser->cfg-> 2050 local_data, ptr)) 2051 fatal_exit("out of memory adding local-data"); 2052 } else { 2053 yyerror("local-data-ptr could not be reversed"); 2054 } 2055 } 2056 ; 2057 server_minimal_responses: VAR_MINIMAL_RESPONSES STRING_ARG 2058 { 2059 OUTYY(("P(server_minimal_responses:%s)\n", $2)); 2060 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2061 yyerror("expected yes or no."); 2062 else cfg_parser->cfg->minimal_responses = 2063 (strcmp($2, "yes")==0); 2064 free($2); 2065 } 2066 ; 2067 server_rrset_roundrobin: VAR_RRSET_ROUNDROBIN STRING_ARG 2068 { 2069 OUTYY(("P(server_rrset_roundrobin:%s)\n", $2)); 2070 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2071 yyerror("expected yes or no."); 2072 else cfg_parser->cfg->rrset_roundrobin = 2073 (strcmp($2, "yes")==0); 2074 free($2); 2075 } 2076 ; 2077 server_unknown_server_time_limit: VAR_UNKNOWN_SERVER_TIME_LIMIT STRING_ARG 2078 { 2079 OUTYY(("P(server_unknown_server_time_limit:%s)\n", $2)); 2080 cfg_parser->cfg->unknown_server_time_limit = atoi($2); 2081 free($2); 2082 } 2083 ; 2084 server_max_udp_size: VAR_MAX_UDP_SIZE STRING_ARG 2085 { 2086 OUTYY(("P(server_max_udp_size:%s)\n", $2)); 2087 cfg_parser->cfg->max_udp_size = atoi($2); 2088 free($2); 2089 } 2090 ; 2091 server_dns64_prefix: VAR_DNS64_PREFIX STRING_ARG 2092 { 2093 OUTYY(("P(dns64_prefix:%s)\n", $2)); 2094 free(cfg_parser->cfg->dns64_prefix); 2095 cfg_parser->cfg->dns64_prefix = $2; 2096 } 2097 ; 2098 server_dns64_synthall: VAR_DNS64_SYNTHALL STRING_ARG 2099 { 2100 OUTYY(("P(server_dns64_synthall:%s)\n", $2)); 2101 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2102 yyerror("expected yes or no."); 2103 else cfg_parser->cfg->dns64_synthall = (strcmp($2, "yes")==0); 2104 free($2); 2105 } 2106 ; 2107 server_dns64_ignore_aaaa: VAR_DNS64_IGNORE_AAAA STRING_ARG 2108 { 2109 OUTYY(("P(dns64_ignore_aaaa:%s)\n", $2)); 2110 if(!cfg_strlist_insert(&cfg_parser->cfg->dns64_ignore_aaaa, 2111 $2)) 2112 fatal_exit("out of memory adding dns64-ignore-aaaa"); 2113 } 2114 ; 2115 server_define_tag: VAR_DEFINE_TAG STRING_ARG 2116 { 2117 char* p, *s = $2; 2118 OUTYY(("P(server_define_tag:%s)\n", $2)); 2119 while((p=strsep(&s, " \t\n")) != NULL) { 2120 if(*p) { 2121 if(!config_add_tag(cfg_parser->cfg, p)) 2122 yyerror("could not define-tag, " 2123 "out of memory"); 2124 } 2125 } 2126 free($2); 2127 } 2128 ; 2129 server_local_zone_tag: VAR_LOCAL_ZONE_TAG STRING_ARG STRING_ARG 2130 { 2131 size_t len = 0; 2132 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3, 2133 &len); 2134 free($3); 2135 OUTYY(("P(server_local_zone_tag:%s)\n", $2)); 2136 if(!bitlist) { 2137 yyerror("could not parse tags, (define-tag them first)"); 2138 free($2); 2139 } 2140 if(bitlist) { 2141 if(!cfg_strbytelist_insert( 2142 &cfg_parser->cfg->local_zone_tags, 2143 $2, bitlist, len)) { 2144 yyerror("out of memory"); 2145 free($2); 2146 } 2147 } 2148 } 2149 ; 2150 server_access_control_tag: VAR_ACCESS_CONTROL_TAG STRING_ARG STRING_ARG 2151 { 2152 size_t len = 0; 2153 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3, 2154 &len); 2155 free($3); 2156 OUTYY(("P(server_access_control_tag:%s)\n", $2)); 2157 if(!bitlist) { 2158 yyerror("could not parse tags, (define-tag them first)"); 2159 free($2); 2160 } 2161 if(bitlist) { 2162 if(!cfg_strbytelist_insert( 2163 &cfg_parser->cfg->acl_tags, 2164 $2, bitlist, len)) { 2165 yyerror("out of memory"); 2166 free($2); 2167 } 2168 } 2169 } 2170 ; 2171 server_access_control_tag_action: VAR_ACCESS_CONTROL_TAG_ACTION STRING_ARG STRING_ARG STRING_ARG 2172 { 2173 OUTYY(("P(server_access_control_tag_action:%s %s %s)\n", $2, $3, $4)); 2174 if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_actions, 2175 $2, $3, $4)) { 2176 yyerror("out of memory"); 2177 free($2); 2178 free($3); 2179 free($4); 2180 } 2181 } 2182 ; 2183 server_access_control_tag_data: VAR_ACCESS_CONTROL_TAG_DATA STRING_ARG STRING_ARG STRING_ARG 2184 { 2185 OUTYY(("P(server_access_control_tag_data:%s %s %s)\n", $2, $3, $4)); 2186 if(!cfg_str3list_insert(&cfg_parser->cfg->acl_tag_datas, 2187 $2, $3, $4)) { 2188 yyerror("out of memory"); 2189 free($2); 2190 free($3); 2191 free($4); 2192 } 2193 } 2194 ; 2195 server_local_zone_override: VAR_LOCAL_ZONE_OVERRIDE STRING_ARG STRING_ARG STRING_ARG 2196 { 2197 OUTYY(("P(server_local_zone_override:%s %s %s)\n", $2, $3, $4)); 2198 if(!cfg_str3list_insert(&cfg_parser->cfg->local_zone_overrides, 2199 $2, $3, $4)) { 2200 yyerror("out of memory"); 2201 free($2); 2202 free($3); 2203 free($4); 2204 } 2205 } 2206 ; 2207 server_access_control_view: VAR_ACCESS_CONTROL_VIEW STRING_ARG STRING_ARG 2208 { 2209 OUTYY(("P(server_access_control_view:%s %s)\n", $2, $3)); 2210 if(!cfg_str2list_insert(&cfg_parser->cfg->acl_view, 2211 $2, $3)) { 2212 yyerror("out of memory"); 2213 } 2214 } 2215 ; 2216 server_response_ip_tag: VAR_RESPONSE_IP_TAG STRING_ARG STRING_ARG 2217 { 2218 size_t len = 0; 2219 uint8_t* bitlist = config_parse_taglist(cfg_parser->cfg, $3, 2220 &len); 2221 free($3); 2222 OUTYY(("P(response_ip_tag:%s)\n", $2)); 2223 if(!bitlist) { 2224 yyerror("could not parse tags, (define-tag them first)"); 2225 free($2); 2226 } 2227 if(bitlist) { 2228 if(!cfg_strbytelist_insert( 2229 &cfg_parser->cfg->respip_tags, 2230 $2, bitlist, len)) { 2231 yyerror("out of memory"); 2232 free($2); 2233 } 2234 } 2235 } 2236 ; 2237 server_ip_ratelimit: VAR_IP_RATELIMIT STRING_ARG 2238 { 2239 OUTYY(("P(server_ip_ratelimit:%s)\n", $2)); 2240 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2241 yyerror("number expected"); 2242 else cfg_parser->cfg->ip_ratelimit = atoi($2); 2243 free($2); 2244 } 2245 ; 2246 2247 server_ratelimit: VAR_RATELIMIT STRING_ARG 2248 { 2249 OUTYY(("P(server_ratelimit:%s)\n", $2)); 2250 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2251 yyerror("number expected"); 2252 else cfg_parser->cfg->ratelimit = atoi($2); 2253 free($2); 2254 } 2255 ; 2256 server_ip_ratelimit_size: VAR_IP_RATELIMIT_SIZE STRING_ARG 2257 { 2258 OUTYY(("P(server_ip_ratelimit_size:%s)\n", $2)); 2259 if(!cfg_parse_memsize($2, &cfg_parser->cfg->ip_ratelimit_size)) 2260 yyerror("memory size expected"); 2261 free($2); 2262 } 2263 ; 2264 server_ratelimit_size: VAR_RATELIMIT_SIZE STRING_ARG 2265 { 2266 OUTYY(("P(server_ratelimit_size:%s)\n", $2)); 2267 if(!cfg_parse_memsize($2, &cfg_parser->cfg->ratelimit_size)) 2268 yyerror("memory size expected"); 2269 free($2); 2270 } 2271 ; 2272 server_ip_ratelimit_slabs: VAR_IP_RATELIMIT_SLABS STRING_ARG 2273 { 2274 OUTYY(("P(server_ip_ratelimit_slabs:%s)\n", $2)); 2275 if(atoi($2) == 0) 2276 yyerror("number expected"); 2277 else { 2278 cfg_parser->cfg->ip_ratelimit_slabs = atoi($2); 2279 if(!is_pow2(cfg_parser->cfg->ip_ratelimit_slabs)) 2280 yyerror("must be a power of 2"); 2281 } 2282 free($2); 2283 } 2284 ; 2285 server_ratelimit_slabs: VAR_RATELIMIT_SLABS STRING_ARG 2286 { 2287 OUTYY(("P(server_ratelimit_slabs:%s)\n", $2)); 2288 if(atoi($2) == 0) 2289 yyerror("number expected"); 2290 else { 2291 cfg_parser->cfg->ratelimit_slabs = atoi($2); 2292 if(!is_pow2(cfg_parser->cfg->ratelimit_slabs)) 2293 yyerror("must be a power of 2"); 2294 } 2295 free($2); 2296 } 2297 ; 2298 server_ratelimit_for_domain: VAR_RATELIMIT_FOR_DOMAIN STRING_ARG STRING_ARG 2299 { 2300 OUTYY(("P(server_ratelimit_for_domain:%s %s)\n", $2, $3)); 2301 if(atoi($3) == 0 && strcmp($3, "0") != 0) { 2302 yyerror("number expected"); 2303 free($2); 2304 free($3); 2305 } else { 2306 if(!cfg_str2list_insert(&cfg_parser->cfg-> 2307 ratelimit_for_domain, $2, $3)) 2308 fatal_exit("out of memory adding " 2309 "ratelimit-for-domain"); 2310 } 2311 } 2312 ; 2313 server_ratelimit_below_domain: VAR_RATELIMIT_BELOW_DOMAIN STRING_ARG STRING_ARG 2314 { 2315 OUTYY(("P(server_ratelimit_below_domain:%s %s)\n", $2, $3)); 2316 if(atoi($3) == 0 && strcmp($3, "0") != 0) { 2317 yyerror("number expected"); 2318 free($2); 2319 free($3); 2320 } else { 2321 if(!cfg_str2list_insert(&cfg_parser->cfg-> 2322 ratelimit_below_domain, $2, $3)) 2323 fatal_exit("out of memory adding " 2324 "ratelimit-below-domain"); 2325 } 2326 } 2327 ; 2328 server_ip_ratelimit_factor: VAR_IP_RATELIMIT_FACTOR STRING_ARG 2329 { 2330 OUTYY(("P(server_ip_ratelimit_factor:%s)\n", $2)); 2331 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2332 yyerror("number expected"); 2333 else cfg_parser->cfg->ip_ratelimit_factor = atoi($2); 2334 free($2); 2335 } 2336 ; 2337 server_ratelimit_factor: VAR_RATELIMIT_FACTOR STRING_ARG 2338 { 2339 OUTYY(("P(server_ratelimit_factor:%s)\n", $2)); 2340 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2341 yyerror("number expected"); 2342 else cfg_parser->cfg->ratelimit_factor = atoi($2); 2343 free($2); 2344 } 2345 ; 2346 server_low_rtt: VAR_LOW_RTT STRING_ARG 2347 { 2348 OUTYY(("P(low-rtt option is deprecated, use fast-server-num instead)\n")); 2349 free($2); 2350 } 2351 ; 2352 server_fast_server_num: VAR_FAST_SERVER_NUM STRING_ARG 2353 { 2354 OUTYY(("P(server_fast_server_num:%s)\n", $2)); 2355 if(atoi($2) <= 0) 2356 yyerror("number expected"); 2357 else cfg_parser->cfg->fast_server_num = atoi($2); 2358 free($2); 2359 } 2360 ; 2361 server_fast_server_permil: VAR_FAST_SERVER_PERMIL STRING_ARG 2362 { 2363 OUTYY(("P(server_fast_server_permil:%s)\n", $2)); 2364 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2365 yyerror("number expected"); 2366 else cfg_parser->cfg->fast_server_permil = atoi($2); 2367 free($2); 2368 } 2369 ; 2370 server_qname_minimisation: VAR_QNAME_MINIMISATION STRING_ARG 2371 { 2372 OUTYY(("P(server_qname_minimisation:%s)\n", $2)); 2373 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2374 yyerror("expected yes or no."); 2375 else cfg_parser->cfg->qname_minimisation = 2376 (strcmp($2, "yes")==0); 2377 free($2); 2378 } 2379 ; 2380 server_qname_minimisation_strict: VAR_QNAME_MINIMISATION_STRICT STRING_ARG 2381 { 2382 OUTYY(("P(server_qname_minimisation_strict:%s)\n", $2)); 2383 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2384 yyerror("expected yes or no."); 2385 else cfg_parser->cfg->qname_minimisation_strict = 2386 (strcmp($2, "yes")==0); 2387 free($2); 2388 } 2389 ; 2390 server_ipsecmod_enabled: VAR_IPSECMOD_ENABLED STRING_ARG 2391 { 2392 #ifdef USE_IPSECMOD 2393 OUTYY(("P(server_ipsecmod_enabled:%s)\n", $2)); 2394 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2395 yyerror("expected yes or no."); 2396 else cfg_parser->cfg->ipsecmod_enabled = (strcmp($2, "yes")==0); 2397 #else 2398 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2399 #endif 2400 free($2); 2401 } 2402 ; 2403 server_ipsecmod_ignore_bogus: VAR_IPSECMOD_IGNORE_BOGUS STRING_ARG 2404 { 2405 #ifdef USE_IPSECMOD 2406 OUTYY(("P(server_ipsecmod_ignore_bogus:%s)\n", $2)); 2407 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2408 yyerror("expected yes or no."); 2409 else cfg_parser->cfg->ipsecmod_ignore_bogus = (strcmp($2, "yes")==0); 2410 #else 2411 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2412 #endif 2413 free($2); 2414 } 2415 ; 2416 server_ipsecmod_hook: VAR_IPSECMOD_HOOK STRING_ARG 2417 { 2418 #ifdef USE_IPSECMOD 2419 OUTYY(("P(server_ipsecmod_hook:%s)\n", $2)); 2420 free(cfg_parser->cfg->ipsecmod_hook); 2421 cfg_parser->cfg->ipsecmod_hook = $2; 2422 #else 2423 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2424 free($2); 2425 #endif 2426 } 2427 ; 2428 server_ipsecmod_max_ttl: VAR_IPSECMOD_MAX_TTL STRING_ARG 2429 { 2430 #ifdef USE_IPSECMOD 2431 OUTYY(("P(server_ipsecmod_max_ttl:%s)\n", $2)); 2432 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2433 yyerror("number expected"); 2434 else cfg_parser->cfg->ipsecmod_max_ttl = atoi($2); 2435 free($2); 2436 #else 2437 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2438 free($2); 2439 #endif 2440 } 2441 ; 2442 server_ipsecmod_whitelist: VAR_IPSECMOD_WHITELIST STRING_ARG 2443 { 2444 #ifdef USE_IPSECMOD 2445 OUTYY(("P(server_ipsecmod_whitelist:%s)\n", $2)); 2446 if(!cfg_strlist_insert(&cfg_parser->cfg->ipsecmod_whitelist, $2)) 2447 yyerror("out of memory"); 2448 #else 2449 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2450 free($2); 2451 #endif 2452 } 2453 ; 2454 server_ipsecmod_strict: VAR_IPSECMOD_STRICT STRING_ARG 2455 { 2456 #ifdef USE_IPSECMOD 2457 OUTYY(("P(server_ipsecmod_strict:%s)\n", $2)); 2458 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2459 yyerror("expected yes or no."); 2460 else cfg_parser->cfg->ipsecmod_strict = (strcmp($2, "yes")==0); 2461 free($2); 2462 #else 2463 OUTYY(("P(Compiled without IPsec module, ignoring)\n")); 2464 free($2); 2465 #endif 2466 } 2467 ; 2468 server_edns_client_tag: VAR_EDNS_CLIENT_TAG STRING_ARG STRING_ARG 2469 { 2470 int tag_data; 2471 OUTYY(("P(server_edns_client_tag:%s %s)\n", $2, $3)); 2472 tag_data = atoi($3); 2473 if(tag_data > 65535 || tag_data < 0 || 2474 (tag_data == 0 && (strlen($3) != 1 || $3[0] != '0'))) 2475 yyerror("edns-client-tag data invalid, needs to be a " 2476 "number from 0 to 65535"); 2477 if(!cfg_str2list_insert( 2478 &cfg_parser->cfg->edns_client_tags, $2, $3)) 2479 fatal_exit("out of memory adding " 2480 "edns-client-tag"); 2481 } 2482 ; 2483 server_edns_client_tag_opcode: VAR_EDNS_CLIENT_TAG_OPCODE STRING_ARG 2484 { 2485 OUTYY(("P(edns_client_tag_opcode:%s)\n", $2)); 2486 if(atoi($2) == 0 && strcmp($2, "0") != 0) 2487 yyerror("option code expected"); 2488 else if(atoi($2) > 65535 || atoi($2) < 0) 2489 yyerror("option code must be in interval [0, 65535]"); 2490 else cfg_parser->cfg->edns_client_tag_opcode = atoi($2); 2491 2492 } 2493 ; 2494 stub_name: VAR_NAME STRING_ARG 2495 { 2496 OUTYY(("P(name:%s)\n", $2)); 2497 if(cfg_parser->cfg->stubs->name) 2498 yyerror("stub name override, there must be one name " 2499 "for one stub-zone"); 2500 free(cfg_parser->cfg->stubs->name); 2501 cfg_parser->cfg->stubs->name = $2; 2502 } 2503 ; 2504 stub_host: VAR_STUB_HOST STRING_ARG 2505 { 2506 OUTYY(("P(stub-host:%s)\n", $2)); 2507 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, $2)) 2508 yyerror("out of memory"); 2509 } 2510 ; 2511 stub_addr: VAR_STUB_ADDR STRING_ARG 2512 { 2513 OUTYY(("P(stub-addr:%s)\n", $2)); 2514 if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, $2)) 2515 yyerror("out of memory"); 2516 } 2517 ; 2518 stub_first: VAR_STUB_FIRST STRING_ARG 2519 { 2520 OUTYY(("P(stub-first:%s)\n", $2)); 2521 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2522 yyerror("expected yes or no."); 2523 else cfg_parser->cfg->stubs->isfirst=(strcmp($2, "yes")==0); 2524 free($2); 2525 } 2526 ; 2527 stub_no_cache: VAR_STUB_NO_CACHE STRING_ARG 2528 { 2529 OUTYY(("P(stub-no-cache:%s)\n", $2)); 2530 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2531 yyerror("expected yes or no."); 2532 else cfg_parser->cfg->stubs->no_cache=(strcmp($2, "yes")==0); 2533 free($2); 2534 } 2535 ; 2536 stub_ssl_upstream: VAR_STUB_SSL_UPSTREAM STRING_ARG 2537 { 2538 OUTYY(("P(stub-ssl-upstream:%s)\n", $2)); 2539 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2540 yyerror("expected yes or no."); 2541 else cfg_parser->cfg->stubs->ssl_upstream = 2542 (strcmp($2, "yes")==0); 2543 free($2); 2544 } 2545 ; 2546 stub_prime: VAR_STUB_PRIME STRING_ARG 2547 { 2548 OUTYY(("P(stub-prime:%s)\n", $2)); 2549 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2550 yyerror("expected yes or no."); 2551 else cfg_parser->cfg->stubs->isprime = 2552 (strcmp($2, "yes")==0); 2553 free($2); 2554 } 2555 ; 2556 forward_name: VAR_NAME STRING_ARG 2557 { 2558 OUTYY(("P(name:%s)\n", $2)); 2559 if(cfg_parser->cfg->forwards->name) 2560 yyerror("forward name override, there must be one " 2561 "name for one forward-zone"); 2562 free(cfg_parser->cfg->forwards->name); 2563 cfg_parser->cfg->forwards->name = $2; 2564 } 2565 ; 2566 forward_host: VAR_FORWARD_HOST STRING_ARG 2567 { 2568 OUTYY(("P(forward-host:%s)\n", $2)); 2569 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, $2)) 2570 yyerror("out of memory"); 2571 } 2572 ; 2573 forward_addr: VAR_FORWARD_ADDR STRING_ARG 2574 { 2575 OUTYY(("P(forward-addr:%s)\n", $2)); 2576 if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, $2)) 2577 yyerror("out of memory"); 2578 } 2579 ; 2580 forward_first: VAR_FORWARD_FIRST STRING_ARG 2581 { 2582 OUTYY(("P(forward-first:%s)\n", $2)); 2583 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2584 yyerror("expected yes or no."); 2585 else cfg_parser->cfg->forwards->isfirst=(strcmp($2, "yes")==0); 2586 free($2); 2587 } 2588 ; 2589 forward_no_cache: VAR_FORWARD_NO_CACHE STRING_ARG 2590 { 2591 OUTYY(("P(forward-no-cache:%s)\n", $2)); 2592 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2593 yyerror("expected yes or no."); 2594 else cfg_parser->cfg->forwards->no_cache=(strcmp($2, "yes")==0); 2595 free($2); 2596 } 2597 ; 2598 forward_ssl_upstream: VAR_FORWARD_SSL_UPSTREAM STRING_ARG 2599 { 2600 OUTYY(("P(forward-ssl-upstream:%s)\n", $2)); 2601 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2602 yyerror("expected yes or no."); 2603 else cfg_parser->cfg->forwards->ssl_upstream = 2604 (strcmp($2, "yes")==0); 2605 free($2); 2606 } 2607 ; 2608 auth_name: VAR_NAME STRING_ARG 2609 { 2610 OUTYY(("P(name:%s)\n", $2)); 2611 if(cfg_parser->cfg->auths->name) 2612 yyerror("auth name override, there must be one name " 2613 "for one auth-zone"); 2614 free(cfg_parser->cfg->auths->name); 2615 cfg_parser->cfg->auths->name = $2; 2616 } 2617 ; 2618 auth_zonefile: VAR_ZONEFILE STRING_ARG 2619 { 2620 OUTYY(("P(zonefile:%s)\n", $2)); 2621 free(cfg_parser->cfg->auths->zonefile); 2622 cfg_parser->cfg->auths->zonefile = $2; 2623 } 2624 ; 2625 auth_master: VAR_MASTER STRING_ARG 2626 { 2627 OUTYY(("P(master:%s)\n", $2)); 2628 if(!cfg_strlist_insert(&cfg_parser->cfg->auths->masters, $2)) 2629 yyerror("out of memory"); 2630 } 2631 ; 2632 auth_url: VAR_URL STRING_ARG 2633 { 2634 OUTYY(("P(url:%s)\n", $2)); 2635 if(!cfg_strlist_insert(&cfg_parser->cfg->auths->urls, $2)) 2636 yyerror("out of memory"); 2637 } 2638 ; 2639 auth_allow_notify: VAR_ALLOW_NOTIFY STRING_ARG 2640 { 2641 OUTYY(("P(allow-notify:%s)\n", $2)); 2642 if(!cfg_strlist_insert(&cfg_parser->cfg->auths->allow_notify, 2643 $2)) 2644 yyerror("out of memory"); 2645 } 2646 ; 2647 auth_for_downstream: VAR_FOR_DOWNSTREAM STRING_ARG 2648 { 2649 OUTYY(("P(for-downstream:%s)\n", $2)); 2650 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2651 yyerror("expected yes or no."); 2652 else cfg_parser->cfg->auths->for_downstream = 2653 (strcmp($2, "yes")==0); 2654 free($2); 2655 } 2656 ; 2657 auth_for_upstream: VAR_FOR_UPSTREAM STRING_ARG 2658 { 2659 OUTYY(("P(for-upstream:%s)\n", $2)); 2660 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2661 yyerror("expected yes or no."); 2662 else cfg_parser->cfg->auths->for_upstream = 2663 (strcmp($2, "yes")==0); 2664 free($2); 2665 } 2666 ; 2667 auth_fallback_enabled: VAR_FALLBACK_ENABLED STRING_ARG 2668 { 2669 OUTYY(("P(fallback-enabled:%s)\n", $2)); 2670 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2671 yyerror("expected yes or no."); 2672 else cfg_parser->cfg->auths->fallback_enabled = 2673 (strcmp($2, "yes")==0); 2674 free($2); 2675 } 2676 ; 2677 view_name: VAR_NAME STRING_ARG 2678 { 2679 OUTYY(("P(name:%s)\n", $2)); 2680 if(cfg_parser->cfg->views->name) 2681 yyerror("view name override, there must be one " 2682 "name for one view"); 2683 free(cfg_parser->cfg->views->name); 2684 cfg_parser->cfg->views->name = $2; 2685 } 2686 ; 2687 view_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG 2688 { 2689 OUTYY(("P(view_local_zone:%s %s)\n", $2, $3)); 2690 if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 && 2691 strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 && 2692 strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0 2693 && strcmp($3, "typetransparent")!=0 2694 && strcmp($3, "always_transparent")!=0 2695 && strcmp($3, "always_refuse")!=0 2696 && strcmp($3, "always_nxdomain")!=0 2697 && strcmp($3, "noview")!=0 2698 && strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0) { 2699 yyerror("local-zone type: expected static, deny, " 2700 "refuse, redirect, transparent, " 2701 "typetransparent, inform, inform_deny, " 2702 "always_transparent, always_refuse, " 2703 "always_nxdomain, noview or nodefault"); 2704 free($2); 2705 free($3); 2706 } else if(strcmp($3, "nodefault")==0) { 2707 if(!cfg_strlist_insert(&cfg_parser->cfg->views-> 2708 local_zones_nodefault, $2)) 2709 fatal_exit("out of memory adding local-zone"); 2710 free($3); 2711 #ifdef USE_IPSET 2712 } else if(strcmp($3, "ipset")==0) { 2713 if(!cfg_strlist_insert(&cfg_parser->cfg->views-> 2714 local_zones_ipset, $2)) 2715 fatal_exit("out of memory adding local-zone"); 2716 free($3); 2717 #endif 2718 } else { 2719 if(!cfg_str2list_insert( 2720 &cfg_parser->cfg->views->local_zones, 2721 $2, $3)) 2722 fatal_exit("out of memory adding local-zone"); 2723 } 2724 } 2725 ; 2726 view_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG 2727 { 2728 OUTYY(("P(view_response_ip:%s %s)\n", $2, $3)); 2729 validate_respip_action($3); 2730 if(!cfg_str2list_insert( 2731 &cfg_parser->cfg->views->respip_actions, $2, $3)) 2732 fatal_exit("out of memory adding per-view " 2733 "response-ip action"); 2734 } 2735 ; 2736 view_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG 2737 { 2738 OUTYY(("P(view_response_ip_data:%s)\n", $2)); 2739 if(!cfg_str2list_insert( 2740 &cfg_parser->cfg->views->respip_data, $2, $3)) 2741 fatal_exit("out of memory adding response-ip-data"); 2742 } 2743 ; 2744 view_local_data: VAR_LOCAL_DATA STRING_ARG 2745 { 2746 OUTYY(("P(view_local_data:%s)\n", $2)); 2747 if(!cfg_strlist_insert(&cfg_parser->cfg->views->local_data, $2)) { 2748 fatal_exit("out of memory adding local-data"); 2749 } 2750 } 2751 ; 2752 view_local_data_ptr: VAR_LOCAL_DATA_PTR STRING_ARG 2753 { 2754 char* ptr; 2755 OUTYY(("P(view_local_data_ptr:%s)\n", $2)); 2756 ptr = cfg_ptr_reverse($2); 2757 free($2); 2758 if(ptr) { 2759 if(!cfg_strlist_insert(&cfg_parser->cfg->views-> 2760 local_data, ptr)) 2761 fatal_exit("out of memory adding local-data"); 2762 } else { 2763 yyerror("local-data-ptr could not be reversed"); 2764 } 2765 } 2766 ; 2767 view_first: VAR_VIEW_FIRST STRING_ARG 2768 { 2769 OUTYY(("P(view-first:%s)\n", $2)); 2770 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2771 yyerror("expected yes or no."); 2772 else cfg_parser->cfg->views->isfirst=(strcmp($2, "yes")==0); 2773 free($2); 2774 } 2775 ; 2776 rcstart: VAR_REMOTE_CONTROL 2777 { 2778 OUTYY(("\nP(remote-control:)\n")); 2779 } 2780 ; 2781 contents_rc: contents_rc content_rc 2782 | ; 2783 content_rc: rc_control_enable | rc_control_interface | rc_control_port | 2784 rc_server_key_file | rc_server_cert_file | rc_control_key_file | 2785 rc_control_cert_file | rc_control_use_cert 2786 ; 2787 rc_control_enable: VAR_CONTROL_ENABLE STRING_ARG 2788 { 2789 OUTYY(("P(control_enable:%s)\n", $2)); 2790 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2791 yyerror("expected yes or no."); 2792 else cfg_parser->cfg->remote_control_enable = 2793 (strcmp($2, "yes")==0); 2794 free($2); 2795 } 2796 ; 2797 rc_control_port: VAR_CONTROL_PORT STRING_ARG 2798 { 2799 OUTYY(("P(control_port:%s)\n", $2)); 2800 if(atoi($2) == 0) 2801 yyerror("control port number expected"); 2802 else cfg_parser->cfg->control_port = atoi($2); 2803 free($2); 2804 } 2805 ; 2806 rc_control_interface: VAR_CONTROL_INTERFACE STRING_ARG 2807 { 2808 OUTYY(("P(control_interface:%s)\n", $2)); 2809 if(!cfg_strlist_append(&cfg_parser->cfg->control_ifs, $2)) 2810 yyerror("out of memory"); 2811 } 2812 ; 2813 rc_control_use_cert: VAR_CONTROL_USE_CERT STRING_ARG 2814 { 2815 OUTYY(("P(control_use_cert:%s)\n", $2)); 2816 cfg_parser->cfg->control_use_cert = (strcmp($2, "yes")==0); 2817 free($2); 2818 } 2819 ; 2820 rc_server_key_file: VAR_SERVER_KEY_FILE STRING_ARG 2821 { 2822 OUTYY(("P(rc_server_key_file:%s)\n", $2)); 2823 free(cfg_parser->cfg->server_key_file); 2824 cfg_parser->cfg->server_key_file = $2; 2825 } 2826 ; 2827 rc_server_cert_file: VAR_SERVER_CERT_FILE STRING_ARG 2828 { 2829 OUTYY(("P(rc_server_cert_file:%s)\n", $2)); 2830 free(cfg_parser->cfg->server_cert_file); 2831 cfg_parser->cfg->server_cert_file = $2; 2832 } 2833 ; 2834 rc_control_key_file: VAR_CONTROL_KEY_FILE STRING_ARG 2835 { 2836 OUTYY(("P(rc_control_key_file:%s)\n", $2)); 2837 free(cfg_parser->cfg->control_key_file); 2838 cfg_parser->cfg->control_key_file = $2; 2839 } 2840 ; 2841 rc_control_cert_file: VAR_CONTROL_CERT_FILE STRING_ARG 2842 { 2843 OUTYY(("P(rc_control_cert_file:%s)\n", $2)); 2844 free(cfg_parser->cfg->control_cert_file); 2845 cfg_parser->cfg->control_cert_file = $2; 2846 } 2847 ; 2848 dtstart: VAR_DNSTAP 2849 { 2850 OUTYY(("\nP(dnstap:)\n")); 2851 } 2852 ; 2853 contents_dt: contents_dt content_dt 2854 | ; 2855 content_dt: dt_dnstap_enable | dt_dnstap_socket_path | dt_dnstap_bidirectional | 2856 dt_dnstap_ip | dt_dnstap_tls | dt_dnstap_tls_server_name | 2857 dt_dnstap_tls_cert_bundle | 2858 dt_dnstap_tls_client_key_file | dt_dnstap_tls_client_cert_file | 2859 dt_dnstap_send_identity | dt_dnstap_send_version | 2860 dt_dnstap_identity | dt_dnstap_version | 2861 dt_dnstap_log_resolver_query_messages | 2862 dt_dnstap_log_resolver_response_messages | 2863 dt_dnstap_log_client_query_messages | 2864 dt_dnstap_log_client_response_messages | 2865 dt_dnstap_log_forwarder_query_messages | 2866 dt_dnstap_log_forwarder_response_messages 2867 ; 2868 dt_dnstap_enable: VAR_DNSTAP_ENABLE STRING_ARG 2869 { 2870 OUTYY(("P(dt_dnstap_enable:%s)\n", $2)); 2871 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2872 yyerror("expected yes or no."); 2873 else cfg_parser->cfg->dnstap = (strcmp($2, "yes")==0); 2874 free($2); 2875 } 2876 ; 2877 dt_dnstap_bidirectional: VAR_DNSTAP_BIDIRECTIONAL STRING_ARG 2878 { 2879 OUTYY(("P(dt_dnstap_bidirectional:%s)\n", $2)); 2880 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2881 yyerror("expected yes or no."); 2882 else cfg_parser->cfg->dnstap_bidirectional = 2883 (strcmp($2, "yes")==0); 2884 free($2); 2885 } 2886 ; 2887 dt_dnstap_socket_path: VAR_DNSTAP_SOCKET_PATH STRING_ARG 2888 { 2889 OUTYY(("P(dt_dnstap_socket_path:%s)\n", $2)); 2890 free(cfg_parser->cfg->dnstap_socket_path); 2891 cfg_parser->cfg->dnstap_socket_path = $2; 2892 } 2893 ; 2894 dt_dnstap_ip: VAR_DNSTAP_IP STRING_ARG 2895 { 2896 OUTYY(("P(dt_dnstap_ip:%s)\n", $2)); 2897 free(cfg_parser->cfg->dnstap_ip); 2898 cfg_parser->cfg->dnstap_ip = $2; 2899 } 2900 ; 2901 dt_dnstap_tls: VAR_DNSTAP_TLS STRING_ARG 2902 { 2903 OUTYY(("P(dt_dnstap_tls:%s)\n", $2)); 2904 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2905 yyerror("expected yes or no."); 2906 else cfg_parser->cfg->dnstap_tls = (strcmp($2, "yes")==0); 2907 free($2); 2908 } 2909 ; 2910 dt_dnstap_tls_server_name: VAR_DNSTAP_TLS_SERVER_NAME STRING_ARG 2911 { 2912 OUTYY(("P(dt_dnstap_tls_server_name:%s)\n", $2)); 2913 free(cfg_parser->cfg->dnstap_tls_server_name); 2914 cfg_parser->cfg->dnstap_tls_server_name = $2; 2915 } 2916 ; 2917 dt_dnstap_tls_cert_bundle: VAR_DNSTAP_TLS_CERT_BUNDLE STRING_ARG 2918 { 2919 OUTYY(("P(dt_dnstap_tls_cert_bundle:%s)\n", $2)); 2920 free(cfg_parser->cfg->dnstap_tls_cert_bundle); 2921 cfg_parser->cfg->dnstap_tls_cert_bundle = $2; 2922 } 2923 ; 2924 dt_dnstap_tls_client_key_file: VAR_DNSTAP_TLS_CLIENT_KEY_FILE STRING_ARG 2925 { 2926 OUTYY(("P(dt_dnstap_tls_client_key_file:%s)\n", $2)); 2927 free(cfg_parser->cfg->dnstap_tls_client_key_file); 2928 cfg_parser->cfg->dnstap_tls_client_key_file = $2; 2929 } 2930 ; 2931 dt_dnstap_tls_client_cert_file: VAR_DNSTAP_TLS_CLIENT_CERT_FILE STRING_ARG 2932 { 2933 OUTYY(("P(dt_dnstap_tls_client_cert_file:%s)\n", $2)); 2934 free(cfg_parser->cfg->dnstap_tls_client_cert_file); 2935 cfg_parser->cfg->dnstap_tls_client_cert_file = $2; 2936 } 2937 ; 2938 dt_dnstap_send_identity: VAR_DNSTAP_SEND_IDENTITY STRING_ARG 2939 { 2940 OUTYY(("P(dt_dnstap_send_identity:%s)\n", $2)); 2941 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2942 yyerror("expected yes or no."); 2943 else cfg_parser->cfg->dnstap_send_identity = (strcmp($2, "yes")==0); 2944 free($2); 2945 } 2946 ; 2947 dt_dnstap_send_version: VAR_DNSTAP_SEND_VERSION STRING_ARG 2948 { 2949 OUTYY(("P(dt_dnstap_send_version:%s)\n", $2)); 2950 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2951 yyerror("expected yes or no."); 2952 else cfg_parser->cfg->dnstap_send_version = (strcmp($2, "yes")==0); 2953 free($2); 2954 } 2955 ; 2956 dt_dnstap_identity: VAR_DNSTAP_IDENTITY STRING_ARG 2957 { 2958 OUTYY(("P(dt_dnstap_identity:%s)\n", $2)); 2959 free(cfg_parser->cfg->dnstap_identity); 2960 cfg_parser->cfg->dnstap_identity = $2; 2961 } 2962 ; 2963 dt_dnstap_version: VAR_DNSTAP_VERSION STRING_ARG 2964 { 2965 OUTYY(("P(dt_dnstap_version:%s)\n", $2)); 2966 free(cfg_parser->cfg->dnstap_version); 2967 cfg_parser->cfg->dnstap_version = $2; 2968 } 2969 ; 2970 dt_dnstap_log_resolver_query_messages: VAR_DNSTAP_LOG_RESOLVER_QUERY_MESSAGES STRING_ARG 2971 { 2972 OUTYY(("P(dt_dnstap_log_resolver_query_messages:%s)\n", $2)); 2973 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2974 yyerror("expected yes or no."); 2975 else cfg_parser->cfg->dnstap_log_resolver_query_messages = 2976 (strcmp($2, "yes")==0); 2977 free($2); 2978 } 2979 ; 2980 dt_dnstap_log_resolver_response_messages: VAR_DNSTAP_LOG_RESOLVER_RESPONSE_MESSAGES STRING_ARG 2981 { 2982 OUTYY(("P(dt_dnstap_log_resolver_response_messages:%s)\n", $2)); 2983 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2984 yyerror("expected yes or no."); 2985 else cfg_parser->cfg->dnstap_log_resolver_response_messages = 2986 (strcmp($2, "yes")==0); 2987 free($2); 2988 } 2989 ; 2990 dt_dnstap_log_client_query_messages: VAR_DNSTAP_LOG_CLIENT_QUERY_MESSAGES STRING_ARG 2991 { 2992 OUTYY(("P(dt_dnstap_log_client_query_messages:%s)\n", $2)); 2993 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 2994 yyerror("expected yes or no."); 2995 else cfg_parser->cfg->dnstap_log_client_query_messages = 2996 (strcmp($2, "yes")==0); 2997 free($2); 2998 } 2999 ; 3000 dt_dnstap_log_client_response_messages: VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES STRING_ARG 3001 { 3002 OUTYY(("P(dt_dnstap_log_client_response_messages:%s)\n", $2)); 3003 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 3004 yyerror("expected yes or no."); 3005 else cfg_parser->cfg->dnstap_log_client_response_messages = 3006 (strcmp($2, "yes")==0); 3007 free($2); 3008 } 3009 ; 3010 dt_dnstap_log_forwarder_query_messages: VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES STRING_ARG 3011 { 3012 OUTYY(("P(dt_dnstap_log_forwarder_query_messages:%s)\n", $2)); 3013 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 3014 yyerror("expected yes or no."); 3015 else cfg_parser->cfg->dnstap_log_forwarder_query_messages = 3016 (strcmp($2, "yes")==0); 3017 free($2); 3018 } 3019 ; 3020 dt_dnstap_log_forwarder_response_messages: VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES STRING_ARG 3021 { 3022 OUTYY(("P(dt_dnstap_log_forwarder_response_messages:%s)\n", $2)); 3023 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 3024 yyerror("expected yes or no."); 3025 else cfg_parser->cfg->dnstap_log_forwarder_response_messages = 3026 (strcmp($2, "yes")==0); 3027 free($2); 3028 } 3029 ; 3030 pythonstart: VAR_PYTHON 3031 { 3032 OUTYY(("\nP(python:)\n")); 3033 } 3034 ; 3035 contents_py: contents_py content_py 3036 | ; 3037 content_py: py_script 3038 ; 3039 py_script: VAR_PYTHON_SCRIPT STRING_ARG 3040 { 3041 OUTYY(("P(python-script:%s)\n", $2)); 3042 if(!cfg_strlist_append_ex(&cfg_parser->cfg->python_script, $2)) 3043 yyerror("out of memory"); 3044 } 3045 dynlibstart: VAR_DYNLIB 3046 { 3047 OUTYY(("\nP(dynlib:)\n")); 3048 } 3049 ; 3050 contents_dl: contents_dl content_dl 3051 | ; 3052 content_dl: dl_file 3053 ; 3054 dl_file: VAR_DYNLIB_FILE STRING_ARG 3055 { 3056 OUTYY(("P(dynlib-file:%s)\n", $2)); 3057 if(!cfg_strlist_append_ex(&cfg_parser->cfg->dynlib_file, $2)) 3058 yyerror("out of memory"); 3059 } 3060 server_disable_dnssec_lame_check: VAR_DISABLE_DNSSEC_LAME_CHECK STRING_ARG 3061 { 3062 OUTYY(("P(disable_dnssec_lame_check:%s)\n", $2)); 3063 if (strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 3064 yyerror("expected yes or no."); 3065 else cfg_parser->cfg->disable_dnssec_lame_check = 3066 (strcmp($2, "yes")==0); 3067 free($2); 3068 } 3069 ; 3070 server_log_identity: VAR_LOG_IDENTITY STRING_ARG 3071 { 3072 OUTYY(("P(server_log_identity:%s)\n", $2)); 3073 free(cfg_parser->cfg->log_identity); 3074 cfg_parser->cfg->log_identity = $2; 3075 } 3076 ; 3077 server_response_ip: VAR_RESPONSE_IP STRING_ARG STRING_ARG 3078 { 3079 OUTYY(("P(server_response_ip:%s %s)\n", $2, $3)); 3080 validate_respip_action($3); 3081 if(!cfg_str2list_insert(&cfg_parser->cfg->respip_actions, 3082 $2, $3)) 3083 fatal_exit("out of memory adding response-ip"); 3084 } 3085 ; 3086 server_response_ip_data: VAR_RESPONSE_IP_DATA STRING_ARG STRING_ARG 3087 { 3088 OUTYY(("P(server_response_ip_data:%s)\n", $2)); 3089 if(!cfg_str2list_insert(&cfg_parser->cfg->respip_data, 3090 $2, $3)) 3091 fatal_exit("out of memory adding response-ip-data"); 3092 } 3093 ; 3094 dnscstart: VAR_DNSCRYPT 3095 { 3096 OUTYY(("\nP(dnscrypt:)\n")); 3097 } 3098 ; 3099 contents_dnsc: contents_dnsc content_dnsc 3100 | ; 3101 content_dnsc: 3102 dnsc_dnscrypt_enable | dnsc_dnscrypt_port | dnsc_dnscrypt_provider | 3103 dnsc_dnscrypt_secret_key | dnsc_dnscrypt_provider_cert | 3104 dnsc_dnscrypt_provider_cert_rotated | 3105 dnsc_dnscrypt_shared_secret_cache_size | 3106 dnsc_dnscrypt_shared_secret_cache_slabs | 3107 dnsc_dnscrypt_nonce_cache_size | 3108 dnsc_dnscrypt_nonce_cache_slabs 3109 ; 3110 dnsc_dnscrypt_enable: VAR_DNSCRYPT_ENABLE STRING_ARG 3111 { 3112 OUTYY(("P(dnsc_dnscrypt_enable:%s)\n", $2)); 3113 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 3114 yyerror("expected yes or no."); 3115 else cfg_parser->cfg->dnscrypt = (strcmp($2, "yes")==0); 3116 free($2); 3117 } 3118 ; 3119 3120 dnsc_dnscrypt_port: VAR_DNSCRYPT_PORT STRING_ARG 3121 { 3122 OUTYY(("P(dnsc_dnscrypt_port:%s)\n", $2)); 3123 if(atoi($2) == 0) 3124 yyerror("port number expected"); 3125 else cfg_parser->cfg->dnscrypt_port = atoi($2); 3126 free($2); 3127 } 3128 ; 3129 dnsc_dnscrypt_provider: VAR_DNSCRYPT_PROVIDER STRING_ARG 3130 { 3131 OUTYY(("P(dnsc_dnscrypt_provider:%s)\n", $2)); 3132 free(cfg_parser->cfg->dnscrypt_provider); 3133 cfg_parser->cfg->dnscrypt_provider = $2; 3134 } 3135 ; 3136 dnsc_dnscrypt_provider_cert: VAR_DNSCRYPT_PROVIDER_CERT STRING_ARG 3137 { 3138 OUTYY(("P(dnsc_dnscrypt_provider_cert:%s)\n", $2)); 3139 if(cfg_strlist_find(cfg_parser->cfg->dnscrypt_provider_cert, $2)) 3140 log_warn("dnscrypt-provider-cert %s is a duplicate", $2); 3141 if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert, $2)) 3142 fatal_exit("out of memory adding dnscrypt-provider-cert"); 3143 } 3144 ; 3145 dnsc_dnscrypt_provider_cert_rotated: VAR_DNSCRYPT_PROVIDER_CERT_ROTATED STRING_ARG 3146 { 3147 OUTYY(("P(dnsc_dnscrypt_provider_cert_rotated:%s)\n", $2)); 3148 if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_provider_cert_rotated, $2)) 3149 fatal_exit("out of memory adding dnscrypt-provider-cert-rotated"); 3150 } 3151 ; 3152 dnsc_dnscrypt_secret_key: VAR_DNSCRYPT_SECRET_KEY STRING_ARG 3153 { 3154 OUTYY(("P(dnsc_dnscrypt_secret_key:%s)\n", $2)); 3155 if(cfg_strlist_find(cfg_parser->cfg->dnscrypt_secret_key, $2)) 3156 log_warn("dnscrypt-secret-key: %s is a duplicate", $2); 3157 if(!cfg_strlist_insert(&cfg_parser->cfg->dnscrypt_secret_key, $2)) 3158 fatal_exit("out of memory adding dnscrypt-secret-key"); 3159 } 3160 ; 3161 dnsc_dnscrypt_shared_secret_cache_size: VAR_DNSCRYPT_SHARED_SECRET_CACHE_SIZE STRING_ARG 3162 { 3163 OUTYY(("P(dnscrypt_shared_secret_cache_size:%s)\n", $2)); 3164 if(!cfg_parse_memsize($2, &cfg_parser->cfg->dnscrypt_shared_secret_cache_size)) 3165 yyerror("memory size expected"); 3166 free($2); 3167 } 3168 ; 3169 dnsc_dnscrypt_shared_secret_cache_slabs: VAR_DNSCRYPT_SHARED_SECRET_CACHE_SLABS STRING_ARG 3170 { 3171 OUTYY(("P(dnscrypt_shared_secret_cache_slabs:%s)\n", $2)); 3172 if(atoi($2) == 0) 3173 yyerror("number expected"); 3174 else { 3175 cfg_parser->cfg->dnscrypt_shared_secret_cache_slabs = atoi($2); 3176 if(!is_pow2(cfg_parser->cfg->dnscrypt_shared_secret_cache_slabs)) 3177 yyerror("must be a power of 2"); 3178 } 3179 free($2); 3180 } 3181 ; 3182 dnsc_dnscrypt_nonce_cache_size: VAR_DNSCRYPT_NONCE_CACHE_SIZE STRING_ARG 3183 { 3184 OUTYY(("P(dnscrypt_nonce_cache_size:%s)\n", $2)); 3185 if(!cfg_parse_memsize($2, &cfg_parser->cfg->dnscrypt_nonce_cache_size)) 3186 yyerror("memory size expected"); 3187 free($2); 3188 } 3189 ; 3190 dnsc_dnscrypt_nonce_cache_slabs: VAR_DNSCRYPT_NONCE_CACHE_SLABS STRING_ARG 3191 { 3192 OUTYY(("P(dnscrypt_nonce_cache_slabs:%s)\n", $2)); 3193 if(atoi($2) == 0) 3194 yyerror("number expected"); 3195 else { 3196 cfg_parser->cfg->dnscrypt_nonce_cache_slabs = atoi($2); 3197 if(!is_pow2(cfg_parser->cfg->dnscrypt_nonce_cache_slabs)) 3198 yyerror("must be a power of 2"); 3199 } 3200 free($2); 3201 } 3202 ; 3203 cachedbstart: VAR_CACHEDB 3204 { 3205 OUTYY(("\nP(cachedb:)\n")); 3206 } 3207 ; 3208 contents_cachedb: contents_cachedb content_cachedb 3209 | ; 3210 content_cachedb: cachedb_backend_name | cachedb_secret_seed | 3211 redis_server_host | redis_server_port | redis_timeout | 3212 redis_expire_records 3213 ; 3214 cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG 3215 { 3216 #ifdef USE_CACHEDB 3217 OUTYY(("P(backend:%s)\n", $2)); 3218 free(cfg_parser->cfg->cachedb_backend); 3219 cfg_parser->cfg->cachedb_backend = $2; 3220 #else 3221 OUTYY(("P(Compiled without cachedb, ignoring)\n")); 3222 free($2); 3223 #endif 3224 } 3225 ; 3226 cachedb_secret_seed: VAR_CACHEDB_SECRETSEED STRING_ARG 3227 { 3228 #ifdef USE_CACHEDB 3229 OUTYY(("P(secret-seed:%s)\n", $2)); 3230 free(cfg_parser->cfg->cachedb_secret); 3231 cfg_parser->cfg->cachedb_secret = $2; 3232 #else 3233 OUTYY(("P(Compiled without cachedb, ignoring)\n")); 3234 free($2); 3235 #endif 3236 } 3237 ; 3238 redis_server_host: VAR_CACHEDB_REDISHOST STRING_ARG 3239 { 3240 #if defined(USE_CACHEDB) && defined(USE_REDIS) 3241 OUTYY(("P(redis_server_host:%s)\n", $2)); 3242 free(cfg_parser->cfg->redis_server_host); 3243 cfg_parser->cfg->redis_server_host = $2; 3244 #else 3245 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 3246 free($2); 3247 #endif 3248 } 3249 ; 3250 redis_server_port: VAR_CACHEDB_REDISPORT STRING_ARG 3251 { 3252 #if defined(USE_CACHEDB) && defined(USE_REDIS) 3253 int port; 3254 OUTYY(("P(redis_server_port:%s)\n", $2)); 3255 port = atoi($2); 3256 if(port == 0 || port < 0 || port > 65535) 3257 yyerror("valid redis server port number expected"); 3258 else cfg_parser->cfg->redis_server_port = port; 3259 #else 3260 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 3261 #endif 3262 free($2); 3263 } 3264 ; 3265 redis_timeout: VAR_CACHEDB_REDISTIMEOUT STRING_ARG 3266 { 3267 #if defined(USE_CACHEDB) && defined(USE_REDIS) 3268 OUTYY(("P(redis_timeout:%s)\n", $2)); 3269 if(atoi($2) == 0) 3270 yyerror("redis timeout value expected"); 3271 else cfg_parser->cfg->redis_timeout = atoi($2); 3272 #else 3273 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 3274 #endif 3275 free($2); 3276 } 3277 ; 3278 redis_expire_records: VAR_CACHEDB_REDISEXPIRERECORDS STRING_ARG 3279 { 3280 #if defined(USE_CACHEDB) && defined(USE_REDIS) 3281 OUTYY(("P(redis_expire_records:%s)\n", $2)); 3282 if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0) 3283 yyerror("expected yes or no."); 3284 else cfg_parser->cfg->redis_expire_records = (strcmp($2, "yes")==0); 3285 #else 3286 OUTYY(("P(Compiled without cachedb or redis, ignoring)\n")); 3287 #endif 3288 free($2); 3289 } 3290 ; 3291 server_tcp_connection_limit: VAR_TCP_CONNECTION_LIMIT STRING_ARG STRING_ARG 3292 { 3293 OUTYY(("P(server_tcp_connection_limit:%s %s)\n", $2, $3)); 3294 if (atoi($3) < 0) 3295 yyerror("positive number expected"); 3296 else { 3297 if(!cfg_str2list_insert(&cfg_parser->cfg->tcp_connection_limits, $2, $3)) 3298 fatal_exit("out of memory adding tcp connection limit"); 3299 } 3300 } 3301 ; 3302 ipsetstart: VAR_IPSET 3303 { 3304 OUTYY(("\nP(ipset:)\n")); 3305 } 3306 ; 3307 contents_ipset: contents_ipset content_ipset 3308 | ; 3309 content_ipset: ipset_name_v4 | ipset_name_v6 3310 ; 3311 ipset_name_v4: VAR_IPSET_NAME_V4 STRING_ARG 3312 { 3313 #ifdef USE_IPSET 3314 OUTYY(("P(name-v4:%s)\n", $2)); 3315 if(cfg_parser->cfg->ipset_name_v4) 3316 yyerror("ipset name v4 override, there must be one " 3317 "name for ip v4"); 3318 free(cfg_parser->cfg->ipset_name_v4); 3319 cfg_parser->cfg->ipset_name_v4 = $2; 3320 #else 3321 OUTYY(("P(Compiled without ipset, ignoring)\n")); 3322 free($2); 3323 #endif 3324 } 3325 ; 3326 ipset_name_v6: VAR_IPSET_NAME_V6 STRING_ARG 3327 { 3328 #ifdef USE_IPSET 3329 OUTYY(("P(name-v6:%s)\n", $2)); 3330 if(cfg_parser->cfg->ipset_name_v6) 3331 yyerror("ipset name v6 override, there must be one " 3332 "name for ip v6"); 3333 free(cfg_parser->cfg->ipset_name_v6); 3334 cfg_parser->cfg->ipset_name_v6 = $2; 3335 #else 3336 OUTYY(("P(Compiled without ipset, ignoring)\n")); 3337 free($2); 3338 #endif 3339 } 3340 ; 3341 %% 3342 3343 /* parse helper routines could be here */ 3344 static void 3345 validate_respip_action(const char* action) 3346 { 3347 if(strcmp(action, "deny")!=0 && 3348 strcmp(action, "redirect")!=0 && 3349 strcmp(action, "inform")!=0 && 3350 strcmp(action, "inform_deny")!=0 && 3351 strcmp(action, "always_transparent")!=0 && 3352 strcmp(action, "always_refuse")!=0 && 3353 strcmp(action, "always_nxdomain")!=0) 3354 { 3355 yyerror("response-ip action: expected deny, redirect, " 3356 "inform, inform_deny, always_transparent, " 3357 "always_refuse or always_nxdomain"); 3358 } 3359 } 3360 3361 3362