unbound
0.1
|
This file contains the remote control functionality for the daemon. More...
#include "config.h"
#include <ctype.h>
#include <ldns/ldns.h>
#include "daemon/remote.h"
#include "daemon/worker.h"
#include "daemon/daemon.h"
#include "daemon/stats.h"
#include "daemon/cachedump.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/module.h"
#include "services/listen_dnsport.h"
#include "services/cache/rrset.h"
#include "services/cache/infra.h"
#include "services/mesh.h"
#include "services/localzone.h"
#include "util/storage/slabhash.h"
#include "util/fptr_wlist.h"
#include "util/data/dname.h"
#include "validator/validator.h"
#include "validator/val_kcache.h"
#include "validator/val_kentry.h"
#include "validator/val_anchor.h"
#include "iterator/iterator.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_hints.h"
#include "iterator/iter_delegpt.h"
#include "services/outbound_list.h"
#include "services/outside_network.h"
Data Structures | |
struct | del_info |
Local info for deletion functions. More... | |
struct | infra_arg |
structure for argument data for dump infra host More... |
Macros | |
#define | SQ "=" |
what to put on statistics lines between var and value, ": " or "=" |
Functions | |
static void | timeval_subtract (struct timeval *d, const struct timeval *end, const struct timeval *start) |
subtract timers and the values do not overflow or become negative | |
static void | timeval_divide (struct timeval *avg, const struct timeval *sum, size_t d) |
divide sum of timers to get average | |
struct daemon_remote * | daemon_remote_create (struct config_file *cfg) |
Create new remote control state for the daemon. | |
void | daemon_remote_clear (struct daemon_remote *rc) |
remote control state to clear up. | |
void | daemon_remote_delete (struct daemon_remote *rc) |
remote control state to delete. | |
static int | add_open (const char *ip, int nr, struct listen_port **list, int noproto_is_err) |
Add and open a new control port. | |
struct listen_port * | daemon_remote_open_ports (struct config_file *cfg) |
Open and create listening ports for remote control. | |
static int | accept_open (struct daemon_remote *rc, int fd) |
open accept commpoint | |
int | daemon_remote_open_accept (struct daemon_remote *rc, struct listen_port *ports, struct worker *worker) |
Setup comm points for accepting remote control connections. | |
void | daemon_remote_stop_accept (struct daemon_remote *rc) |
Stop accept handlers for TCP (until enabled again) | |
void | daemon_remote_start_accept (struct daemon_remote *rc) |
Stop accept handlers for TCP (until enabled again) | |
int | remote_accept_callback (struct comm_point *c, void *arg, int err, struct comm_reply *ATTR_UNUSED(rep)) |
static void | state_list_remove_elem (struct rc_state **list, struct comm_point *c) |
delete from list | |
static void | clean_point (struct daemon_remote *rc, struct rc_state *s) |
decrease active count and remove commpoint from busy list | |
int | ssl_print_text (SSL *ssl, const char *text) |
Print fixed line of text over ssl connection in blocking mode. | |
static int | ssl_print_vmsg (SSL *ssl, const char *format, va_list args) |
print text over the ssl connection | |
int | ssl_printf (SSL *ssl, const char *format,...) |
printf style printing to the ssl connection | |
int | ssl_read_line (SSL *ssl, char *buf, size_t max) |
Read until is encountered If SSL signals EOF, the string up to then is returned (without ). | |
static char * | skipwhite (char *str) |
skip whitespace, return new pointer into string | |
static void | send_ok (SSL *ssl) |
send the OK to the control client | |
static void | do_stop (SSL *ssl, struct daemon_remote *rc) |
do the stop command | |
static void | do_reload (SSL *ssl, struct daemon_remote *rc) |
do the reload command | |
static void | do_verbosity (SSL *ssl, char *str) |
do the verbosity command | |
static int | print_stats (SSL *ssl, const char *nm, struct stats_info *s) |
print stats from statinfo | |
static int | print_thread_stats (SSL *ssl, int i, struct stats_info *s) |
print stats for one thread | |
static int | print_longnum (SSL *ssl, char *desc, size_t x) |
print long number | |
static int | print_mem (SSL *ssl, struct worker *worker, struct daemon *daemon) |
print mem stats | |
static int | print_uptime (SSL *ssl, struct worker *worker, int reset) |
print uptime stats | |
static int | print_hist (SSL *ssl, struct stats_info *s) |
print extended histogram | |
static int | print_ext (SSL *ssl, struct stats_info *s) |
print extended stats | |
static void | do_stats (SSL *ssl, struct daemon_remote *rc, int reset) |
do the stats command | |
static int | parse_arg_name (SSL *ssl, char *str, uint8_t **res, size_t *len, int *labs) |
parse commandline argument domain name | |
static int | find_arg2 (SSL *ssl, char *arg, char **arg2) |
find second argument, modifies string | |
static void | do_zone_add (SSL *ssl, struct worker *worker, char *arg) |
Add a new zone. | |
static void | do_zone_remove (SSL *ssl, struct worker *worker, char *arg) |
Remove a zone. | |
static void | do_data_add (SSL *ssl, struct worker *worker, char *arg) |
Add new RR data. | |
static void | do_data_remove (SSL *ssl, struct worker *worker, char *arg) |
Remove RR data. | |
static void | do_lookup (SSL *ssl, struct worker *worker, char *arg) |
cache lookup of nameservers | |
static void | do_cache_remove (struct worker *worker, uint8_t *nm, size_t nmlen, uint16_t t, uint16_t c) |
flush something from rrset and msg caches | |
static void | do_flush_type (SSL *ssl, struct worker *worker, char *arg) |
flush a type | |
static void | do_flush_stats (SSL *ssl, struct worker *worker) |
flush statistics | |
static void | infra_del_host (struct lruhash_entry *e, void *arg) |
callback to delete hosts in infra cache | |
static void | do_flush_infra (SSL *ssl, struct worker *worker, char *arg) |
flush infra cache | |
static void | do_flush_requestlist (SSL *ssl, struct worker *worker) |
flush requestlist | |
static void | zone_del_rrset (struct lruhash_entry *e, void *arg) |
callback to delete rrsets in a zone | |
static void | zone_del_msg (struct lruhash_entry *e, void *arg) |
callback to delete messages in a zone | |
static void | zone_del_kcache (struct lruhash_entry *e, void *arg) |
callback to delete keys in zone | |
static void | do_flush_zone (SSL *ssl, struct worker *worker, char *arg) |
remove all rrsets and keys from zone from cache | |
static void | do_flush_name (SSL *ssl, struct worker *w, char *arg) |
remove name rrset from cache | |
static int | ssl_print_name_dp (SSL *ssl, char *str, uint8_t *nm, uint16_t dclass, struct delegpt *dp) |
printout a delegation point info | |
static int | print_root_fwds (SSL *ssl, struct iter_forwards *fwds, uint8_t *root) |
print root forwards | |
static struct delegpt * | parse_delegpt (SSL *ssl, char *args, uint8_t *nm, int allow_names) |
parse args into delegpt | |
static void | do_forward (SSL *ssl, struct worker *worker, char *args) |
do the status command | |
static int | parse_fs_args (SSL *ssl, char *args, uint8_t **nm, struct delegpt **dp, int *insecure, int *prime) |
static void | do_forward_add (SSL *ssl, struct worker *worker, char *args) |
do the forward_add command | |
static void | do_forward_remove (SSL *ssl, struct worker *worker, char *args) |
do the forward_remove command | |
static void | do_stub_add (SSL *ssl, struct worker *worker, char *args) |
do the stub_add command | |
static void | do_stub_remove (SSL *ssl, struct worker *worker, char *args) |
do the stub_remove command | |
static void | do_status (SSL *ssl, struct worker *worker) |
do the status command | |
static void | get_mesh_age (struct mesh_state *m, char *buf, size_t len, struct module_env *env) |
get age for the mesh state | |
static void | get_mesh_status (struct mesh_area *mesh, struct mesh_state *m, char *buf, size_t len) |
get status of a mesh state | |
static void | do_dump_requestlist (SSL *ssl, struct worker *worker) |
do the dump_requestlist command | |
static void | dump_infra_host (struct lruhash_entry *e, void *arg) |
callback for every host element in the infra cache | |
static void | do_dump_infra (SSL *ssl, struct worker *worker) |
do the dump_infra command | |
static void | do_log_reopen (SSL *ssl, struct worker *worker) |
do the log_reopen command | |
static void | do_set_option (SSL *ssl, struct worker *worker, char *arg) |
do the set_option command | |
void | remote_get_opt_ssl (char *line, void *arg) |
routine to printout option values over SSL | |
static void | do_get_option (SSL *ssl, struct worker *worker, char *arg) |
do the get_option command | |
static void | do_list_forwards (SSL *ssl, struct worker *worker) |
do the list_forwards command | |
static void | do_list_stubs (SSL *ssl, struct worker *worker) |
do the list_stubs command | |
static void | do_list_local_zones (SSL *ssl, struct worker *worker) |
do the list_local_zones command | |
static void | do_list_local_data (SSL *ssl, struct worker *worker) |
do the list_local_data command | |
static void | distribute_cmd (struct daemon_remote *rc, SSL *ssl, char *cmd) |
tell other processes to execute the command | |
static int | cmdcmp (char *p, const char *cmd, size_t len) |
check for name with end-of-string, space or tab after it | |
static void | execute_cmd (struct daemon_remote *rc, SSL *ssl, char *cmd, struct worker *worker) |
execute a remote control command | |
void | daemon_remote_exec (struct worker *worker) |
Handle nonthreaded remote cmd execution. | |
static void | handle_req (struct daemon_remote *rc, struct rc_state *s, SSL *ssl) |
handle remote control request | |
int | remote_control_callback (struct comm_point *c, void *arg, int err, struct comm_reply *ATTR_UNUSED(rep)) |
Variables | |
static const int | inhibit_zero = 1 |
if true, inhibits a lot of =0 lines from the stats output |
This file contains the remote control functionality for the daemon.
The remote control can be performed using either the commandline unbound-control tool, or a SSLv3/TLS capable web browser. The channel is secured using SSLv3 or TLSv1, and certificates. Both the server and the client(control tool) have their own keys.
|
read |
Create new remote control state for the daemon.
cfg,: | config file with key file settings. |
References daemon_remote::ctx, daemon_remote_delete(), fname_after_chroot(), log_crypto_err(), log_err(), daemon_remote::max_active, config_file::remote_control_enable, config_file::server_cert_file, config_file::server_key_file, VERB_ALGO, and verbose().
Referenced by perform_setup(), and service_init().
void daemon_remote_clear | ( | struct daemon_remote * | rc | ) |
remote control state to clear up.
Busy and accept points are closed. Does not delete the rc itself, or the ssl context (with its keys).
rc,: | state to clear. |
References daemon_remote::accept_list, daemon_remote::active, daemon_remote::busy_list, rc_state::c, comm_point_delete(), listen_list_delete(), rc_state::next, rc_state::ssl, and daemon_remote::worker.
Referenced by daemon_cleanup(), and daemon_remote_delete().
void daemon_remote_delete | ( | struct daemon_remote * | rc | ) |
remote control state to delete.
rc,: | state to delete. |
Referenced by daemon_delete(), and daemon_remote_create().
|
static |
Add and open a new control port.
ip,: | ip str |
nr,: | port nr |
list,: | list head |
noproto_is_err,: | if lack of protocol support is an error. |
References create_tcp_accept_sock(), listen_port::fd, log_err(), and listen_port::next.
Referenced by daemon_remote_open_ports().
|
read |
Open and create listening ports for remote control.
cfg,: | config options. |
References add_open(), config_file::control_ifs, config_file::control_port, config_file::do_ip4, config_file::do_ip6, listening_ports_free(), log_assert, config_strlist::next, config_file::remote_control_enable, and config_strlist::str.
Referenced by daemon_open_shared_ports().
int daemon_remote_open_accept | ( | struct daemon_remote * | rc, |
struct listen_port * | ports, | ||
struct worker * | worker | ||
) |
Setup comm points for accepting remote control connections.
rc,: | state |
ports,: | already opened ports. |
worker,: | worker with communication base. and links to command channels. |
References accept_open(), listen_port::fd, log_err(), listen_port::next, and daemon_remote::worker.
Referenced by worker_init().
void daemon_remote_stop_accept | ( | struct daemon_remote * | rc | ) |
Stop accept handlers for TCP (until enabled again)
rc,: | state |
References daemon_remote::accept_list, listen_list::com, and listen_list::next.
Referenced by worker_stop_accept().
void daemon_remote_start_accept | ( | struct daemon_remote * | rc | ) |
Stop accept handlers for TCP (until enabled again)
rc,: | state |
References daemon_remote::accept_list, listen_list::com, and listen_list::next.
Referenced by worker_start_accept().
int ssl_print_text | ( | SSL * | ssl, |
const char * | text | ||
) |
Print fixed line of text over ssl connection in blocking mode.
ssl,: | print to |
text,: | the text. |
References log_crypto_err(), VERB_QUERY, and verbose().
Referenced by ssl_print_vmsg().
int ssl_read_line | ( | SSL * | ssl, |
char * | buf, | ||
size_t | max | ||
) |
Read until
is encountered If SSL signals EOF, the string up to then is returned (without
).
ssl,: | the SSL connection to read from. blocking. |
buf,: | buffer to read to. |
max,: | size of buffer. |
References log_crypto_err(), and log_err().
Referenced by handle_req(), and ssl_read_buf().
void daemon_remote_exec | ( | struct worker * | worker | ) |
Handle nonthreaded remote cmd execution.
worker,: | this worker (the remote worker). |
References worker::cmd, execute_cmd(), log_err(), tube_read_msg(), VERB_ALGO, and verbose().