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