Retry connections through control socket
This commit is contained in:
parent
a62a6825a8
commit
f0a57eab4c
8 changed files with 33 additions and 26 deletions
|
|
@ -124,6 +124,12 @@ static void handle_control_data(struct bufferevent *event, void *data) {
|
|||
goto respond;
|
||||
}
|
||||
|
||||
if(req.type == REQ_RETRY) {
|
||||
logger(LOG_NOTICE, _("Got '%s' command"), "retry");
|
||||
retry();
|
||||
goto respond;
|
||||
}
|
||||
|
||||
logger(LOG_DEBUG, _("Malformed control command received"));
|
||||
res.res_errno = EINVAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ enum request_type {
|
|||
REQ_DUMP_GRAPH,
|
||||
REQ_PURGE,
|
||||
REQ_SET_DEBUG,
|
||||
REQ_RETRY,
|
||||
};
|
||||
|
||||
#define TINC_CTL_VERSION_CURRENT 0
|
||||
|
|
|
|||
|
|
@ -280,9 +280,7 @@ static void sighup_handler(int signal, short events, void *data) {
|
|||
try_outgoing_connections();
|
||||
}
|
||||
|
||||
static void sigalrm_handler(int signal, short events, void *data) {
|
||||
logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal));
|
||||
|
||||
void retry(void) {
|
||||
connection_t *c;
|
||||
splay_node_t *node;
|
||||
|
||||
|
|
@ -308,7 +306,6 @@ int main_loop(void) {
|
|||
struct event sighup_event;
|
||||
struct event sigterm_event;
|
||||
struct event sigquit_event;
|
||||
struct event sigalrm_event;
|
||||
|
||||
cp();
|
||||
|
||||
|
|
@ -320,8 +317,6 @@ int main_loop(void) {
|
|||
signal_add(&sigterm_event, NULL);
|
||||
signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
|
||||
signal_add(&sigquit_event, NULL);
|
||||
signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL);
|
||||
signal_add(&sigalrm_event, NULL);
|
||||
|
||||
if(event_loop(0) < 0) {
|
||||
logger(LOG_ERR, _("Error while waiting for input: %s"), strerror(errno));
|
||||
|
|
@ -331,7 +326,6 @@ int main_loop(void) {
|
|||
signal_del(&sighup_event);
|
||||
signal_del(&sigterm_event);
|
||||
signal_del(&sigquit_event);
|
||||
signal_del(&sigalrm_event);
|
||||
event_del(&timeout_event);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ extern void handle_device_data(int, short, void *);
|
|||
extern void handle_meta_connection_data(int, short, void *);
|
||||
extern void regenerate_key();
|
||||
extern void purge(void);
|
||||
extern void retry(void);
|
||||
|
||||
#ifndef HAVE_MINGW
|
||||
#define closesocket(s) close(s)
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ static void usage(bool status) {
|
|||
" graph - graph of the VPN in dotty format\n"
|
||||
" purge Purge unreachable nodes\n"
|
||||
" debug N Set debug level\n"
|
||||
" retry Retry all outgoing connections\n"
|
||||
"\n"));
|
||||
printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
|
||||
}
|
||||
|
|
@ -596,6 +597,10 @@ int main(int argc, char *argv[], char *envp[]) {
|
|||
sizeof(debuglevel)) != -1;
|
||||
}
|
||||
|
||||
if(!strcasecmp(argv[optind], "retry")) {
|
||||
return send_ctl_request_cooked(fd, REQ_RETRY, NULL, 0) != -1;
|
||||
}
|
||||
|
||||
fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
|
||||
usage(true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue