|
unbound 0.1
|
This program delays queries made. More...
#include "config.h"#include <sys/time.h>#include "util/net_help.h"#include "util/config_file.h"#include "sldns/sbuffer.h"#include <signal.h>Data Structures | |
| struct | ringbuf |
| The ring buffer. More... | |
| struct | proxy |
| List of proxy fds that return replies from the server to our clients. More... | |
| struct | tcp_send_list |
| An item that has to be TCP relayed. More... | |
| struct | tcp_proxy |
| List of TCP proxy fd pairs to TCP connect client to server. More... | |
Macros | |
| #define | TRIES_PER_SELECT 100 |
| number of reads per select for delayer | |
Functions | |
| static void | usage (char *argv[]) |
| usage information for delayer | |
| static int | dl_tv_smaller (struct timeval *t1, const struct timeval *t2) |
| timeval compare, t1 < t2 | |
| static void | dl_tv_add (struct timeval *t1, const struct timeval *t2) |
| timeval add, t1 += t2 | |
| static void | dl_tv_subtract (struct timeval *t1, const struct timeval *t2) |
| timeval subtract, t1 -= t2 | |
| static struct ringbuf * | ring_create (size_t sz) |
| create new ring buffer | |
| static void | ring_delete (struct ringbuf *r) |
| delete ring buffer | |
| static void | ring_add (struct ringbuf *r, sldns_buffer *pkt, struct timeval *now, struct timeval *delay, struct proxy *p) |
| add entry to ringbuffer | |
| static int | ring_empty (struct ringbuf *r) |
| see if the ringbuffer is empty | |
| static struct timeval * | ring_peek_time (struct ringbuf *r) |
| peek at timevalue for next item in ring | |
| static int | ring_pop (struct ringbuf *r, sldns_buffer *pkt, struct timeval *tv, struct proxy **p) |
| get entry from ringbuffer | |
| static RETSIGTYPE | delayer_sigh (int sig) |
| signal handler for user quit | |
| static void | service_send (struct ringbuf *ring, struct timeval *now, sldns_buffer *pkt, struct sockaddr_storage *srv_addr, socklen_t srv_len) |
| send out waiting packets | |
| static void | do_proxy (struct proxy *p, int retsock, sldns_buffer *pkt) |
| do proxy for one readable client | |
| static void | service_proxy (fd_set *rset, int retsock, struct proxy *proxies, sldns_buffer *pkt, struct timeval *now) |
| proxy return replies to clients | |
| static struct proxy * | find_create_proxy (struct sockaddr_storage *from, socklen_t from_len, fd_set *rorig, int *max, struct proxy **proxies, int serv_ip6, struct timeval *now, struct timeval *reuse_timeout) |
| find or else create proxy for this remote client | |
| static void | service_recv (int s, struct ringbuf *ring, sldns_buffer *pkt, fd_set *rorig, int *max, struct proxy **proxies, struct sockaddr_storage *srv_addr, socklen_t srv_len, struct timeval *now, struct timeval *delay, struct timeval *reuse) |
| recv new waiting packets | |
| static void | tcp_proxy_delete (struct tcp_proxy *p) |
| delete tcp proxy | |
| static void | service_tcp_listen (int s, fd_set *rorig, int *max, struct tcp_proxy **proxies, struct sockaddr_storage *srv_addr, socklen_t srv_len, struct timeval *now, struct timeval *tcp_timeout) |
| accept new TCP connections, and set them up | |
| static int | tcp_relay_read (int s, struct tcp_send_list **first, struct tcp_send_list **last, struct timeval *now, struct timeval *delay, sldns_buffer *pkt) |
| relay TCP, read a part | |
| static int | tcp_relay_write (int s, struct tcp_send_list **first, struct tcp_send_list **last, struct timeval *now) |
| relay TCP, write a part | |
| static void | service_tcp_relay (struct tcp_proxy **tcp_proxies, struct timeval *now, struct timeval *delay, struct timeval *tcp_timeout, sldns_buffer *pkt, fd_set *rset, fd_set *rorig, fd_set *worig) |
| perform TCP relaying | |
| static int | service_findwait (struct timeval *now, struct timeval *wait, struct ringbuf *ring, struct tcp_proxy *tcplist) |
| find waiting time | |
| static void | proxy_list_clear (struct proxy *p) |
| clear proxy list | |
| static void | tcp_proxy_list_clear (struct tcp_proxy *p) |
| clear TCP proxy list | |
| static void | service_loop (int udp_s, int listen_s, struct ringbuf *ring, struct timeval *delay, struct timeval *reuse, struct sockaddr_storage *srv_addr, socklen_t srv_len, sldns_buffer *pkt) |
| delayer service loop | |
| static void | service (const char *bind_str, int bindport, const char *serv_str, size_t memsize, int delay_msec) |
| delayer main service routine | |
| int | main (int argc, char **argv) |
| main program for delayer | |
Variables | |
| static volatile int | do_quit = 0 |
| signal handler global info | |
| int | optind |
| getopt global, in case header files fail to declare it. | |
| char * | optarg |
| getopt global, in case header files fail to declare it. | |
This program delays queries made.
It performs as a proxy to another server and delays queries to it.
| #define TRIES_PER_SELECT 100 |
number of reads per select for delayer
Referenced by do_proxy(), and service_recv().
|
static |
usage information for delayer
References usage().
|
static |
timeval compare, t1 < t2
References dl_tv_smaller().
Referenced by dl_tv_smaller(), find_create_proxy(), service_findwait(), service_send(), service_tcp_relay(), and tcp_relay_write().
|
static |
timeval add, t1 += t2
References dl_tv_add().
Referenced by dl_tv_add(), ring_add(), service(), service_tcp_listen(), service_tcp_relay(), and tcp_relay_read().
|
static |
timeval subtract, t1 -= t2
References dl_tv_subtract().
Referenced by dl_tv_subtract(), find_create_proxy(), and service_findwait().
|
static |
create new ring buffer
References ringbuf::buf, fatal_exit(), ringbuf::high, ringbuf::low, ring_create(), and ringbuf::size.
Referenced by ring_create(), and service().
|
static |
delete ring buffer
References ringbuf::buf, and ring_delete().
Referenced by ring_delete(), and service().
|
static |
add entry to ringbuffer
References ringbuf::buf, dl_tv_add(), ringbuf::high, log_assert, log_warn(), ringbuf::low, ring_add(), ringbuf::size, sldns_buffer_begin(), and sldns_buffer_limit().
Referenced by ring_add(), and service_recv().
|
static |
see if the ringbuffer is empty
References ringbuf::high, ringbuf::low, and ring_empty().
Referenced by ring_empty(), ring_peek_time(), and service_send().
|
static |
peek at timevalue for next item in ring
References ringbuf::buf, ringbuf::low, ring_empty(), and ring_peek_time().
Referenced by ring_peek_time(), service_findwait(), and service_send().
|
static |
get entry from ringbuffer
References ringbuf::buf, ringbuf::high, log_assert, ringbuf::low, ring_pop(), ringbuf::size, sldns_buffer_begin(), and sldns_buffer_set_limit().
Referenced by ring_pop(), and service_send().
|
static |
signal handler for user quit
References delayer_sigh(), and do_quit.
Referenced by delayer_sigh(), and service().
|
static |
send out waiting packets
References proxy::addr, proxy::addr_len, dl_tv_smaller(), fatal_exit(), proxy::lastuse, log_addr(), log_err(), proxy::numsent, ring_empty(), ring_peek_time(), ring_pop(), proxy::s, service_send(), sldns_buffer_begin(), sldns_buffer_limit(), sock_strerror(), and verbose().
Referenced by service_loop(), and service_send().
|
static |
do proxy for one readable client
References proxy::addr, proxy::addr_len, do_proxy(), log_addr(), log_err(), proxy::numreturn, proxy::s, sldns_buffer_begin(), sldns_buffer_capacity(), sldns_buffer_set_limit(), sock_strerror(), and TRIES_PER_SELECT.
Referenced by do_proxy(), and service_proxy().
|
static |
proxy return replies to clients
References do_proxy(), proxy::lastuse, proxy::next, proxy::s, and service_proxy().
Referenced by service_loop(), and service_proxy().
|
static |
find or else create proxy for this remote client
References proxy::addr, proxy::addr_len, dl_tv_smaller(), dl_tv_subtract(), fatal_exit(), fd_set_nonblock(), find_create_proxy(), proxy::lastuse, proxy::next, proxy::numreturn, proxy::numreuse, proxy::numsent, proxy::numwait, proxy::s, sock_strerror(), sockaddr_cmp(), and verbose().
Referenced by find_create_proxy(), and service_recv().
|
static |
recv new waiting packets
References proxy::addr, addr_is_ip6(), proxy::addr_len, fatal_exit(), find_create_proxy(), proxy::lastuse, log_addr(), proxy::numwait, ring_add(), proxy::s, service_recv(), sldns_buffer_begin(), sldns_buffer_capacity(), sldns_buffer_set_limit(), sock_strerror(), and TRIES_PER_SELECT.
Referenced by service_loop(), and service_recv().
|
static |
delete tcp proxy
References tcp_proxy::addr, tcp_proxy::addr_len, tcp_proxy::answerlist, tcp_proxy::client_s, tcp_send_list::item, log_addr(), tcp_send_list::next, tcp_proxy::querylist, tcp_proxy::server_s, sock_close(), and tcp_proxy_delete().
Referenced by service_tcp_relay(), tcp_proxy_delete(), and tcp_proxy_list_clear().
|
static |
accept new TCP connections, and set them up
References tcp_proxy::addr, addr_is_ip6(), tcp_proxy::addr_len, tcp_proxy::client_s, dl_tv_add(), fatal_exit(), fd_set_nonblock(), log_addr(), log_err(), tcp_proxy::next, tcp_proxy::server_s, service_tcp_listen(), sock_close(), sock_strerror(), and tcp_proxy::timeout.
Referenced by service_loop(), and service_tcp_listen().
|
static |
relay TCP, read a part
References dl_tv_add(), tcp_send_list::item, log_err(), memdup(), sldns_buffer_begin(), sldns_buffer_capacity(), sock_strerror(), tcp_relay_read(), and verbose().
Referenced by service_tcp_relay(), and tcp_relay_read().
|
static |
relay TCP, write a part
References dl_tv_smaller(), tcp_send_list::done, tcp_send_list::item, tcp_send_list::len, log_err(), tcp_send_list::next, sock_strerror(), tcp_relay_write(), verbose(), and tcp_send_list::wait.
Referenced by service_tcp_relay(), and tcp_relay_write().
|
static |
perform TCP relaying
References tcp_proxy::addr, tcp_proxy::addr_len, tcp_proxy::answerlast, tcp_proxy::answerlist, tcp_proxy::client_s, dl_tv_add(), dl_tv_smaller(), log_addr(), tcp_proxy::next, tcp_proxy::querylast, tcp_proxy::querylist, tcp_proxy::server_s, service_tcp_relay(), sock_close(), tcp_proxy_delete(), tcp_relay_read(), tcp_relay_write(), tcp_proxy::timeout, and tcp_send_list::wait.
Referenced by service_loop(), and service_tcp_relay().
|
static |
find waiting time
References tcp_proxy::answerlist, dl_tv_smaller(), dl_tv_subtract(), tcp_proxy::next, tcp_proxy::querylist, ring_peek_time(), service_findwait(), tcp_proxy::timeout, and tcp_send_list::wait.
Referenced by service_findwait(), and service_loop().
|
static |
clear proxy list
References proxy::addr, addr_is_ip6(), proxy::addr_len, proxy::next, proxy::numreturn, proxy::numreuse, proxy::numsent, proxy::numwait, proxy_list_clear(), proxy::s, and sock_close().
Referenced by proxy_list_clear(), and service_loop().
|
static |
clear TCP proxy list
References tcp_proxy::next, tcp_proxy_delete(), and tcp_proxy_list_clear().
Referenced by service_loop(), and tcp_proxy_list_clear().
|
static |
delayer service loop
References do_quit, fatal_exit(), proxy_list_clear(), service_findwait(), service_loop(), service_proxy(), service_recv(), service_send(), service_tcp_listen(), service_tcp_relay(), tcp_proxy_list_clear(), and verbose().
Referenced by service(), and service_loop().
|
static |
delayer main service routine
References delayer_sigh(), dl_tv_add(), do_quit, extstrtoaddr(), fatal_exit(), fd_set_nonblock(), ipstrtoaddr(), log_err(), ring_create(), ring_delete(), service_loop(), sldns_buffer_free(), sldns_buffer_new(), sock_close(), sock_strerror(), str_is_ip6(), and verbose().
Referenced by main().
| int main | ( | int | argc, |
| char ** | argv ) |
main program for delayer
References cfg_parse_memsize(), log_ident_set(), log_init(), main, optarg, optind, service(), usage(), and verbosity.
|
static |
signal handler global info
Referenced by delayer_sigh(), service(), and service_loop().