Purge through the control socket
This commit is contained in:
parent
6eaefb4dbc
commit
1065879c8c
8 changed files with 19 additions and 16 deletions
|
@ -1569,9 +1569,6 @@ New outgoing connections specified in @file{tinc.conf} will be made.
|
||||||
Temporarily increases debug level to 5.
|
Temporarily increases debug level to 5.
|
||||||
Send this signal again to revert to the original level.
|
Send this signal again to revert to the original level.
|
||||||
|
|
||||||
@item WINCH
|
|
||||||
Purges all information remembered about unreachable nodes.
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@c ==================================================================
|
@c ==================================================================
|
||||||
|
@ -1854,6 +1851,9 @@ Dump a list of all meta connections with ourself.
|
||||||
@item dump graph
|
@item dump graph
|
||||||
Dump a graph of the VPN in dotty format.
|
Dump a graph of the VPN in dotty format.
|
||||||
|
|
||||||
|
@item purge
|
||||||
|
Purges all information remembered about unreachable nodes.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ Dump a list of all meta connections with ourself.
|
||||||
Dump a graph of the VPN in
|
Dump a graph of the VPN in
|
||||||
.Xr dotty 1
|
.Xr dotty 1
|
||||||
format.
|
format.
|
||||||
|
.It purge
|
||||||
|
Purges all information remembered about unreachable nodes.
|
||||||
.El
|
.El
|
||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
The "start", "restart", and "reload" commands are not yet implemented.
|
The "start", "restart", and "reload" commands are not yet implemented.
|
||||||
|
|
|
@ -98,8 +98,6 @@ will be made.
|
||||||
.It INT
|
.It INT
|
||||||
Temporarily increases debug level to 5.
|
Temporarily increases debug level to 5.
|
||||||
Send this signal again to revert to the original level.
|
Send this signal again to revert to the original level.
|
||||||
.It WINCH
|
|
||||||
Purges all information remembered about unreachable nodes.
|
|
||||||
.El
|
.El
|
||||||
.Sh DEBUG LEVELS
|
.Sh DEBUG LEVELS
|
||||||
The tinc daemon can send a lot of messages to the syslog.
|
The tinc daemon can send a lot of messages to the syslog.
|
||||||
|
|
|
@ -97,6 +97,12 @@ static void handle_control_data(struct bufferevent *event, void *data) {
|
||||||
goto respond;
|
goto respond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(req.type == REQ_PURGE) {
|
||||||
|
logger(LOG_NOTICE, _("Got '%s' command"), "purge");
|
||||||
|
purge();
|
||||||
|
goto respond;
|
||||||
|
}
|
||||||
|
|
||||||
logger(LOG_DEBUG, _("Malformed control command received"));
|
logger(LOG_DEBUG, _("Malformed control command received"));
|
||||||
res.res_errno = EINVAL;
|
res.res_errno = EINVAL;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum request_type {
|
||||||
REQ_DUMP_SUBNETS,
|
REQ_DUMP_SUBNETS,
|
||||||
REQ_DUMP_CONNECTIONS,
|
REQ_DUMP_CONNECTIONS,
|
||||||
REQ_DUMP_GRAPH,
|
REQ_DUMP_GRAPH,
|
||||||
|
REQ_PURGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TINC_CTL_VERSION_CURRENT 0
|
#define TINC_CTL_VERSION_CURRENT 0
|
||||||
|
|
11
src/net.c
11
src/net.c
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
/* Purge edges and subnets of unreachable nodes. Use carefully. */
|
/* Purge edges and subnets of unreachable nodes. Use carefully. */
|
||||||
|
|
||||||
static void purge(void) {
|
void purge(void) {
|
||||||
splay_node_t *nnode, *nnext, *enode, *enext, *snode, *snext;
|
splay_node_t *nnode, *nnext, *enode, *enext, *snode, *snext;
|
||||||
node_t *n;
|
node_t *n;
|
||||||
edge_t *e;
|
edge_t *e;
|
||||||
|
@ -252,11 +252,6 @@ static void sigint_handler(int signal, short events, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sigwinch_handler(int signal, short events, void *data) {
|
|
||||||
logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal));
|
|
||||||
purge();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sighup_handler(int signal, short events, void *data) {
|
static void sighup_handler(int signal, short events, void *data) {
|
||||||
connection_t *c;
|
connection_t *c;
|
||||||
splay_node_t *node, *next;
|
splay_node_t *node, *next;
|
||||||
|
@ -333,7 +328,6 @@ int main_loop(void) {
|
||||||
struct event sigint_event;
|
struct event sigint_event;
|
||||||
struct event sigterm_event;
|
struct event sigterm_event;
|
||||||
struct event sigquit_event;
|
struct event sigquit_event;
|
||||||
struct event sigwinch_event;
|
|
||||||
struct event sigalrm_event;
|
struct event sigalrm_event;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
@ -348,8 +342,6 @@ int main_loop(void) {
|
||||||
signal_add(&sigterm_event, NULL);
|
signal_add(&sigterm_event, NULL);
|
||||||
signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
|
signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
|
||||||
signal_add(&sigquit_event, NULL);
|
signal_add(&sigquit_event, NULL);
|
||||||
signal_set(&sigwinch_event, SIGWINCH, sigwinch_handler, NULL);
|
|
||||||
signal_add(&sigwinch_event, NULL);
|
|
||||||
signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL);
|
signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL);
|
||||||
signal_add(&sigalrm_event, NULL);
|
signal_add(&sigalrm_event, NULL);
|
||||||
|
|
||||||
|
@ -362,7 +354,6 @@ int main_loop(void) {
|
||||||
signal_del(&sigint_event);
|
signal_del(&sigint_event);
|
||||||
signal_del(&sigterm_event);
|
signal_del(&sigterm_event);
|
||||||
signal_del(&sigquit_event);
|
signal_del(&sigquit_event);
|
||||||
signal_del(&sigwinch_event);
|
|
||||||
signal_del(&sigalrm_event);
|
signal_del(&sigalrm_event);
|
||||||
event_del(&timeout_event);
|
event_del(&timeout_event);
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,6 @@ extern listen_socket_t listen_socket[MAXSOCKETS];
|
||||||
extern int listen_sockets;
|
extern int listen_sockets;
|
||||||
extern int keylifetime;
|
extern int keylifetime;
|
||||||
extern bool do_prune;
|
extern bool do_prune;
|
||||||
extern bool do_purge;
|
|
||||||
extern char *myport;
|
extern char *myport;
|
||||||
extern EVP_CIPHER_CTX packet_ctx;
|
extern EVP_CIPHER_CTX packet_ctx;
|
||||||
|
|
||||||
|
@ -156,6 +155,7 @@ extern void send_mtu_probe(struct node_t *);
|
||||||
extern void handle_device_data(int, short, void *);
|
extern void handle_device_data(int, short, void *);
|
||||||
extern void handle_meta_connection_data(int, short, void *);
|
extern void handle_meta_connection_data(int, short, void *);
|
||||||
extern void regenerate_key();
|
extern void regenerate_key();
|
||||||
|
extern void purge(void);
|
||||||
|
|
||||||
#ifndef HAVE_MINGW
|
#ifndef HAVE_MINGW
|
||||||
#define closesocket(s) close(s)
|
#define closesocket(s) close(s)
|
||||||
|
|
|
@ -89,6 +89,7 @@ static void usage(bool status) {
|
||||||
" subnets - all known subnets in the VPN\n"
|
" subnets - all known subnets in the VPN\n"
|
||||||
" connections - all meta connections with ourself\n"
|
" connections - all meta connections with ourself\n"
|
||||||
" graph - graph of the VPN in dotty format\n"
|
" graph - graph of the VPN in dotty format\n"
|
||||||
|
" purge Purge unreachable nodes\n"
|
||||||
"\n"));
|
"\n"));
|
||||||
printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
|
printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
|
||||||
}
|
}
|
||||||
|
@ -578,6 +579,10 @@ int main(int argc, char *argv[], char *envp[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!strcasecmp(argv[optind], "purge")) {
|
||||||
|
return send_ctl_request_cooked(fd, REQ_PURGE, NULL, 0) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
|
fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
|
||||||
usage(true);
|
usage(true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue