unbound 0.1
daemon.h File Reference

The daemon consists of global settings and a number of workers. More...

#include "util/locks.h"
#include "util/alloc.h"
#include "services/modstack.h"
#include "dnstap/dnstap_config.h"
#include "dnscrypt/dnscrypt_config.h"

Data Structures

struct  daemon
 Structure holding worker list. More...

Functions

struct daemon * daemon_init (void)
 Initialize daemon structure.
int daemon_open_shared_ports (struct daemon *daemon)
 Open shared listening ports (if needed).
int daemon_privileged (struct daemon *daemon)
 Do daemon setup that needs privileges like opening privileged ports or opening device files.
void daemon_fork (struct daemon *daemon)
 Fork workers and start service.
void daemon_cleanup (struct daemon *daemon)
 Close off the worker thread information.
void daemon_delete (struct daemon *daemon)
 Delete workers, close listening ports.
void daemon_apply_cfg (struct daemon *daemon, struct config_file *cfg)
 Apply config settings.
int setup_acl_for_ports (struct acl_list *list, struct listen_port *port_list)
 Setup acl list to have entries for the port list.
void daemon_setup_sslctxs (struct daemon *daemon, struct config_file *cfg)
int ssl_cert_changed (struct daemon *daemon, struct config_file *cfg)
 See if the SSL cert files have changed.
void * daemon_setup_listen_dot_sslctx (struct daemon *daemon, struct config_file *cfg)
 Setup the listening DoT SSL_CTX, returns the ssl ctx.
void * daemon_setup_listen_doh_sslctx (struct daemon *daemon, struct config_file *cfg)
 Setup the listening DoH SSL_CTX, returns the ssl ctx.
void * daemon_setup_listen_quic_sslctx (struct daemon *daemon, struct config_file *cfg)
 Setup the listening Quic SSL_CTX, returns the ssl ctx.
void * daemon_setup_connect_dot_sslctx (struct daemon *daemon, struct config_file *cfg)
 Setup the connect DoT SSL_CTX, returns the ssl ctx.

Detailed Description

The daemon consists of global settings and a number of workers.

Function Documentation

◆ daemon_init()

◆ daemon_open_shared_ports()

◆ daemon_privileged()

int daemon_privileged ( struct daemon * daemon)

Do daemon setup that needs privileges like opening privileged ports or opening device files.

The cfg member pointer must have been set for the daemon.

Parameters
daemonthe daemon.
Returns
: false on error.

References module_env::alloc, daemon::cfg, module_env::cfg, daemon_privileged(), daemon::env, fatal_exit(), daemon::mods, modstack_call_startup(), config_file::module_conf, daemon::superalloc, and module_env::worker.

Referenced by daemon_privileged(), perform_setup(), and service_init().

◆ daemon_fork()

void daemon_fork ( struct daemon * daemon)

Fork workers and start service.

When the routine exits, it is no longer forked.

Parameters
daemonthe daemon.

References daemon::acl, daemon::acl_interface, acl_interface_apply_cfg(), acl_list_apply_cfg(), daemon::allow_proxy_tree, allow_proxy_tree_apply_cfg(), module_env::auth_zones, auth_zones_apply_cfg(), cachedb_is_enabled(), daemon::cfg, config_file::cookie_secret_file, daemon::cookie_secrets, cookie_secrets_apply_cfg(), cookie_secrets_create(), daemon_create_workers(), daemon_fork(), daemon_reload_sslctxs(), daemon_setup_modules(), daemon_start_others(), daemon_stop_others(), config_file::dnscrypt, module_env::edns_strings, edns_strings_apply_cfg(), daemon::env, fatal_exit(), forwards_apply_cfg(), forwards_create(), module_env::fwds, module_env::hints, hints_apply_cfg(), hints_create(), daemon::local_zones, local_zones_apply_cfg(), local_zones_create(), log_assert, log_info(), log_warn(), daemon::mods, modstack_find(), daemon::need_to_exit, worker::need_to_exit, daemon::ports, respip_global_apply_cfg(), module_env::respip_set, respip_set_create(), respip_set_is_empty(), respip_views_apply_cfg(), daemon::reuse_cache, worker::reuse_cache, set_log_thread_id(), config_file::shm_enable, signal_handling_playback(), config_file::stat_interval, daemon::stat_time_offset, daemon::stat_time_specific, daemon::tcl, tcl_list_apply_cfg(), daemon::use_response_ip, daemon::use_rpz, module_env::views, views_apply_cfg(), views_create(), worker_init(), worker_work(), and daemon::workers.

Referenced by daemon_fork(), run_daemon(), and service_main().

◆ daemon_cleanup()

◆ daemon_delete()

◆ daemon_apply_cfg()

◆ setup_acl_for_ports()

int setup_acl_for_ports ( struct acl_list * list,
struct listen_port * port_list )

Setup acl list to have entries for the port list.

Parameters
listthe acl interface
port_listlist of open ports, or none.
Returns
false on failure

References unbound_socket::acl, acl_interface_insert(), acl_refuse, unbound_socket::addr, unbound_socket::addrlen, listen_port::next, setup_acl_for_ports(), and listen_port::socket.

Referenced by ct_acl_interface_setup_ports(), daemon_open_shared_ports(), and setup_acl_for_ports().

◆ ssl_cert_changed()

◆ daemon_setup_listen_dot_sslctx()

void * daemon_setup_listen_dot_sslctx ( struct daemon * daemon,
struct config_file * cfg )

Setup the listening DoT SSL_CTX, returns the ssl ctx.

References daemon_setup_listen_dot_sslctx().

Referenced by ct_create_sslctxs(), and daemon_setup_listen_dot_sslctx().

◆ daemon_setup_listen_doh_sslctx()

void * daemon_setup_listen_doh_sslctx ( struct daemon * daemon,
struct config_file * cfg )

Setup the listening DoH SSL_CTX, returns the ssl ctx.

References daemon_setup_listen_doh_sslctx().

Referenced by ct_create_sslctxs(), and daemon_setup_listen_doh_sslctx().

◆ daemon_setup_listen_quic_sslctx()

void * daemon_setup_listen_quic_sslctx ( struct daemon * daemon,
struct config_file * cfg )

Setup the listening Quic SSL_CTX, returns the ssl ctx.

References daemon_setup_listen_quic_sslctx().

Referenced by ct_create_sslctxs(), and daemon_setup_listen_quic_sslctx().

◆ daemon_setup_connect_dot_sslctx()

void * daemon_setup_connect_dot_sslctx ( struct daemon * daemon,
struct config_file * cfg )

Setup the connect DoT SSL_CTX, returns the ssl ctx.

References daemon_setup_connect_dot_sslctx().

Referenced by ct_create_sslctxs(), and daemon_setup_connect_dot_sslctx().