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