Connections to hosts whose host config file are removed are closed.
New outgoing connections specified in @file{tinc.conf} will be made.
-@item INT
-Temporarily increases debug level to 5.
-Send this signal again to revert to the original level.
-
@end table
@c ==================================================================
@item purge
Purges all information remembered about unreachable nodes.
+@item debug @var{level}
+Sets debug level to @var{level}.
+
@end table
format.
.It purge
Purges all information remembered about unreachable nodes.
+.It debug Ar N
+Sets debug level to
+.Ar N .
.El
.Sh BUGS
The "start", "restart", and "reload" commands are not yet implemented.
New outgoing connections specified in
.Pa tinc.conf
will be made.
-.It INT
-Temporarily increases debug level to 5.
-Send this signal again to revert to the original level.
.El
.Sh DEBUG LEVELS
The tinc daemon can send a lot of messages to the syslog.
size_t size;
tinc_ctl_request_t res;
struct evbuffer *res_data = NULL;
+ void *req_data;
if(EVBUFFER_LENGTH(event->input) < sizeof(tinc_ctl_request_t))
return;
if(EVBUFFER_LENGTH(event->input) < req.length)
return;
+ req_data = EVBUFFER_DATA(event->input) + sizeof(tinc_ctl_request_t);
if(req.length < sizeof(tinc_ctl_request_t))
goto failure;
goto respond;
}
+ if(req.type == REQ_SET_DEBUG) {
+ debug_t new_debug_level;
+
+ logger(LOG_NOTICE, _("Got '%s' command"), "debug");
+ if(req.length != sizeof(req) + sizeof debug_level)
+ res.res_errno = EINVAL;
+ else {
+ memcpy(&new_debug_level, req_data, sizeof(debug_t));
+ logger(LOG_NOTICE, _("Changing debug level from %d to %d"),
+ debug_level, new_debug_level);
+ if(evbuffer_add_printf(res_data,
+ _("Changing debug level from %d to %d\n"),
+ debug_level, new_debug_level) == -1)
+ res.res_errno = errno;
+ debug_level = new_debug_level;
+ }
+ goto respond;
+ }
+
logger(LOG_DEBUG, _("Malformed control command received"));
res.res_errno = EINVAL;
REQ_DUMP_CONNECTIONS,
REQ_DUMP_GRAPH,
REQ_PURGE,
+ REQ_SET_DEBUG,
};
#define TINC_CTL_VERSION_CURRENT 0
event_loopexit(NULL);
}
-static void sigint_handler(int signal, short events, void *data) {
- static int saved_debug_level = -1;
-
- logger(LOG_NOTICE, _("Got %s signal"), strsignal(signal));
-
- if(saved_debug_level != -1) {
- logger(LOG_NOTICE, _("Reverting to old debug level (%d)"),
- saved_debug_level);
- debug_level = saved_debug_level;
- saved_debug_level = -1;
- } else {
- logger(LOG_NOTICE,
- _("Temporarily setting debug level to 5. Kill me with SIGINT again to go back to level %d."),
- debug_level);
- saved_debug_level = debug_level;
- debug_level = 5;
- }
-}
-
static void sighup_handler(int signal, short events, void *data) {
connection_t *c;
splay_node_t *node, *next;
int main_loop(void) {
struct event timeout_event;
struct event sighup_event;
- struct event sigint_event;
struct event sigterm_event;
struct event sigquit_event;
struct event sigalrm_event;
event_add(&timeout_event, &(struct timeval){pingtimeout, 0});
signal_set(&sighup_event, SIGHUP, sighup_handler, NULL);
signal_add(&sighup_event, NULL);
- signal_set(&sigint_event, SIGINT, sigint_handler, NULL);
- signal_add(&sigint_event, NULL);
signal_set(&sigterm_event, SIGTERM, sigterm_handler, NULL);
signal_add(&sigterm_event, NULL);
signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL);
}
signal_del(&sighup_event);
- signal_del(&sigint_event);
signal_del(&sigterm_event);
signal_del(&sigquit_event);
signal_del(&sigalrm_event);
" connections - all meta connections with ourself\n"
" graph - graph of the VPN in dotty format\n"
" purge Purge unreachable nodes\n"
+ " debug N Set debug level\n"
"\n"));
printf(_("Report bugs to tinc@tinc-vpn.org.\n"));
}
return send_ctl_request_cooked(fd, REQ_PURGE, NULL, 0) != -1;
}
+ if(!strcasecmp(argv[optind], "debug")) {
+ int debuglevel;
+
+ if(argc != optind + 2) {
+ fprintf(stderr, "Invalid arguments.\n");
+ return 1;
+ }
+ debuglevel = atoi(argv[optind+1]);
+ return send_ctl_request_cooked(fd, REQ_SET_DEBUG, &debuglevel,
+ sizeof(debuglevel)) != -1;
+ }
+
fprintf(stderr, _("Unknown command `%s'.\n"), argv[optind]);
usage(true);