1 /* 2 * util/config_file.h - reads and stores the config file for unbound. 3 * 4 * Copyright (c) 2007, NLnet Labs. All rights reserved. 5 * 6 * This software is open source. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 19 * Neither the name of the NLNET LABS nor the names of its contributors may 20 * be used to endorse or promote products derived from this software without 21 * specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 /** 37 * \file 38 * 39 * This file contains functions for the config file. 40 */ 41 42 #ifndef UTIL_CONFIG_FILE_H 43 #define UTIL_CONFIG_FILE_H 44 #include "sldns/rrdef.h" 45 struct config_stub; 46 struct config_auth; 47 struct config_view; 48 struct config_strlist; 49 struct config_str2list; 50 struct config_str3list; 51 struct config_strbytelist; 52 struct module_qstate; 53 struct sock_list; 54 struct ub_packed_rrset_key; 55 struct regional; 56 57 /** List head for strlist processing, used for append operation. */ 58 struct config_strlist_head { 59 /** first in list of text items */ 60 struct config_strlist* first; 61 /** last in list of text items */ 62 struct config_strlist* last; 63 }; 64 65 /** 66 * The configuration options. 67 * Strings are malloced. 68 */ 69 struct config_file { 70 /** verbosity level as specified in the config file */ 71 int verbosity; 72 73 /** statistics interval (in seconds) */ 74 int stat_interval; 75 /** if false, statistics values are reset after printing them */ 76 int stat_cumulative; 77 /** if true, the statistics are kept in greater detail */ 78 int stat_extended; 79 /** if true, inhibits a lot of =0 lines from the extended stats output */ 80 int stat_inhibit_zero; 81 82 /** number of threads to create */ 83 int num_threads; 84 85 /** port on which queries are answered. */ 86 int port; 87 /** do ip4 query support. */ 88 int do_ip4; 89 /** do ip6 query support. */ 90 int do_ip6; 91 /** do nat64 on queries */ 92 int do_nat64; 93 /** prefer ip4 upstream queries. */ 94 int prefer_ip4; 95 /** prefer ip6 upstream queries. */ 96 int prefer_ip6; 97 /** do udp query support. */ 98 int do_udp; 99 /** do tcp query support. */ 100 int do_tcp; 101 /** max number of queries on a reuse connection. */ 102 size_t max_reuse_tcp_queries; 103 /** timeout for REUSE entries in milliseconds. */ 104 int tcp_reuse_timeout; 105 /** timeout in milliseconds for TCP queries to auth servers. */ 106 int tcp_auth_query_timeout; 107 /** tcp upstream queries (no UDP upstream queries) */ 108 int tcp_upstream; 109 /** udp upstream enabled when no UDP downstream is enabled (do_udp no)*/ 110 int udp_upstream_without_downstream; 111 /** maximum segment size of tcp socket which queries are answered */ 112 int tcp_mss; 113 /** maximum segment size of tcp socket for outgoing queries */ 114 int outgoing_tcp_mss; 115 /** tcp idle timeout, in msec */ 116 int tcp_idle_timeout; 117 /** do edns tcp keepalive */ 118 int do_tcp_keepalive; 119 /** tcp keepalive timeout, in msec */ 120 int tcp_keepalive_timeout; 121 /** timeout of packets sitting in the socket queue */ 122 int sock_queue_timeout; 123 /** proxy protocol ports */ 124 struct config_strlist* proxy_protocol_port; 125 126 /** private key file for dnstcp-ssl service (enabled if not NULL) */ 127 char* ssl_service_key; 128 /** public key file for dnstcp-ssl service */ 129 char* ssl_service_pem; 130 /** port on which to provide ssl service */ 131 int ssl_port; 132 /** if outgoing tcp connections use SSL */ 133 int ssl_upstream; 134 /** cert bundle for outgoing connections */ 135 char* tls_cert_bundle; 136 /** should the system certificate store get added to the cert bundle */ 137 int tls_win_cert; 138 /** additional tls ports */ 139 struct config_strlist* tls_additional_port; 140 /** secret key used to encrypt and decrypt TLS session ticket */ 141 struct config_strlist_head tls_session_ticket_keys; 142 /** TLS ciphers */ 143 char* tls_ciphers; 144 /** TLS chiphersuites (TLSv1.3) */ 145 char* tls_ciphersuites; 146 /** if SNI is to be used */ 147 int tls_use_sni; 148 149 /** port on which to provide DNS over HTTPS service */ 150 int https_port; 151 /** endpoint for HTTP service */ 152 char* http_endpoint; 153 /** MAX_CONCURRENT_STREAMS HTTP/2 setting */ 154 uint32_t http_max_streams; 155 /** maximum size of all HTTP2 query buffers combined. */ 156 size_t http_query_buffer_size; 157 /** maximum size of all HTTP2 response buffers combined. */ 158 size_t http_response_buffer_size; 159 /** set TCP_NODELAY option for http sockets */ 160 int http_nodelay; 161 /** Disable TLS for http sockets downstream */ 162 int http_notls_downstream; 163 164 /** outgoing port range number of ports (per thread) */ 165 int outgoing_num_ports; 166 /** number of outgoing tcp buffers per (per thread) */ 167 size_t outgoing_num_tcp; 168 /** number of incoming tcp buffers per (per thread) */ 169 size_t incoming_num_tcp; 170 /** allowed udp port numbers, array with 0 if not allowed */ 171 int* outgoing_avail_ports; 172 173 /** EDNS buffer size to use */ 174 size_t edns_buffer_size; 175 /** size of the stream wait buffers, max */ 176 size_t stream_wait_size; 177 /** number of bytes buffer size for DNS messages */ 178 size_t msg_buffer_size; 179 /** size of the message cache */ 180 size_t msg_cache_size; 181 /** slabs in the message cache. */ 182 size_t msg_cache_slabs; 183 /** number of queries every thread can service */ 184 size_t num_queries_per_thread; 185 /** number of msec to wait before items can be jostled out */ 186 size_t jostle_time; 187 /** size of the rrset cache */ 188 size_t rrset_cache_size; 189 /** slabs in the rrset cache */ 190 size_t rrset_cache_slabs; 191 /** host cache ttl in seconds */ 192 int host_ttl; 193 /** number of slabs in the infra host cache */ 194 size_t infra_cache_slabs; 195 /** max number of hosts in the infra cache */ 196 size_t infra_cache_numhosts; 197 /** min value for infra cache rtt (min retransmit timeout) */ 198 int infra_cache_min_rtt; 199 /** max value for infra cache rtt (max retransmit timeout) */ 200 int infra_cache_max_rtt; 201 /** keep probing hosts that are down */ 202 int infra_keep_probing; 203 /** delay close of udp-timeouted ports, if 0 no delayclose. in msec */ 204 int delay_close; 205 /** udp_connect enable uses UDP connect to mitigate ICMP side channel */ 206 int udp_connect; 207 208 /** the target fetch policy for the iterator */ 209 char* target_fetch_policy; 210 /** percent*10, how many times in 1000 to pick from the fastest 211 * destinations */ 212 int fast_server_permil; 213 /** number of fastest server to select from */ 214 size_t fast_server_num; 215 216 /** automatic interface for incoming messages. Uses ipv6 remapping, 217 * and recvmsg/sendmsg ancillary data to detect interfaces, boolean */ 218 int if_automatic; 219 /** extra ports to open if if_automatic enabled, or NULL for default */ 220 char* if_automatic_ports; 221 /** SO_RCVBUF size to set on port 53 UDP socket */ 222 size_t so_rcvbuf; 223 /** SO_SNDBUF size to set on port 53 UDP socket */ 224 size_t so_sndbuf; 225 /** SO_REUSEPORT requested on port 53 sockets */ 226 int so_reuseport; 227 /** IP_TRANSPARENT socket option requested on port 53 sockets */ 228 int ip_transparent; 229 /** IP_FREEBIND socket option request on port 53 sockets */ 230 int ip_freebind; 231 /** IP_TOS socket option requested on port 53 sockets */ 232 int ip_dscp; 233 234 /** number of interfaces to open. If 0 default all interfaces. */ 235 int num_ifs; 236 /** interface description strings (IP addresses) */ 237 char **ifs; 238 239 /** number of outgoing interfaces to open. 240 * If 0 default all interfaces. */ 241 int num_out_ifs; 242 /** outgoing interface description strings (IP addresses) */ 243 char **out_ifs; 244 245 /** the root hints */ 246 struct config_strlist* root_hints; 247 /** the stub definitions, linked list */ 248 struct config_stub* stubs; 249 /** the forward zone definitions, linked list */ 250 struct config_stub* forwards; 251 /** the auth zone definitions, linked list */ 252 struct config_auth* auths; 253 /** the views definitions, linked list */ 254 struct config_view* views; 255 /** list of donotquery addresses, linked list */ 256 struct config_strlist* donotqueryaddrs; 257 #ifdef CLIENT_SUBNET 258 /** list of servers we send edns-client-subnet option to and 259 * accept option from, linked list */ 260 struct config_strlist* client_subnet; 261 /** list of zones we send edns-client-subnet option for */ 262 struct config_strlist* client_subnet_zone; 263 /** opcode assigned by IANA for edns0-client-subnet option */ 264 uint16_t client_subnet_opcode; 265 /** Do not check whitelist if incoming query contains an ECS record */ 266 int client_subnet_always_forward; 267 /** Subnet length we are willing to give up privacy for */ 268 uint8_t max_client_subnet_ipv4; 269 uint8_t max_client_subnet_ipv6; 270 /** Minimum subnet length we are willing to answer */ 271 uint8_t min_client_subnet_ipv4; 272 uint8_t min_client_subnet_ipv6; 273 /** Max number of nodes in the ECS radix tree */ 274 uint32_t max_ecs_tree_size_ipv4; 275 uint32_t max_ecs_tree_size_ipv6; 276 #endif 277 /** list of access control entries, linked list */ 278 struct config_str2list* acls; 279 /** use default localhost donotqueryaddr entries */ 280 int donotquery_localhost; 281 282 /** list of tcp connection limitss, linked list */ 283 struct config_str2list* tcp_connection_limits; 284 285 /** harden against very small edns buffer sizes */ 286 int harden_short_bufsize; 287 /** harden against very large query sizes */ 288 int harden_large_queries; 289 /** harden against spoofed glue (out of zone data) */ 290 int harden_glue; 291 /** harden against receiving no DNSSEC data for trust anchor */ 292 int harden_dnssec_stripped; 293 /** harden against queries that fall under known nxdomain names */ 294 int harden_below_nxdomain; 295 /** harden the referral path, query for NS,A,AAAA and validate */ 296 int harden_referral_path; 297 /** harden against algorithm downgrade */ 298 int harden_algo_downgrade; 299 /** harden against unknown records in the authority section and in 300 * the additional section */ 301 int harden_unknown_additional; 302 /** use 0x20 bits in query as random ID bits */ 303 int use_caps_bits_for_id; 304 /** 0x20 whitelist, domains that do not use capsforid */ 305 struct config_strlist* caps_whitelist; 306 /** strip away these private addrs from answers, no DNS Rebinding */ 307 struct config_strlist* private_address; 308 /** allow domain (and subdomains) to use private address space */ 309 struct config_strlist* private_domain; 310 /** what threshold for unwanted action. */ 311 size_t unwanted_threshold; 312 /** the number of seconds maximal TTL used for RRsets and messages */ 313 int max_ttl; 314 /** the number of seconds minimum TTL used for RRsets and messages */ 315 int min_ttl; 316 /** the number of seconds maximal negative TTL for SOA in auth */ 317 int max_negative_ttl; 318 /** if prefetching of messages should be performed. */ 319 int prefetch; 320 /** if prefetching of DNSKEYs should be performed. */ 321 int prefetch_key; 322 /** deny queries of type ANY with an empty answer */ 323 int deny_any; 324 325 /** chrootdir, if not "" or chroot will be done */ 326 char* chrootdir; 327 /** username to change to, if not "". */ 328 char* username; 329 /** working directory */ 330 char* directory; 331 /** filename to log to. */ 332 char* logfile; 333 /** pidfile to write pid to. */ 334 char* pidfile; 335 336 /** should log messages be sent to syslogd */ 337 int use_syslog; 338 /** log timestamp in ascii UTC */ 339 int log_time_ascii; 340 /** log queries with one line per query */ 341 int log_queries; 342 /** log replies with one line per reply */ 343 int log_replies; 344 /** tag log_queries and log_replies for filtering */ 345 int log_tag_queryreply; 346 /** log every local-zone hit **/ 347 int log_local_actions; 348 /** log servfails with a reason */ 349 int log_servfail; 350 /** log identity to report */ 351 char* log_identity; 352 353 /** do not report identity (id.server, hostname.bind) */ 354 int hide_identity; 355 /** do not report version (version.server, version.bind) */ 356 int hide_version; 357 /** do not report trustanchor (trustanchor.unbound) */ 358 int hide_trustanchor; 359 /** do not report the User-Agent HTTP header */ 360 int hide_http_user_agent; 361 /** identity, hostname is returned if "". */ 362 char* identity; 363 /** version, package version returned if "". */ 364 char* version; 365 /** User-Agent for HTTP header */ 366 char* http_user_agent; 367 /** nsid */ 368 char *nsid_cfg_str; 369 uint8_t *nsid; 370 uint16_t nsid_len; 371 372 /** the module configuration string */ 373 char* module_conf; 374 375 /** files with trusted DS and DNSKEYs in zonefile format, list */ 376 struct config_strlist* trust_anchor_file_list; 377 /** list of trustanchor keys, linked list */ 378 struct config_strlist* trust_anchor_list; 379 /** files with 5011 autotrust tracked keys */ 380 struct config_strlist* auto_trust_anchor_file_list; 381 /** files with trusted DNSKEYs in named.conf format, list */ 382 struct config_strlist* trusted_keys_file_list; 383 /** insecure domain list */ 384 struct config_strlist* domain_insecure; 385 /** send key tag query */ 386 int trust_anchor_signaling; 387 /** enable root key sentinel */ 388 int root_key_sentinel; 389 390 /** if not 0, this value is the validation date for RRSIGs */ 391 int32_t val_date_override; 392 /** the minimum for signature clock skew */ 393 int32_t val_sig_skew_min; 394 /** the maximum for signature clock skew */ 395 int32_t val_sig_skew_max; 396 /** max number of query restarts, number of IPs to probe */ 397 int32_t val_max_restart; 398 /** this value sets the number of seconds before revalidating bogus */ 399 int bogus_ttl; 400 /** should validator clean additional section for secure msgs */ 401 int val_clean_additional; 402 /** log bogus messages by the validator */ 403 int val_log_level; 404 /** squelch val_log_level to log - this is library goes to callback */ 405 int val_log_squelch; 406 /** should validator allow bogus messages to go through */ 407 int val_permissive_mode; 408 /** use cached NSEC records to synthesise (negative) answers */ 409 int aggressive_nsec; 410 /** ignore the CD flag in incoming queries and refuse them bogus data */ 411 int ignore_cd; 412 /** serve expired entries and prefetch them */ 413 int serve_expired; 414 /** serve expired entries until TTL after expiration */ 415 int serve_expired_ttl; 416 /** reset serve expired TTL after failed update attempt */ 417 int serve_expired_ttl_reset; 418 /** TTL for the serve expired replies */ 419 int serve_expired_reply_ttl; 420 /** serve expired entries only after trying to update the entries and this 421 * timeout (in milliseconds) is reached */ 422 int serve_expired_client_timeout; 423 /** serve EDE code 3 - Stale Answer (RFC8914) for expired entries */ 424 int ede_serve_expired; 425 /** serve original TTLs rather than decrementing ones */ 426 int serve_original_ttl; 427 /** nsec3 maximum iterations per key size, string */ 428 char* val_nsec3_key_iterations; 429 /** if zonemd failures are permitted, only logged */ 430 int zonemd_permissive_mode; 431 /** autotrust add holddown time, in seconds */ 432 unsigned int add_holddown; 433 /** autotrust del holddown time, in seconds */ 434 unsigned int del_holddown; 435 /** autotrust keep_missing time, in seconds. 0 is forever. */ 436 unsigned int keep_missing; 437 /** permit small holddown values, allowing 5011 rollover very fast */ 438 int permit_small_holddown; 439 440 /** size of the key cache */ 441 size_t key_cache_size; 442 /** slabs in the key cache. */ 443 size_t key_cache_slabs; 444 /** size of the neg cache */ 445 size_t neg_cache_size; 446 447 /** local zones config */ 448 struct config_str2list* local_zones; 449 /** local zones nodefault list */ 450 struct config_strlist* local_zones_nodefault; 451 #ifdef USE_IPSET 452 /** local zones ipset list */ 453 struct config_strlist* local_zones_ipset; 454 #endif 455 /** do not add any default local zone */ 456 int local_zones_disable_default; 457 /** local data RRs configured */ 458 struct config_strlist* local_data; 459 /** local zone override types per netblock */ 460 struct config_str3list* local_zone_overrides; 461 /** unblock lan zones (reverse lookups for AS112 zones) */ 462 int unblock_lan_zones; 463 /** insecure lan zones (don't validate AS112 zones) */ 464 int insecure_lan_zones; 465 /** list of zonename, tagbitlist */ 466 struct config_strbytelist* local_zone_tags; 467 /** list of aclname, tagbitlist */ 468 struct config_strbytelist* acl_tags; 469 /** list of aclname, tagname, localzonetype */ 470 struct config_str3list* acl_tag_actions; 471 /** list of aclname, tagname, redirectdata */ 472 struct config_str3list* acl_tag_datas; 473 /** list of aclname, view*/ 474 struct config_str2list* acl_view; 475 /** list of interface action entries, linked list */ 476 struct config_str2list* interface_actions; 477 /** list of interface, tagbitlist */ 478 struct config_strbytelist* interface_tags; 479 /** list of interface, tagname, localzonetype */ 480 struct config_str3list* interface_tag_actions; 481 /** list of interface, tagname, redirectdata */ 482 struct config_str3list* interface_tag_datas; 483 /** list of interface, view*/ 484 struct config_str2list* interface_view; 485 /** list of IP-netblock, tagbitlist */ 486 struct config_strbytelist* respip_tags; 487 /** list of response-driven access control entries, linked list */ 488 struct config_str2list* respip_actions; 489 /** RRs configured for response-driven access controls */ 490 struct config_str2list* respip_data; 491 /** tag list, array with tagname[i] is malloced string */ 492 char** tagname; 493 /** number of items in the taglist */ 494 int num_tags; 495 496 /** remote control section. enable toggle. */ 497 int remote_control_enable; 498 /** the interfaces the remote control should listen on */ 499 struct config_strlist_head control_ifs; 500 /** if the use-cert option is set */ 501 int control_use_cert; 502 /** port number for the control port */ 503 int control_port; 504 /** private key file for server */ 505 char* server_key_file; 506 /** certificate file for server */ 507 char* server_cert_file; 508 /** private key file for unbound-control */ 509 char* control_key_file; 510 /** certificate file for unbound-control */ 511 char* control_cert_file; 512 513 /** Python script file */ 514 struct config_strlist* python_script; 515 516 /** Dynamic library file */ 517 struct config_strlist* dynlib_file; 518 519 /** Use systemd socket activation. */ 520 int use_systemd; 521 522 /** daemonize, i.e. fork into the background. */ 523 int do_daemonize; 524 525 /* minimal response when positive answer */ 526 int minimal_responses; 527 528 /* RRSet roundrobin */ 529 int rrset_roundrobin; 530 531 /* wait time for unknown server in msec */ 532 int unknown_server_time_limit; 533 534 /* maximum UDP response size */ 535 size_t max_udp_size; 536 537 /* DNS64 prefix */ 538 char* dns64_prefix; 539 540 /* Synthetize all AAAA record despite the presence of an authoritative one */ 541 int dns64_synthall; 542 /** ignore AAAAs for these domain names and use A record anyway */ 543 struct config_strlist* dns64_ignore_aaaa; 544 545 /* NAT64 prefix; if unset defaults to dns64_prefix */ 546 char* nat64_prefix; 547 548 /** true to enable dnstap support */ 549 int dnstap; 550 /** using bidirectional frame streams if true */ 551 int dnstap_bidirectional; 552 /** dnstap socket path */ 553 char* dnstap_socket_path; 554 /** dnstap IP */ 555 char* dnstap_ip; 556 /** dnstap TLS enable */ 557 int dnstap_tls; 558 /** dnstap tls server authentication name */ 559 char* dnstap_tls_server_name; 560 /** dnstap server cert bundle */ 561 char* dnstap_tls_cert_bundle; 562 /** dnstap client key for client authentication */ 563 char* dnstap_tls_client_key_file; 564 /** dnstap client cert for client authentication */ 565 char* dnstap_tls_client_cert_file; 566 /** true to send "identity" via dnstap */ 567 int dnstap_send_identity; 568 /** true to send "version" via dnstap */ 569 int dnstap_send_version; 570 /** dnstap "identity", hostname is used if "". */ 571 char* dnstap_identity; 572 /** dnstap "version", package version is used if "". */ 573 char* dnstap_version; 574 575 /** true to log dnstap RESOLVER_QUERY message events */ 576 int dnstap_log_resolver_query_messages; 577 /** true to log dnstap RESOLVER_RESPONSE message events */ 578 int dnstap_log_resolver_response_messages; 579 /** true to log dnstap CLIENT_QUERY message events */ 580 int dnstap_log_client_query_messages; 581 /** true to log dnstap CLIENT_RESPONSE message events */ 582 int dnstap_log_client_response_messages; 583 /** true to log dnstap FORWARDER_QUERY message events */ 584 int dnstap_log_forwarder_query_messages; 585 /** true to log dnstap FORWARDER_RESPONSE message events */ 586 int dnstap_log_forwarder_response_messages; 587 588 /** true to disable DNSSEC lameness check in iterator */ 589 int disable_dnssec_lame_check; 590 591 /** ratelimit for ip addresses. 0 is off, otherwise qps (unless overridden) */ 592 int ip_ratelimit; 593 /** ratelimit for ip addresses with a valid DNS Cookie. 0 is off, 594 * otherwise qps (unless overridden) */ 595 int ip_ratelimit_cookie; 596 /** number of slabs for ip_ratelimit cache */ 597 size_t ip_ratelimit_slabs; 598 /** memory size in bytes for ip_ratelimit cache */ 599 size_t ip_ratelimit_size; 600 /** ip_ratelimit factor, 0 blocks all, 10 allows 1/10 of traffic */ 601 int ip_ratelimit_factor; 602 /** ratelimit backoff, when on, if the limit is reached it is 603 * considered an attack and it backs off until 'demand' decreases over 604 * the RATE_WINDOW. */ 605 int ip_ratelimit_backoff; 606 607 /** ratelimit for domains. 0 is off, otherwise qps (unless overridden) */ 608 int ratelimit; 609 /** number of slabs for ratelimit cache */ 610 size_t ratelimit_slabs; 611 /** memory size in bytes for ratelimit cache */ 612 size_t ratelimit_size; 613 /** ratelimits for domain (exact match) */ 614 struct config_str2list* ratelimit_for_domain; 615 /** ratelimits below domain */ 616 struct config_str2list* ratelimit_below_domain; 617 /** ratelimit factor, 0 blocks all, 10 allows 1/10 of traffic */ 618 int ratelimit_factor; 619 /** ratelimit backoff, when on, if the limit is reached it is 620 * considered an attack and it backs off until 'demand' decreases over 621 * the RATE_WINDOW. */ 622 int ratelimit_backoff; 623 624 /** number of retries on outgoing queries */ 625 int outbound_msg_retry; 626 /** max sent queries per qstate; resets on query restarts (e.g., 627 * CNAMES) and referrals */ 628 int max_sent_count; 629 /** max number of query restarts; determines max length of CNAME chain */ 630 int max_query_restarts; 631 /** minimise outgoing QNAME and hide original QTYPE if possible */ 632 int qname_minimisation; 633 /** minimise QNAME in strict mode, minimise according to RFC. 634 * Do not apply fallback */ 635 int qname_minimisation_strict; 636 /** SHM data - true if shm is enabled */ 637 int shm_enable; 638 /** SHM data - key for the shm */ 639 int shm_key; 640 641 /** list of EDNS client string entries, linked list */ 642 struct config_str2list* edns_client_strings; 643 /** EDNS opcode to use for EDNS client strings */ 644 uint16_t edns_client_string_opcode; 645 646 /** DNSCrypt */ 647 /** true to enable dnscrypt */ 648 int dnscrypt; 649 /** port on which to provide dnscrypt service */ 650 int dnscrypt_port; 651 /** provider name 2.dnscrypt-cert.example.com */ 652 char* dnscrypt_provider; 653 /** dnscrypt secret keys 1.key */ 654 struct config_strlist* dnscrypt_secret_key; 655 /** dnscrypt provider certs 1.cert */ 656 struct config_strlist* dnscrypt_provider_cert; 657 /** dnscrypt provider certs 1.cert which have been rotated and should not be 658 * advertised through DNS's providername TXT record but are required to be 659 * able to handle existing traffic using the old cert. */ 660 struct config_strlist* dnscrypt_provider_cert_rotated; 661 /** memory size in bytes for dnscrypt shared secrets cache */ 662 size_t dnscrypt_shared_secret_cache_size; 663 /** number of slabs for dnscrypt shared secrets cache */ 664 size_t dnscrypt_shared_secret_cache_slabs; 665 /** memory size in bytes for dnscrypt nonces cache */ 666 size_t dnscrypt_nonce_cache_size; 667 /** number of slabs for dnscrypt nonces cache */ 668 size_t dnscrypt_nonce_cache_slabs; 669 670 /** EDNS padding according to RFC7830 and RFC8467 */ 671 /** true to enable padding of responses (default: on) */ 672 int pad_responses; 673 /** block size with which to pad encrypted responses (default: 468) */ 674 size_t pad_responses_block_size; 675 /** true to enable padding of queries (default: on) */ 676 int pad_queries; 677 /** block size with which to pad encrypted queries (default: 128) */ 678 size_t pad_queries_block_size; 679 680 /** IPsec module */ 681 #ifdef USE_IPSECMOD 682 /** false to bypass the IPsec module */ 683 int ipsecmod_enabled; 684 /** whitelisted domains for ipsecmod */ 685 struct config_strlist* ipsecmod_whitelist; 686 /** path to external hook */ 687 char* ipsecmod_hook; 688 /** true to proceed even with a bogus IPSECKEY */ 689 int ipsecmod_ignore_bogus; 690 /** max TTL for the A/AAAA records that call the hook */ 691 int ipsecmod_max_ttl; 692 /** false to proceed even when ipsecmod_hook fails */ 693 int ipsecmod_strict; 694 #endif 695 696 /* cachedb module */ 697 #ifdef USE_CACHEDB 698 /** backend DB name */ 699 char* cachedb_backend; 700 /** secret seed for hash key calculation */ 701 char* cachedb_secret; 702 #ifdef USE_REDIS 703 /** redis server's IP address or host name */ 704 char* redis_server_host; 705 /** redis server's TCP port */ 706 int redis_server_port; 707 /** redis server's unix path. Or "", NULL if unused */ 708 char* redis_server_path; 709 /** redis server's AUTH password. Or "", NULL if unused */ 710 char* redis_server_password; 711 /** timeout (in ms) for communication with the redis server */ 712 int redis_timeout; 713 /** set timeout on redis records based on DNS response ttl */ 714 int redis_expire_records; 715 #endif 716 #endif 717 /** Downstream DNS Cookies */ 718 /** do answer with server cookie when request contained cookie option */ 719 int do_answer_cookie; 720 /** cookie secret */ 721 uint8_t cookie_secret[40]; 722 /** cookie secret length */ 723 size_t cookie_secret_len; 724 725 /* ipset module */ 726 #ifdef USE_IPSET 727 char* ipset_name_v4; 728 char* ipset_name_v6; 729 #endif 730 /** respond with Extended DNS Errors (RFC8914) */ 731 int ede; 732 }; 733 734 /** from cfg username, after daemonize setup performed */ 735 extern uid_t cfg_uid; 736 /** from cfg username, after daemonize setup performed */ 737 extern gid_t cfg_gid; 738 /** debug and enable small timeouts */ 739 extern int autr_permit_small_holddown; 740 /** size (in bytes) of stream wait buffers max */ 741 extern size_t stream_wait_max; 742 /** size (in bytes) of all total HTTP2 query buffers max */ 743 extern size_t http2_query_buffer_max; 744 /** size (in bytes) of all total HTTP2 response buffers max */ 745 extern size_t http2_response_buffer_max; 746 747 /** 748 * Stub config options 749 */ 750 struct config_stub { 751 /** next in list */ 752 struct config_stub* next; 753 /** domain name (in text) of the stub apex domain */ 754 char* name; 755 /** list of stub nameserver hosts (domain name) */ 756 struct config_strlist* hosts; 757 /** list of stub nameserver addresses (IP address) */ 758 struct config_strlist* addrs; 759 /** if stub-prime is set */ 760 int isprime; 761 /** if forward-first is set (failover to without if fails) */ 762 int isfirst; 763 /** use tcp for queries to this stub */ 764 int tcp_upstream; 765 /** use SSL for queries to this stub */ 766 int ssl_upstream; 767 /*** no cache */ 768 int no_cache; 769 }; 770 771 /** 772 * Auth config options 773 */ 774 struct config_auth { 775 /** next in list */ 776 struct config_auth* next; 777 /** domain name (in text) of the auth apex domain */ 778 char* name; 779 /** list of masters */ 780 struct config_strlist* masters; 781 /** list of urls */ 782 struct config_strlist* urls; 783 /** list of allow-notify */ 784 struct config_strlist* allow_notify; 785 /** zonefile (or NULL) */ 786 char* zonefile; 787 /** provide downstream answers */ 788 int for_downstream; 789 /** provide upstream answers */ 790 int for_upstream; 791 /** fallback to recursion to authorities if zone expired and other 792 * reasons perhaps (like, query bogus) */ 793 int fallback_enabled; 794 /** this zone is used to create local-zone policies */ 795 int isrpz; 796 /** rpz tags (or NULL) */ 797 uint8_t* rpz_taglist; 798 /** length of the taglist (in bytes) */ 799 size_t rpz_taglistlen; 800 /** Override RPZ action for this zone, regardless of zone content */ 801 char* rpz_action_override; 802 /** Log when this RPZ policy is applied */ 803 int rpz_log; 804 /** Display this name in the log when RPZ policy is applied */ 805 char* rpz_log_name; 806 /** Always reply with this CNAME target if the cname override action is 807 * used */ 808 char* rpz_cname; 809 /** signal nxdomain block with unset RA */ 810 int rpz_signal_nxdomain_ra; 811 /** Check ZONEMD records for this zone */ 812 int zonemd_check; 813 /** Reject absence of ZONEMD records, zone must have one */ 814 int zonemd_reject_absence; 815 }; 816 817 /** 818 * View config options 819 */ 820 struct config_view { 821 /** next in list */ 822 struct config_view* next; 823 /** view name */ 824 char* name; 825 /** local zones */ 826 struct config_str2list* local_zones; 827 /** local data RRs */ 828 struct config_strlist* local_data; 829 /** local zones nodefault list */ 830 struct config_strlist* local_zones_nodefault; 831 #ifdef USE_IPSET 832 /** local zones ipset list */ 833 struct config_strlist* local_zones_ipset; 834 #endif 835 /** Fallback to global local_zones when there is no match in the view 836 * view specific tree. 1 for yes, 0 for no */ 837 int isfirst; 838 /** predefined actions for particular IP address responses */ 839 struct config_str2list* respip_actions; 840 /** data complementing the 'redirect' response IP actions */ 841 struct config_str2list* respip_data; 842 }; 843 844 /** 845 * List of strings for config options 846 */ 847 struct config_strlist { 848 /** next item in list */ 849 struct config_strlist* next; 850 /** config option string */ 851 char* str; 852 }; 853 854 /** 855 * List of two strings for config options 856 */ 857 struct config_str2list { 858 /** next item in list */ 859 struct config_str2list* next; 860 /** first string */ 861 char* str; 862 /** second string */ 863 char* str2; 864 }; 865 866 /** 867 * List of three strings for config options 868 */ 869 struct config_str3list { 870 /** next item in list */ 871 struct config_str3list* next; 872 /** first string */ 873 char* str; 874 /** second string */ 875 char* str2; 876 /** third string */ 877 char* str3; 878 }; 879 880 881 /** 882 * List of string, bytestring for config options 883 */ 884 struct config_strbytelist { 885 /** next item in list */ 886 struct config_strbytelist* next; 887 /** first string */ 888 char* str; 889 /** second bytestring */ 890 uint8_t* str2; 891 size_t str2len; 892 }; 893 894 /** 895 * Create config file structure. Filled with default values. 896 * @return: the new structure or NULL on memory error. 897 */ 898 struct config_file* config_create(void); 899 900 /** 901 * Create config file structure for library use. Filled with default values. 902 * @return: the new structure or NULL on memory error. 903 */ 904 struct config_file* config_create_forlib(void); 905 906 /** 907 * Read the config file from the specified filename. 908 * @param config: where options are stored into, must be freshly created. 909 * @param filename: name of configfile. If NULL nothing is done. 910 * @param chroot: if not NULL, the chroot dir currently in use (for include). 911 * @return: false on error. In that case errno is set, ENOENT means 912 * file not found. 913 */ 914 int config_read(struct config_file* config, const char* filename, 915 const char* chroot); 916 917 /** 918 * Destroy the config file structure. 919 * @param config: to delete. 920 */ 921 void config_delete(struct config_file* config); 922 923 /** 924 * Apply config to global constants; this routine is called in single thread. 925 * @param config: to apply. Side effect: global constants change. 926 */ 927 void config_apply(struct config_file* config); 928 929 /** 930 * Find username, sets cfg_uid and cfg_gid. 931 * @param config: the config structure. 932 */ 933 void config_lookup_uid(struct config_file* config); 934 935 /** 936 * Set the given keyword to the given value. 937 * @param config: where to store config 938 * @param option: option name, including the ':' character. 939 * @param value: value, this string is copied if needed, or parsed. 940 * The caller owns the value string. 941 * @return 0 on error (malloc or syntax error). 942 */ 943 int config_set_option(struct config_file* config, const char* option, 944 const char* value); 945 946 /** 947 * Call print routine for the given option. 948 * @param cfg: config. 949 * @param opt: option name without trailing :. 950 * This is different from config_set_option. 951 * @param func: print func, called as (str, arg) for every data element. 952 * @param arg: user argument for print func. 953 * @return false if the option name is not supported (syntax error). 954 */ 955 int config_get_option(struct config_file* cfg, const char* opt, 956 void (*func)(char*,void*), void* arg); 957 958 /** 959 * Get an option and return strlist 960 * @param cfg: config file 961 * @param opt: option name. 962 * @param list: list is returned here. malloced, caller must free it. 963 * @return 0=OK, 1=syntax error, 2=malloc failed. 964 */ 965 int config_get_option_list(struct config_file* cfg, const char* opt, 966 struct config_strlist** list); 967 968 /** 969 * Get an option and collate results into string 970 * @param cfg: config file 971 * @param opt: option name. 972 * @param str: string. malloced, caller must free it. 973 * @return 0=OK, 1=syntax error, 2=malloc failed. 974 */ 975 int config_get_option_collate(struct config_file* cfg, const char* opt, 976 char** str); 977 978 /** 979 * function to print to a file, use as func with config_get_option. 980 * @param line: text to print. \n appended. 981 * @param arg: pass a FILE*, like stdout. 982 */ 983 void config_print_func(char* line, void* arg); 984 985 /** 986 * function to collate the text strings into a strlist_head. 987 * @param line: text to append. 988 * @param arg: pass a strlist_head structure. zeroed on start. 989 */ 990 void config_collate_func(char* line, void* arg); 991 992 /** 993 * take a strlist_head list and return a malloc string. separated with newline. 994 * @param list: strlist first to collate. zeroes return "". 995 * @return NULL on malloc failure. Or if malloc failure happened in strlist. 996 */ 997 char* config_collate_cat(struct config_strlist* list); 998 999 /** 1000 * Append text at end of list. 1001 * @param list: list head. zeroed at start. 1002 * @param item: new item. malloced by caller. if NULL the insertion fails. 1003 * @return true on success. 1004 * on fail the item is free()ed. 1005 */ 1006 int cfg_strlist_append(struct config_strlist_head* list, char* item); 1007 1008 /** 1009 * Searches the end of a string list and appends the given text. 1010 * @param head: pointer to strlist head variable. 1011 * @param item: new item. malloced by caller. if NULL the insertion fails. 1012 * @return true on success. 1013 */ 1014 int cfg_strlist_append_ex(struct config_strlist** head, char* item); 1015 1016 /** 1017 * Find string in strlist. 1018 * @param head: pointer to strlist head variable. 1019 * @param item: the item to search for. 1020 * @return: the element in the list when found, NULL otherwise. 1021 */ 1022 struct config_strlist* cfg_strlist_find(struct config_strlist* head, 1023 const char* item); 1024 1025 /** 1026 * Insert string into strlist. 1027 * @param head: pointer to strlist head variable. 1028 * @param item: new item. malloced by caller. If NULL the insertion fails. 1029 * @return: true on success. 1030 * on fail, the item is free()d. 1031 */ 1032 int cfg_strlist_insert(struct config_strlist** head, char* item); 1033 1034 /** insert with region for allocation. */ 1035 int cfg_region_strlist_insert(struct regional* region, 1036 struct config_strlist** head, char* item); 1037 1038 /** 1039 * Insert string into str2list. 1040 * @param head: pointer to str2list head variable. 1041 * @param item: new item. malloced by caller. If NULL the insertion fails. 1042 * @param i2: 2nd string, malloced by caller. If NULL the insertion fails. 1043 * @return: true on success. 1044 * on fail, the item and i2 are free()d. 1045 */ 1046 int cfg_str2list_insert(struct config_str2list** head, char* item, char* i2); 1047 1048 /** 1049 * Insert string into str3list. 1050 * @param head: pointer to str3list head variable. 1051 * @param item: new item. malloced by caller. If NULL the insertion fails. 1052 * @param i2: 2nd string, malloced by caller. If NULL the insertion fails. 1053 * @param i3: 3rd string, malloced by caller. If NULL the insertion fails. 1054 * @return: true on success. 1055 */ 1056 int cfg_str3list_insert(struct config_str3list** head, char* item, char* i2, 1057 char* i3); 1058 1059 /** 1060 * Insert string into strbytelist. 1061 * @param head: pointer to strbytelist head variable. 1062 * @param item: new item. malloced by caller. If NULL the insertion fails. 1063 * @param i2: 2nd string, malloced by caller. If NULL the insertion fails. 1064 * @param i2len: length of the i2 bytestring. 1065 * @return: true on success. 1066 */ 1067 int cfg_strbytelist_insert(struct config_strbytelist** head, char* item, 1068 uint8_t* i2, size_t i2len); 1069 1070 /** 1071 * Find stub in config list, also returns prevptr (for deletion). 1072 * @param pp: call routine with pointer to a pointer to the start of the list, 1073 * if the stub is found, on exit, the value contains a pointer to the 1074 * next pointer that points to the found element (or to the list start 1075 * pointer if it is the first element). 1076 * @param nm: name of stub to find. 1077 * @return: pointer to config_stub if found, or NULL if not found. 1078 */ 1079 struct config_stub* cfg_stub_find(struct config_stub*** pp, const char* nm); 1080 1081 /** 1082 * Delete items in config string list. 1083 * @param list: list. 1084 */ 1085 void config_delstrlist(struct config_strlist* list); 1086 1087 /** 1088 * Delete items in config double string list. 1089 * @param list: list. 1090 */ 1091 void config_deldblstrlist(struct config_str2list* list); 1092 1093 /** 1094 * Delete items in config triple string list. 1095 * @param list: list. 1096 */ 1097 void config_deltrplstrlist(struct config_str3list* list); 1098 1099 /** delete string array */ 1100 void config_del_strarray(char** array, int num); 1101 1102 /** delete stringbytelist */ 1103 void config_del_strbytelist(struct config_strbytelist* list); 1104 1105 /** 1106 * Delete a stub item 1107 * @param p: stub item 1108 */ 1109 void config_delstub(struct config_stub* p); 1110 1111 /** 1112 * Delete items in config stub list. 1113 * @param list: list. 1114 */ 1115 void config_delstubs(struct config_stub* list); 1116 1117 /** 1118 * Delete an auth item 1119 * @param p: auth item 1120 */ 1121 void config_delauth(struct config_auth* p); 1122 1123 /** 1124 * Delete items in config auth list. 1125 * @param list: list. 1126 */ 1127 void config_delauths(struct config_auth* list); 1128 1129 /** 1130 * Delete a view item 1131 * @param p: view item 1132 */ 1133 void config_delview(struct config_view* p); 1134 1135 /** 1136 * Delete items in config view list. 1137 * @param list: list. 1138 */ 1139 void config_delviews(struct config_view* list); 1140 1141 /** check if config for remote control turns on IP-address interface 1142 * with certificates or a named pipe without certificates. */ 1143 int options_remote_is_address(struct config_file* cfg); 1144 1145 /** 1146 * Convert 14digit to time value 1147 * @param str: string of 14 digits 1148 * @return time value or 0 for error. 1149 */ 1150 time_t cfg_convert_timeval(const char* str); 1151 1152 /** 1153 * Count number of values in the string. 1154 * format ::= (sp num)+ sp 1155 * num ::= [-](0-9)+ 1156 * sp ::= (space|tab)* 1157 * 1158 * @param str: string 1159 * @return: 0 on parse error, or empty string, else 1160 * number of integer values in the string. 1161 */ 1162 int cfg_count_numbers(const char* str); 1163 1164 /** 1165 * Convert a 'nice' memory or file size into a bytecount 1166 * From '100k' to 102400. and so on. Understands kKmMgG. 1167 * k=1024, m=1024*1024, g=1024*1024*1024. 1168 * @param str: string 1169 * @param res: result is stored here, size in bytes. 1170 * @return: true if parsed correctly, or 0 on a parse error (and an error 1171 * is logged). 1172 */ 1173 int cfg_parse_memsize(const char* str, size_t* res); 1174 1175 /** 1176 * Parse nsid from string into binary nsid. nsid is either a hexadecimal 1177 * string or an ascii string prepended with ascii_ in which case the 1178 * characters after ascii_ are simply copied. 1179 * @param str: the string to parse. 1180 * @param nsid_len: returns length of nsid in bytes. 1181 * @return malloced bytes or NULL on parse error or malloc failure. 1182 */ 1183 uint8_t* cfg_parse_nsid(const char* str, uint16_t* nsid_len); 1184 1185 /** 1186 * Add a tag name to the config. It is added at the end with a new ID value. 1187 * @param cfg: the config structure. 1188 * @param tag: string (which is copied) with the name. 1189 * @return: false on alloc failure. 1190 */ 1191 int config_add_tag(struct config_file* cfg, const char* tag); 1192 1193 /** 1194 * Find tag ID in the tag list. 1195 * @param cfg: the config structure. 1196 * @param tag: string with tag name to search for. 1197 * @return: 0..(num_tags-1) with tag ID, or -1 if tagname is not found. 1198 */ 1199 int find_tag_id(struct config_file* cfg, const char* tag); 1200 1201 /** 1202 * parse taglist from string into bytestring with bitlist. 1203 * @param cfg: the config structure (with tagnames) 1204 * @param str: the string to parse. Parse puts 0 bytes in string. 1205 * @param listlen: returns length of in bytes. 1206 * @return malloced bytes with a bitlist of the tags. or NULL on parse error 1207 * or malloc failure. 1208 */ 1209 uint8_t* config_parse_taglist(struct config_file* cfg, char* str, 1210 size_t* listlen); 1211 1212 /** 1213 * convert tag bitlist to a malloced string with tag names. For debug output. 1214 * @param cfg: the config structure (with tagnames) 1215 * @param taglist: the tag bitlist. 1216 * @param len: length of the tag bitlist. 1217 * @return malloced string or NULL. 1218 */ 1219 char* config_taglist2str(struct config_file* cfg, uint8_t* taglist, 1220 size_t len); 1221 1222 /** 1223 * see if two taglists intersect (have tags in common). 1224 * @param list1: first tag bitlist. 1225 * @param list1len: length in bytes of first list. 1226 * @param list2: second tag bitlist. 1227 * @param list2len: length in bytes of second list. 1228 * @return true if there are tags in common, 0 if not. 1229 */ 1230 int taglist_intersect(uint8_t* list1, size_t list1len, const uint8_t* list2, 1231 size_t list2len); 1232 1233 /** 1234 * Parse local-zone directive into two strings and register it in the config. 1235 * @param cfg: to put it in. 1236 * @param val: argument strings to local-zone, "example.com nodefault". 1237 * @return: false on failure 1238 */ 1239 int cfg_parse_local_zone(struct config_file* cfg, const char* val); 1240 1241 /** 1242 * Mark "number" or "low-high" as available or not in ports array. 1243 * @param str: string in input 1244 * @param allow: give true if this range is permitted. 1245 * @param avail: the array from cfg. 1246 * @param num: size of the array (65536). 1247 * @return: true if parsed correctly, or 0 on a parse error (and an error 1248 * is logged). 1249 */ 1250 int cfg_mark_ports(const char* str, int allow, int* avail, int num); 1251 1252 /** 1253 * Get a condensed list of ports returned. allocated. 1254 * @param cfg: config file. 1255 * @param avail: the available ports array is returned here. 1256 * @return: number of ports in array or 0 on error. 1257 */ 1258 int cfg_condense_ports(struct config_file* cfg, int** avail); 1259 1260 /** 1261 * Apply system specific port range policy. 1262 * @param cfg: config file. 1263 * @param num: size of the array (65536). 1264 */ 1265 void cfg_apply_local_port_policy(struct config_file* cfg, int num); 1266 1267 /** 1268 * Scan ports available 1269 * @param avail: the array from cfg. 1270 * @param num: size of the array (65536). 1271 * @return the number of ports available for use. 1272 */ 1273 int cfg_scan_ports(int* avail, int num); 1274 1275 /** 1276 * Convert a filename to full pathname in original filesys 1277 * @param fname: the path name to convert. 1278 * Must not be null or empty. 1279 * @param cfg: config struct for chroot and chdir (if set). 1280 * @param use_chdir: if false, only chroot is applied. 1281 * @return pointer to malloced buffer which is: [chroot][chdir]fname 1282 * or NULL on malloc failure. 1283 */ 1284 char* fname_after_chroot(const char* fname, struct config_file* cfg, 1285 int use_chdir); 1286 1287 /** 1288 * Convert a ptr shorthand into a full reverse-notation PTR record. 1289 * @param str: input string, "IP name" 1290 * @return: malloced string "reversed-ip-name PTR name" 1291 */ 1292 char* cfg_ptr_reverse(char* str); 1293 1294 /** 1295 * Used during options parsing 1296 */ 1297 struct config_parser_state { 1298 /** name of file being parser */ 1299 char* filename; 1300 /** line number in the file, starts at 1 */ 1301 int line; 1302 /** number of errors encountered */ 1303 int errors; 1304 /** the result of parsing is stored here. */ 1305 struct config_file* cfg; 1306 /** the current chroot dir (or NULL if none) */ 1307 const char* chroot; 1308 /** if we are started in a toplevel, or not, after a force_toplevel */ 1309 int started_toplevel; 1310 }; 1311 1312 /** global config parser object used during config parsing */ 1313 extern struct config_parser_state* cfg_parser; 1314 /** init lex state */ 1315 void init_cfg_parse(void); 1316 /** lex in file */ 1317 extern FILE* ub_c_in; 1318 /** lex out file */ 1319 extern FILE* ub_c_out; 1320 /** the yacc lex generated parse function */ 1321 int ub_c_parse(void); 1322 /** the lexer function */ 1323 int ub_c_lex(void); 1324 /** wrap function */ 1325 int ub_c_wrap(void); 1326 /** parsing helpers: print error with file and line numbers */ 1327 void ub_c_error(const char* msg); 1328 /** parsing helpers: print error with file and line numbers */ 1329 void ub_c_error_msg(const char* fmt, ...) ATTR_FORMAT(printf, 1, 2); 1330 1331 #ifdef UB_ON_WINDOWS 1332 /** 1333 * Obtain registry string (if it exists). 1334 * @param key: key string 1335 * @param name: name of value to fetch. 1336 * @return malloced string with the result or NULL if it did not 1337 * exist on an error (logged with log_err) was encountered. 1338 */ 1339 char* w_lookup_reg_str(const char* key, const char* name); 1340 1341 /** Modify directory in options for module file name */ 1342 void w_config_adjust_directory(struct config_file* cfg); 1343 #endif /* UB_ON_WINDOWS */ 1344 1345 /** debug option for unit tests. */ 1346 extern int fake_dsa, fake_sha1; 1347 1348 /** see if interface is https, its port number == the https port number */ 1349 int if_is_https(const char* ifname, const char* port, int https_port); 1350 1351 /** 1352 * Return true if the config contains settings that enable https. 1353 * @param cfg: config information. 1354 * @return true if https ports are used for server. 1355 */ 1356 int cfg_has_https(struct config_file* cfg); 1357 1358 /** see if interface is PROXYv2, its port number == the proxy port number */ 1359 int if_is_pp2(const char* ifname, const char* port, 1360 struct config_strlist* proxy_protocol_port); 1361 1362 /** see if interface is DNSCRYPT, its port number == the dnscrypt port number */ 1363 int if_is_dnscrypt(const char* ifname, const char* port, int dnscrypt_port); 1364 #ifdef USE_LINUX_IP_LOCAL_PORT_RANGE 1365 #define LINUX_IP_LOCAL_PORT_RANGE_PATH "/proc/sys/net/ipv4/ip_local_port_range" 1366 #endif 1367 1368 #endif /* UTIL_CONFIG_FILE_H */ 1369