This file contains functions for the config file. More...
#include "sldns/rrdef.h"
Data Structures | |
struct | config_strlist_head |
List head for strlist processing, used for append operation. More... | |
struct | config_file |
The configuration options. More... | |
struct | config_stub |
Stub config options. More... | |
struct | config_auth |
Auth config options. More... | |
struct | config_view |
View config options. More... | |
struct | config_strlist |
List of strings for config options. More... | |
struct | config_str2list |
List of two strings for config options. More... | |
struct | config_str3list |
List of three strings for config options. More... | |
struct | config_strbytelist |
List of string, bytestring for config options. More... | |
struct | config_parser_state |
Used during options parsing. More... | |
Functions | |
struct config_file * | config_create (void) |
Create config file structure. More... | |
struct config_file * | config_create_forlib (void) |
Create config file structure for library use. More... | |
int | config_read (struct config_file *config, const char *filename, const char *chroot) |
Read the config file from the specified filename. More... | |
void | config_delete (struct config_file *config) |
Destroy the config file structure. More... | |
void | config_apply (struct config_file *config) |
Apply config to global constants; this routine is called in single thread. More... | |
void | config_lookup_uid (struct config_file *config) |
Find username, sets cfg_uid and cfg_gid. More... | |
int | config_set_option (struct config_file *config, const char *option, const char *value) |
Set the given keyword to the given value. More... | |
int | config_get_option (struct config_file *cfg, const char *opt, void(*func)(char *, void *), void *arg) |
Call print routine for the given option. More... | |
int | config_get_option_list (struct config_file *cfg, const char *opt, struct config_strlist **list) |
Get an option and return strlist. More... | |
int | config_get_option_collate (struct config_file *cfg, const char *opt, char **str) |
Get an option and collate results into string. More... | |
void | config_print_func (char *line, void *arg) |
function to print to a file, use as func with config_get_option. More... | |
void | config_collate_func (char *line, void *arg) |
function to collate the text strings into a strlist_head. More... | |
char * | config_collate_cat (struct config_strlist *list) |
take a strlist_head list and return a malloc string. More... | |
int | cfg_strlist_append (struct config_strlist_head *list, char *item) |
Append text at end of list. More... | |
int | cfg_strlist_append_ex (struct config_strlist **head, char *item) |
Searches the end of a string list and appends the given text. More... | |
struct config_strlist * | cfg_strlist_find (struct config_strlist *head, const char *item) |
Find string in strlist. More... | |
int | cfg_strlist_insert (struct config_strlist **head, char *item) |
Insert string into strlist. More... | |
int | cfg_region_strlist_insert (struct regional *region, struct config_strlist **head, char *item) |
insert with region for allocation. | |
int | cfg_str2list_insert (struct config_str2list **head, char *item, char *i2) |
Insert string into str2list. More... | |
int | cfg_str3list_insert (struct config_str3list **head, char *item, char *i2, char *i3) |
Insert string into str3list. More... | |
int | cfg_strbytelist_insert (struct config_strbytelist **head, char *item, uint8_t *i2, size_t i2len) |
Insert string into strbytelist. More... | |
struct config_stub * | cfg_stub_find (struct config_stub ***pp, const char *nm) |
Find stub in config list, also returns prevptr (for deletion). More... | |
void | config_delstrlist (struct config_strlist *list) |
Delete items in config string list. More... | |
void | config_deldblstrlist (struct config_str2list *list) |
Delete items in config double string list. More... | |
void | config_deltrplstrlist (struct config_str3list *list) |
Delete items in config triple string list. More... | |
void | config_del_strarray (char **array, int num) |
delete string array | |
void | config_del_strbytelist (struct config_strbytelist *list) |
delete stringbytelist | |
void | config_delstub (struct config_stub *p) |
Delete a stub item. More... | |
void | config_delstubs (struct config_stub *list) |
Delete items in config stub list. More... | |
void | config_delauth (struct config_auth *p) |
Delete an auth item. More... | |
void | config_delauths (struct config_auth *list) |
Delete items in config auth list. More... | |
void | config_delview (struct config_view *p) |
Delete a view item. More... | |
void | config_delviews (struct config_view *list) |
Delete items in config view list. More... | |
int | options_remote_is_address (struct config_file *cfg) |
check if config for remote control turns on IP-address interface with certificates or a named pipe without certificates. | |
time_t | cfg_convert_timeval (const char *str) |
Convert 14digit to time value. More... | |
int | cfg_count_numbers (const char *str) |
Count number of values in the string. More... | |
int | cfg_parse_memsize (const char *str, size_t *res) |
Convert a 'nice' memory or file size into a bytecount From '100k' to 102400. More... | |
uint8_t * | cfg_parse_nsid (const char *str, uint16_t *nsid_len) |
Parse nsid from string into binary nsid. More... | |
int | config_add_tag (struct config_file *cfg, const char *tag) |
Add a tag name to the config. More... | |
int | find_tag_id (struct config_file *cfg, const char *tag) |
Find tag ID in the tag list. More... | |
uint8_t * | config_parse_taglist (struct config_file *cfg, char *str, size_t *listlen) |
parse taglist from string into bytestring with bitlist. More... | |
char * | config_taglist2str (struct config_file *cfg, uint8_t *taglist, size_t len) |
convert tag bitlist to a malloced string with tag names. More... | |
int | taglist_intersect (uint8_t *list1, size_t list1len, const uint8_t *list2, size_t list2len) |
see if two taglists intersect (have tags in common). More... | |
int | cfg_parse_local_zone (struct config_file *cfg, const char *val) |
Parse local-zone directive into two strings and register it in the config. More... | |
int | cfg_mark_ports (const char *str, int allow, int *avail, int num) |
Mark "number" or "low-high" as available or not in ports array. More... | |
int | cfg_condense_ports (struct config_file *cfg, int **avail) |
Get a condensed list of ports returned. More... | |
void | cfg_apply_local_port_policy (struct config_file *cfg, int num) |
Apply system specific port range policy. More... | |
int | cfg_scan_ports (int *avail, int num) |
Scan ports available. More... | |
char * | fname_after_chroot (const char *fname, struct config_file *cfg, int use_chdir) |
Convert a filename to full pathname in original filesys. More... | |
char * | cfg_ptr_reverse (char *str) |
Convert a ptr shorthand into a full reverse-notation PTR record. More... | |
void | init_cfg_parse (void) |
init lex state | |
int | ub_c_parse (void) |
the yacc lex generated parse function | |
int | ub_c_lex (void) |
the lexer function | |
int | ub_c_wrap (void) |
wrap function | |
void | ub_c_error (const char *msg) |
parsing helpers: print error with file and line numbers | |
void | ub_c_error_msg (const char *fmt,...) ATTR_FORMAT(printf |
parsing helpers: print error with file and line numbers | |
int | if_is_https (const char *ifname, const char *port, int https_port) |
see if interface is https, its port number == the https port number | |
int | cfg_has_https (struct config_file *cfg) |
Return true if the config contains settings that enable https. More... | |
int | if_is_pp2 (const char *ifname, const char *port, struct config_strlist *proxy_protocol_port) |
see if interface is PROXYv2, its port number == the proxy port number | |
int | if_is_dnscrypt (const char *ifname, const char *port, int dnscrypt_port) |
see if interface is DNSCRYPT, its port number == the dnscrypt port number | |
int | if_is_quic (const char *ifname, const char *port, int quic_port) |
see if interface is quic, its port number == the quic port number | |
Variables | |
uid_t | cfg_uid |
from cfg username, after daemonize setup performed | |
gid_t | cfg_gid |
from cfg username, after daemonize setup performed | |
int | autr_permit_small_holddown |
debug and enable small timeouts More... | |
size_t | stream_wait_max |
size (in bytes) of stream wait buffers max | |
size_t | http2_query_buffer_max |
size (in bytes) of all total HTTP2 query buffers max | |
size_t | http2_response_buffer_max |
size (in bytes) of all total HTTP2 response buffers max | |
struct config_parser_state * | cfg_parser |
global config parser object used during config parsing More... | |
FILE * | ub_c_in |
lex in file | |
FILE * | ub_c_out |
lex out file | |
void int | fake_dsa |
debug option for unit tests. More... | |
void int | fake_sha1 |
This file contains functions for the config file.
struct config_file* config_create | ( | void | ) |
Create config file structure.
Filled with default values.
References config_file::auths, config_file::bogus_ttl, config_file::chrootdir, config_file::delay_close, config_file::deny_any, config_file::directory, config_file::do_daemonize, config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_tcp_keepalive, config_file::do_udp, config_file::donotquery_localhost, config_file::donotqueryaddrs, config_file::edns_buffer_size, config_file::fast_server_num, config_file::fast_server_permil, config_file::forwards, config_file::host_ttl, config_file::http_endpoint, config_file::http_max_streams, config_file::http_nodelay, config_file::http_query_buffer_size, config_file::http_response_buffer_size, config_file::https_port, config_file::if_automatic, config_file::if_automatic_ports, config_file::ifs, config_file::incoming_num_tcp, config_file::infra_cache_max_rtt, config_file::infra_cache_min_rtt, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, config_file::infra_keep_probing, init_outgoing_availports(), config_file::ip_dscp, config_file::ip_freebind, config_file::ip_transparent, config_file::jostle_time, config_file::log_destaddr, config_file::log_identity, config_file::log_local_actions, config_file::log_queries, config_file::log_replies, config_file::log_servfail, config_file::log_tag_queryreply, config_file::log_time_ascii, config_file::log_time_iso, config_file::logfile, config_file::max_negative_ttl, config_file::max_reuse_tcp_queries, config_file::max_ttl, config_file::min_negative_ttl, config_file::min_ttl, config_file::msg_buffer_size, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::num_ifs, config_file::num_out_ifs, config_file::num_queries_per_thread, config_file::num_threads, config_file::out_ifs, config_file::outgoing_avail_ports, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::outgoing_tcp_mss, config_file::pidfile, config_file::port, config_file::prefetch, config_file::prefetch_key, config_file::quic_port, config_file::quic_size, config_file::root_hints, config_file::rrset_cache_size, config_file::rrset_cache_slabs, config_file::so_rcvbuf, config_file::so_reuseport, config_file::so_sndbuf, config_file::sock_queue_timeout, config_file::ssl_port, config_file::ssl_service_key, config_file::ssl_service_pem, config_file::ssl_upstream, config_file::stat_cumulative, config_file::stat_extended, config_file::stat_inhibit_zero, config_file::stat_interval, config_file::stream_wait_size, config_file::stubs, config_file::target_fetch_policy, config_file::tcp_auth_query_timeout, config_file::tcp_idle_timeout, config_file::tcp_keepalive_timeout, config_file::tcp_mss, config_file::tcp_reuse_timeout, config_file::tcp_upstream, config_file::tls_cert_bundle, config_file::tls_use_sni, config_file::tls_win_cert, config_file::udp_connect, config_file::udp_upstream_without_downstream, config_file::use_syslog, config_file::use_systemd, config_file::username, and config_file::verbosity.
Referenced by checkconf(), config_create_forlib(), go(), infra_test(), and print_stats_shm().
struct config_file* config_create_forlib | ( | void | ) |
Create config file structure for library use.
Filled with default values.
References config_file::chrootdir, config_create(), config_file::donotquery_localhost, config_file::harden_short_bufsize, config_file::infra_cache_slabs, config_file::key_cache_size, config_file::key_cache_slabs, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::neg_cache_size, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::rrset_cache_size, config_file::rrset_cache_slabs, config_file::use_syslog, config_file::val_log_level, config_file::val_log_squelch, and config_file::verbosity.
Referenced by ub_ctx_create_nopipe().
int config_read | ( | struct config_file * | config, |
const char * | filename, | ||
const char * | chroot | ||
) |
Read the config file from the specified filename.
config | where options are stored into, must be freshly created. |
filename | name of configfile. If NULL nothing is done. |
chroot | if not NULL, the chroot dir currently in use (for include). |
References config_parser_state::cfg, cfg_parser, config_parser_state::chroot, create_cfg_parser(), config_file::dnscrypt, config_file::dnscrypt_port, config_parser_state::errors, config_parser_state::filename, log_err(), ub_c_in, ub_c_parse(), VERB_QUERY, and verbose().
Referenced by ub_ctx_config().
void config_delete | ( | struct config_file * | config | ) |
Destroy the config file structure.
config | to delete. |
References config_file::acl_tag_actions, config_file::acl_tag_datas, config_file::acl_tags, config_file::acl_view, config_file::acls, config_file::auths, config_file::auto_trust_anchor_file_list, config_file::caps_whitelist, config_file::chrootdir, config_del_strarray(), config_del_strbytelist(), config_delauths(), config_deldblstrlist(), config_delstrlist(), config_delstubs(), config_deltrplstrlist(), config_delviews(), config_file::control_cert_file, config_file::control_ifs, config_file::control_key_file, config_file::cookie_secret_file, config_file::directory, config_file::dns64_ignore_aaaa, config_file::dnstap_identity, config_file::dnstap_ip, config_file::dnstap_socket_path, config_file::dnstap_tls_cert_bundle, config_file::dnstap_tls_client_cert_file, config_file::dnstap_tls_client_key_file, config_file::dnstap_tls_server_name, config_file::dnstap_version, config_file::domain_insecure, config_file::donotqueryaddrs, config_file::dynlib_file, config_file::edns_client_strings, config_strlist_head::first, config_file::forwards, config_file::http_endpoint, config_file::http_user_agent, config_file::identity, config_file::if_automatic_ports, config_file::ifs, config_file::interface_actions, config_file::interface_tag_actions, config_file::interface_tag_datas, config_file::interface_tags, config_file::interface_view, config_file::local_data, config_file::local_zone_overrides, config_file::local_zone_tags, config_file::local_zones, config_file::local_zones_nodefault, log_ident_revert_to_default(), config_file::log_identity, config_file::logfile, config_file::module_conf, config_file::nsid_cfg_str, config_file::num_ifs, config_file::num_out_ifs, config_file::num_tags, config_file::out_ifs, config_file::outgoing_avail_ports, config_file::pidfile, config_file::private_address, config_file::private_domain, config_file::proxy_protocol_port, config_file::python_script, config_file::ratelimit_below_domain, config_file::ratelimit_for_domain, config_file::respip_tags, config_file::root_hints, config_file::server_cert_file, config_file::server_key_file, config_file::ssl_service_key, config_file::ssl_service_pem, config_file::stubs, config_file::tagname, config_file::target_fetch_policy, config_file::tcp_connection_limits, config_file::tls_additional_port, config_file::tls_cert_bundle, config_file::tls_ciphers, config_file::tls_ciphersuites, config_file::tls_session_ticket_keys, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trusted_keys_file_list, config_file::username, config_file::val_nsec3_key_iterations, config_file::version, config_file::views, config_file::wait_limit_cookie_netblock, and config_file::wait_limit_netblock.
Referenced by service_deinit(), ub_ctx_create(), and ub_ctx_create_nopipe().
void config_apply | ( | struct config_file * | config | ) |
Apply config to global constants; this routine is called in single thread.
config | to apply. Side effect: global constants change. |
References autr_permit_small_holddown, BLACKLIST_PENALTY, EDNS_ADVERTISED_SIZE, config_file::edns_buffer_size, http2_query_buffer_max, http2_response_buffer_max, config_file::http_query_buffer_size, config_file::http_response_buffer_size, config_file::infra_cache_max_rtt, config_file::infra_cache_min_rtt, log_set_time_asc(), log_set_time_iso(), config_file::log_tag_queryreply, LOG_TAG_QUERYREPLY, config_file::log_time_ascii, config_file::log_time_iso, MAX_GLOBAL_QUOTA, config_file::max_global_quota, MAX_NEG_TTL, config_file::max_negative_ttl, config_file::max_ttl, MAX_TTL, MIN_NEG_TTL, config_file::min_negative_ttl, config_file::min_ttl, MIN_TTL, MINIMAL_RESPONSES, config_file::permit_small_holddown, RRSET_ROUNDROBIN, RTT_MAX_TIMEOUT, RTT_MIN_TIMEOUT, config_file::serve_expired, SERVE_EXPIRED, config_file::serve_expired_reply_ttl, SERVE_EXPIRED_REPLY_TTL, config_file::serve_expired_ttl, SERVE_EXPIRED_TTL, config_file::serve_expired_ttl_reset, SERVE_EXPIRED_TTL_RESET, config_file::serve_original_ttl, SERVE_ORIGINAL_TTL, stream_wait_max, config_file::stream_wait_size, UNKNOWN_SERVER_NICENESS, and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by context_finalize(), and daemon_apply_cfg().
void config_lookup_uid | ( | struct config_file * | config | ) |
Find username, sets cfg_uid and cfg_gid.
config | the config structure. |
References cfg_gid, cfg_uid, and config_file::username.
int config_set_option | ( | struct config_file * | config, |
const char * | option, | ||
const char * | value | ||
) |
Set the given keyword to the given value.
config | where to store config |
option | option name, including the ':' character. |
value | value, this string is copied if needed, or parsed. The caller owns the value string. |
References config_file::add_holddown, config_file::aggressive_nsec, config_file::auto_trust_anchor_file_list, autr_permit_small_holddown, BLACKLIST_PENALTY, config_file::bogus_ttl, config_file::caps_whitelist, cfg_convert_timeval(), cfg_mark_ports(), cfg_parse_local_zone(), cfg_parse_nsid(), cfg_ptr_reverse(), cfg_strlist_insert(), config_file::chrootdir, config_add_tag(), config_file::control_cert_file, config_file::control_ifs, config_file::control_key_file, config_file::control_port, config_file::cookie_secret_file, config_file::del_holddown, config_file::delay_close, config_file::deny_any, config_file::directory, config_file::disable_dnssec_lame_check, config_file::disable_edns_do, config_file::discard_timeout, config_file::dnscrypt, config_file::dnscrypt_nonce_cache_size, config_file::dnscrypt_nonce_cache_slabs, config_file::dnscrypt_port, config_file::dnscrypt_provider, config_file::dnscrypt_provider_cert, config_file::dnscrypt_provider_cert_rotated, config_file::dnscrypt_secret_key, config_file::dnscrypt_shared_secret_cache_size, config_file::dnscrypt_shared_secret_cache_slabs, config_file::dnstap, config_file::dnstap_bidirectional, config_file::dnstap_identity, config_file::dnstap_ip, config_file::dnstap_log_client_query_messages, config_file::dnstap_log_client_response_messages, config_file::dnstap_log_forwarder_query_messages, config_file::dnstap_log_forwarder_response_messages, config_file::dnstap_log_resolver_query_messages, config_file::dnstap_log_resolver_response_messages, config_file::dnstap_sample_rate, config_file::dnstap_send_identity, config_file::dnstap_send_version, config_file::dnstap_socket_path, config_file::dnstap_tls, config_file::dnstap_tls_cert_bundle, config_file::dnstap_tls_client_cert_file, config_file::dnstap_tls_client_key_file, config_file::dnstap_tls_server_name, config_file::dnstap_version, config_file::do_answer_cookie, config_file::do_daemonize, config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_tcp_keepalive, config_file::do_udp, config_file::domain_insecure, config_file::donotquery_localhost, config_file::donotqueryaddrs, config_file::dynlib_file, config_file::ede, config_file::ede_serve_expired, config_file::edns_buffer_size, config_file::fast_server_num, config_file::fast_server_permil, config_file::harden_algo_downgrade, config_file::harden_below_nxdomain, config_file::harden_dnssec_stripped, config_file::harden_glue, config_file::harden_large_queries, config_file::harden_referral_path, config_file::harden_short_bufsize, config_file::harden_unknown_additional, config_file::harden_unverified_glue, config_file::hide_http_user_agent, config_file::hide_identity, config_file::hide_trustanchor, config_file::hide_version, config_file::host_ttl, config_file::http_endpoint, config_file::http_max_streams, config_file::http_nodelay, config_file::http_notls_downstream, config_file::http_query_buffer_size, config_file::http_response_buffer_size, config_file::http_user_agent, config_file::https_port, config_file::identity, config_file::if_automatic, config_file::if_automatic_ports, config_file::ignore_cd, config_file::incoming_num_tcp, config_file::infra_cache_max_rtt, config_file::infra_cache_min_rtt, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, infra_dp_ratelimit, infra_ip_ratelimit, infra_ip_ratelimit_cookie, config_file::infra_keep_probing, config_file::insecure_lan_zones, config_file::ip_dscp, config_file::ip_freebind, config_file::ip_ratelimit, config_file::ip_ratelimit_backoff, config_file::ip_ratelimit_cookie, config_file::ip_ratelimit_factor, config_file::ip_ratelimit_size, config_file::ip_ratelimit_slabs, config_file::ip_transparent, IS_NUMBER_OR_ZERO, IS_YES_OR_NO, config_file::iter_scrub_cname, config_file::iter_scrub_ns, config_file::jostle_time, config_file::keep_missing, config_file::key_cache_size, config_file::key_cache_slabs, config_file::local_data, config_file::log_destaddr, config_file::log_identity, config_file::log_local_actions, config_file::log_queries, config_file::log_replies, config_file::log_servfail, log_set_time_asc(), log_set_time_iso(), config_file::log_tag_queryreply, config_file::log_time_ascii, config_file::log_time_iso, config_file::logfile, config_file::max_global_quota, MAX_NEG_TTL, config_file::max_negative_ttl, config_file::max_query_restarts, config_file::max_reuse_tcp_queries, config_file::max_sent_count, config_file::max_ttl, MAX_TTL, MIN_NEG_TTL, config_file::min_negative_ttl, config_file::min_ttl, MIN_TTL, config_file::module_conf, config_file::msg_buffer_size, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::neg_cache_size, config_file::nsid_cfg_str, config_file::num_out_ifs, config_file::num_queries_per_thread, config_file::out_ifs, config_file::outbound_msg_retry, config_file::outgoing_avail_ports, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::outgoing_tcp_mss, config_file::pad_queries, config_file::pad_queries_block_size, config_file::pad_responses, config_file::pad_responses_block_size, config_file::permit_small_holddown, config_file::pidfile, config_file::port, config_file::prefer_ip4, config_file::prefer_ip6, config_file::prefetch, config_file::prefetch_key, config_file::private_address, config_file::private_domain, config_file::proxy_protocol_port, config_file::python_script, config_file::qname_minimisation, config_file::qname_minimisation_strict, config_file::quic_port, config_file::quic_size, config_file::ratelimit, config_file::ratelimit_backoff, config_file::ratelimit_factor, config_file::ratelimit_size, config_file::ratelimit_slabs, config_file::remote_control_enable, config_file::root_hints, config_file::root_key_sentinel, config_file::rrset_cache_size, config_file::rrset_cache_slabs, RTT_MAX_TIMEOUT, RTT_MIN_TIMEOUT, S_MEMSIZE, S_NUMBER_NONZERO, S_NUMBER_OR_ZERO, S_POW2, S_SIZET_NONZERO, S_SIZET_OR_ZERO, S_STR, S_STRLIST, S_STRLIST_APPEND, S_STRLIST_UNIQ, S_UNSIGNED_OR_ZERO, S_YNO, config_file::serve_expired, SERVE_EXPIRED, config_file::serve_expired_client_timeout, config_file::serve_expired_reply_ttl, SERVE_EXPIRED_REPLY_TTL, config_file::serve_expired_ttl, SERVE_EXPIRED_TTL, config_file::serve_expired_ttl_reset, SERVE_EXPIRED_TTL_RESET, config_file::serve_original_ttl, config_file::server_cert_file, config_file::server_key_file, config_file::shm_enable, config_file::shm_key, config_file::so_rcvbuf, config_file::so_reuseport, config_file::so_sndbuf, config_file::sock_queue_timeout, config_file::ssl_port, config_file::ssl_service_key, config_file::ssl_service_pem, config_file::ssl_upstream, config_file::stat_cumulative, config_file::stat_extended, config_file::stat_inhibit_zero, config_file::stat_interval, config_file::stream_wait_size, config_file::target_fetch_policy, config_file::tcp_auth_query_timeout, config_file::tcp_idle_timeout, config_file::tcp_keepalive_timeout, config_file::tcp_mss, config_file::tcp_reuse_timeout, config_file::tcp_upstream, config_file::tls_additional_port, config_file::tls_cert_bundle, config_file::tls_ciphers, config_file::tls_ciphersuites, config_file::tls_session_ticket_keys, config_file::tls_use_sni, config_file::tls_win_cert, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trust_anchor_signaling, config_file::trusted_keys_file_list, config_file::udp_connect, config_file::udp_upstream_without_downstream, config_file::unblock_lan_zones, config_file::unwanted_threshold, config_file::use_caps_bits_for_id, config_file::use_syslog, config_file::use_systemd, USEFUL_SERVER_TOP_TIMEOUT, config_file::username, config_file::val_clean_additional, config_file::val_date_override, config_file::val_log_level, config_file::val_log_squelch, config_file::val_max_restart, config_file::val_nsec3_key_iterations, config_file::val_permissive_mode, config_file::val_sig_skew_max, config_file::val_sig_skew_min, verbosity, config_file::version, config_file::wait_limit, config_file::wait_limit_cookie, and config_file::zonemd_permissive_mode.
Referenced by do_set_option(), and ub_ctx_set_option().
int config_get_option | ( | struct config_file * | cfg, |
const char * | opt, | ||
void(*)(char *, void *) | func, | ||
void * | arg | ||
) |
Call print routine for the given option.
cfg | config. |
opt | option name without trailing :. This is different from config_set_option. |
func | print func, called as (str, arg) for every data element. |
arg | user argument for print func. |
References fptr_ok, fptr_whitelist_print_func(), log_time_iso, logfile, O_DEC, O_IFC, O_LS2, O_LS3, O_LST, O_LTG, O_MEM, O_STR, O_UNS, O_YNO, and verbosity.
Referenced by config_get_option_list(), and do_get_option().
int config_get_option_list | ( | struct config_file * | cfg, |
const char * | opt, | ||
struct config_strlist ** | list | ||
) |
Get an option and return strlist.
cfg | config file |
opt | option name. |
list | list is returned here. malloced, caller must free it. |
References config_collate_func(), config_delstrlist(), config_get_option(), config_strlist_head::first, config_collate_arg::list, and config_collate_arg::status.
int config_get_option_collate | ( | struct config_file * | cfg, |
const char * | opt, | ||
char ** | str | ||
) |
Get an option and collate results into string.
cfg | config file |
opt | option name. |
str | string. malloced, caller must free it. |
void config_print_func | ( | char * | line, |
void * | arg | ||
) |
function to print to a file, use as func with config_get_option.
line | text to print. appended. |
arg | pass a FILE*, like stdout. |
Referenced by fptr_whitelist_print_func().
void config_collate_func | ( | char * | line, |
void * | arg | ||
) |
function to collate the text strings into a strlist_head.
line | text to append. |
arg | pass a strlist_head structure. zeroed on start. |
References cfg_strlist_append(), config_collate_arg::list, and config_collate_arg::status.
Referenced by config_get_option_list(), and fptr_whitelist_print_func().
char* config_collate_cat | ( | struct config_strlist * | list | ) |
take a strlist_head list and return a malloc string.
separated with newline.
list | strlist first to collate. zeroes return "". |
References config_strlist::next, and config_strlist::str.
int cfg_strlist_append | ( | struct config_strlist_head * | list, |
char * | item | ||
) |
Append text at end of list.
list | list head. zeroed at start. |
item | new item. malloced by caller. if NULL the insertion fails. |
References config_strlist_head::first, config_strlist_head::last, config_strlist::next, and config_strlist::str.
Referenced by config_collate_func().
int cfg_strlist_append_ex | ( | struct config_strlist ** | head, |
char * | item | ||
) |
Searches the end of a string list and appends the given text.
head | pointer to strlist head variable. |
item | new item. malloced by caller. if NULL the insertion fails. |
References config_strlist::next, and config_strlist::str.
struct config_strlist* cfg_strlist_find | ( | struct config_strlist * | head, |
const char * | item | ||
) |
Find string in strlist.
head | pointer to strlist head variable. |
item | the item to search for. |
References config_strlist::next, and config_strlist::str.
int cfg_strlist_insert | ( | struct config_strlist ** | head, |
char * | item | ||
) |
Insert string into strlist.
head | pointer to strlist head variable. |
item | new item. malloced by caller. If NULL the insertion fails. |
References config_strlist::next, and config_strlist::str.
Referenced by cfg_parse_local_zone(), config_set_option(), dnsc_load_local_data(), ub_ctx_add_ta(), ub_ctx_add_ta_autr(), ub_ctx_add_ta_file(), ub_ctx_hosts(), ub_ctx_set_fwd(), ub_ctx_set_stub(), and ub_ctx_trustedkeys().
int cfg_str2list_insert | ( | struct config_str2list ** | head, |
char * | item, | ||
char * | i2 | ||
) |
Insert string into str2list.
head | pointer to str2list head variable. |
item | new item. malloced by caller. If NULL the insertion fails. |
i2 | 2nd string, malloced by caller. If NULL the insertion fails. |
References config_str2list::next, config_str2list::str, and config_str2list::str2.
Referenced by cfg_parse_local_zone(), dnsc_load_local_data(), and views_apply_cfg().
int cfg_str3list_insert | ( | struct config_str3list ** | head, |
char * | item, | ||
char * | i2, | ||
char * | i3 | ||
) |
Insert string into str3list.
head | pointer to str3list head variable. |
item | new item. malloced by caller. If NULL the insertion fails. |
i2 | 2nd string, malloced by caller. If NULL the insertion fails. |
i3 | 3rd string, malloced by caller. If NULL the insertion fails. |
References config_str3list::next, config_str3list::str, config_str3list::str2, and config_str3list::str3.
int cfg_strbytelist_insert | ( | struct config_strbytelist ** | head, |
char * | item, | ||
uint8_t * | i2, | ||
size_t | i2len | ||
) |
Insert string into strbytelist.
head | pointer to strbytelist head variable. |
item | new item. malloced by caller. If NULL the insertion fails. |
i2 | 2nd string, malloced by caller. If NULL the insertion fails. |
i2len | length of the i2 bytestring. |
References config_strbytelist::next, config_strbytelist::str, and config_strbytelist::str2.
struct config_stub* cfg_stub_find | ( | struct config_stub *** | pp, |
const char * | nm | ||
) |
Find stub in config list, also returns prevptr (for deletion).
pp | call routine with pointer to a pointer to the start of the list, if the stub is found, on exit, the value contains a pointer to the next pointer that points to the found element (or to the list start pointer if it is the first element). |
nm | name of stub to find. |
References config_stub::name, and config_stub::next.
Referenced by ub_ctx_set_stub().
void config_delstrlist | ( | struct config_strlist * | list | ) |
Delete items in config string list.
list | list. |
References config_strlist::next, and config_strlist::str.
Referenced by config_delauth(), config_delete(), config_delstub(), config_delview(), config_get_option_list(), lz_freeup_cfg(), remove_configfile(), and replay_moment_delete().
void config_deldblstrlist | ( | struct config_str2list * | list | ) |
Delete items in config double string list.
list | list. |
References config_str2list::next, config_str2list::str, and config_str2list::str2.
Referenced by config_delete(), config_delview(), lz_freeup_cfg(), read_acl_interface_view(), and read_acl_view().
void config_deltrplstrlist | ( | struct config_str3list * | list | ) |
Delete items in config triple string list.
list | list. |
References config_str3list::next, config_str3list::str, config_str3list::str2, and config_str3list::str3.
Referenced by config_delete(), read_acl_interface_tag_actions(), read_acl_interface_tag_datas(), read_acl_tag_actions(), and read_acl_tag_datas().
void config_delstub | ( | struct config_stub * | p | ) |
Delete a stub item.
p | stub item |
References config_stub::addrs, config_delstrlist(), config_stub::hosts, and config_stub::name.
Referenced by config_delstubs(), and ub_ctx_set_stub().
void config_delstubs | ( | struct config_stub * | list | ) |
Delete items in config stub list.
list | list. |
References config_delstub(), and config_stub::next.
Referenced by config_delete(), and ub_ctx_set_fwd().
void config_delauth | ( | struct config_auth * | p | ) |
Delete an auth item.
p | auth item |
References config_auth::allow_notify, config_delstrlist(), config_auth::masters, config_auth::name, config_auth::rpz_action_override, config_auth::rpz_cname, config_auth::rpz_log_name, config_auth::rpz_taglist, config_auth::urls, and config_auth::zonefile.
Referenced by config_delauths().
void config_delauths | ( | struct config_auth * | list | ) |
Delete items in config auth list.
list | list. |
References config_delauth(), and config_auth::next.
Referenced by config_delete().
void config_delview | ( | struct config_view * | p | ) |
Delete a view item.
p | view item |
References config_deldblstrlist(), config_delstrlist(), config_view::local_data, config_view::local_zones, config_view::local_zones_nodefault, and config_view::name.
Referenced by config_delviews().
void config_delviews | ( | struct config_view * | list | ) |
Delete items in config view list.
list | list. |
References config_delview(), and config_view::next.
Referenced by config_delete().
time_t cfg_convert_timeval | ( | const char * | str | ) |
Convert 14digit to time value.
str | string of 14 digits |
Referenced by config_set_option().
int cfg_count_numbers | ( | const char * | str | ) |
Count number of values in the string.
format ::= (sp num)+ sp num ::= [-](0-9)+ sp ::= (space|tab)*
str | string |
Referenced by val_apply_cfg().
int cfg_parse_memsize | ( | const char * | str, |
size_t * | res | ||
) |
Convert a 'nice' memory or file size into a bytecount From '100k' to 102400.
and so on. Understands kKmMgG. k=1024, m=1024*1024, g=1024*1024*1024.
str | string |
res | result is stored here, size in bytes. |
Referenced by config_memsize_test(), and main().
uint8_t* cfg_parse_nsid | ( | const char * | str, |
uint16_t * | nsid_len | ||
) |
Parse nsid from string into binary nsid.
nsid is either a hexadecimal string or an ascii string prepended with ascii_ in which case the characters after ascii_ are simply copied.
str | the string to parse. |
nsid_len | returns length of nsid in bytes. |
Referenced by config_set_option().
int config_add_tag | ( | struct config_file * | cfg, |
const char * | tag | ||
) |
Add a tag name to the config.
It is added at the end with a new ID value.
cfg | the config structure. |
tag | string (which is copied) with the name. |
References find_tag_id(), config_file::num_tags, and config_file::tagname.
Referenced by config_set_option().
int find_tag_id | ( | struct config_file * | cfg, |
const char * | tag | ||
) |
Find tag ID in the tag list.
cfg | the config structure. |
tag | string with tag name to search for. |
References config_file::num_tags, and config_file::tagname.
Referenced by config_add_tag().
uint8_t* config_parse_taglist | ( | struct config_file * | cfg, |
char * | str, | ||
size_t * | listlen | ||
) |
parse taglist from string into bytestring with bitlist.
cfg | the config structure (with tagnames) |
str | the string to parse. Parse puts 0 bytes in string. |
listlen | returns length of in bytes. |
char* config_taglist2str | ( | struct config_file * | cfg, |
uint8_t * | taglist, | ||
size_t | len | ||
) |
convert tag bitlist to a malloced string with tag names.
For debug output.
cfg | the config structure (with tagnames) |
taglist | the tag bitlist. |
len | length of the tag bitlist. |
References config_file::tagname.
int taglist_intersect | ( | uint8_t * | list1, |
size_t | list1len, | ||
const uint8_t * | list2, | ||
size_t | list2len | ||
) |
see if two taglists intersect (have tags in common).
list1 | first tag bitlist. |
list1len | length in bytes of first list. |
list2 | second tag bitlist. |
list2len | length in bytes of second list. |
Referenced by config_tag_test(), local_zones_tags_lookup(), respip_rewrite_reply(), rpz_callback_from_iterator_cname(), and rpz_callback_from_iterator_module().
int cfg_parse_local_zone | ( | struct config_file * | cfg, |
const char * | val | ||
) |
Parse local-zone directive into two strings and register it in the config.
cfg | to put it in. |
val | argument strings to local-zone, "example.com nodefault". |
References cfg_str2list_insert(), cfg_strlist_insert(), last_space_pos(), config_file::local_zones, config_file::local_zones_nodefault, log_err(), and next_space_pos().
Referenced by config_set_option().
int cfg_mark_ports | ( | const char * | str, |
int | allow, | ||
int * | avail, | ||
int | num | ||
) |
Mark "number" or "low-high" as available or not in ports array.
str | string in input |
allow | give true if this range is permitted. |
avail | the array from cfg. |
num | size of the array (65536). |
Referenced by config_set_option().
int cfg_condense_ports | ( | struct config_file * | cfg, |
int ** | avail | ||
) |
Get a condensed list of ports returned.
allocated.
cfg | config file. |
avail | the available ports array is returned here. |
References cfg_scan_ports(), log_assert, and config_file::outgoing_avail_ports.
void cfg_apply_local_port_policy | ( | struct config_file * | cfg, |
int | num | ||
) |
Apply system specific port range policy.
cfg | config file. |
num | size of the array (65536). |
References log_err(), and config_file::outgoing_avail_ports.
Referenced by context_finalize().
int cfg_scan_ports | ( | int * | avail, |
int | num | ||
) |
Scan ports available.
avail | the array from cfg. |
num | size of the array (65536). |
Referenced by cfg_condense_ports().
char* fname_after_chroot | ( | const char * | fname, |
struct config_file * | cfg, | ||
int | use_chdir | ||
) |
Convert a filename to full pathname in original filesys.
fname | the path name to convert. Must not be null or empty. |
cfg | config struct for chroot and chdir (if set). |
use_chdir | if false, only chroot is applied. |
References config_file::chrootdir, config_file::directory, and strlen_after_chroot().
Referenced by check_chroot_filelist_wild(), print_option(), and setup_ctx().
char* cfg_ptr_reverse | ( | char * | str | ) |
Convert a ptr shorthand into a full reverse-notation PTR record.
str | input string, "IP name" |
Referenced by config_set_option().
int cfg_has_https | ( | struct config_file * | cfg | ) |
Return true if the config contains settings that enable https.
cfg | config information. |
Return true if the config contains settings that enable https.
References config_file::https_port, if_is_https(), config_file::ifs, config_file::num_ifs, and config_file::port.
Referenced by checkrlimits().
|
extern |
debug and enable small timeouts
debug and enable small timeouts
Referenced by autr_probe_timer(), calc_next_probe(), config_apply(), config_set_option(), and set_tp_times().
|
extern |
global config parser object used during config parsing
global config parser object used during config parsing
Referenced by config_read(), create_cfg_parser(), and ub_c_error_va_list().
|
extern |
debug option for unit tests.
debug option for unit tests.