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