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