X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=56179c6ec19d3576246463c54493b80220cd2c3f;hb=1065879c8c6e8cdf8d3755024241f31eaabd4138;hp=3944fa2e96f516136e043fb13cadd9752a567996;hpb=50ad3f2a895c38f8d546f87490ca96ab7d9e011e;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 3944fa2e..56179c6e 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -89,6 +89,7 @@ static void usage(bool status) { " subnets - all known subnets in the VPN\n" " connections - all meta connections with ourself\n" " graph - graph of the VPN in dotty format\n" + " purge Purge unreachable nodes\n" "\n")); printf(_("Report bugs to tinc@tinc-vpn.org.\n")); } @@ -546,6 +547,42 @@ int main(int argc, char *argv[], char *envp[]) { return send_ctl_request_cooked(fd, REQ_RESTART, NULL, 0) != -1; } + if(!strcasecmp(argv[optind], "dump")) { + if (argc < optind + 2) { + fprintf(stderr, _("Not enough arguments.\n")); + usage(true); + return 1; + } + + if(!strcasecmp(argv[optind+1], "nodes")) { + return send_ctl_request_cooked(fd, REQ_DUMP_NODES, NULL, 0) != -1; + } + + if(!strcasecmp(argv[optind+1], "edges")) { + return send_ctl_request_cooked(fd, REQ_DUMP_EDGES, NULL, 0) != -1; + } + + if(!strcasecmp(argv[optind+1], "subnets")) { + return send_ctl_request_cooked(fd, REQ_DUMP_SUBNETS, NULL, 0) != -1; + } + + if(!strcasecmp(argv[optind+1], "connections")) { + return send_ctl_request_cooked(fd, REQ_DUMP_CONNECTIONS, NULL, 0) != -1; + } + + if(!strcasecmp(argv[optind+1], "graph")) { + return send_ctl_request_cooked(fd, REQ_DUMP_GRAPH, NULL, 0) != -1; + } + + fprintf(stderr, _("Unknown dump type '%s'.\n"), argv[optind+1]); + usage(true); + 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]); usage(true);