X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=e0a6086e8f89b9b44f3ce9d328656c16206efb8c;hb=58e8f598f38dbb2f210d8a62c8fb4b46513dc39f;hp=0bb35e7108b52ae937219b68eb1e5d8ab12ad01a;hpb=467397f25d3a99ec1a97d4419502c37b64276f49;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 0bb35e71..e0a6086e 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -1,6 +1,6 @@ /* tincctl.c -- Controlling a running tincd - Copyright (C) 2007-2014 Guus Sliepen + Copyright (C) 2007-2015 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -88,7 +88,7 @@ static struct option const long_options[] = { static void version(void) { printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, - VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); + BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); printf("Copyright (C) 1998-2014 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" @@ -134,6 +134,7 @@ static void usage(bool status) { " subnets - all known subnets in the VPN\n" " connections - all meta connections with ourself\n" " [di]graph - graph of the VPN in dotty format\n" + " invitations - outstanding invitations\n" " info NODE|SUBNET|ADDRESS Give information about a particular NODE, SUBNET or ADDRESS.\n" " purge Purge unreachable nodes\n" " debug N Set debug level\n" @@ -150,7 +151,7 @@ static void usage(bool status) { " exchange Same as export followed by import\n" " exchange-all Same as export-all followed by import\n" " invite NODE [...] Generate an invitation for NODE\n" - " join INVITATION Join a VPN using an INVITIATION\n" + " join INVITATION Join a VPN using an INVITATION\n" " network [NETNAME] List all known networks, or switch to the one named NETNAME.\n" " fsck Check the configuration files for problems.\n" "\n"); @@ -943,6 +944,65 @@ static int cmd_reload(int argc, char *argv[]) { } +static int dump_invitations(void) { + char dname[PATH_MAX]; + snprintf(dname, sizeof dname, "%s" SLASH "invitations", confbase); + DIR *dir = opendir(dname); + if(!dir) { + if(errno == ENOENT) { + fprintf(stderr, "No outstanding invitations.\n"); + return 0; + } + + fprintf(stderr, "Cannot not read directory %s: %s\n", dname, strerror(errno)); + return 1; + } + + struct dirent *ent; + bool found = false; + + while((ent = readdir(dir))) { + char buf[MAX_STRING_SIZE]; + if(b64decode(ent->d_name, buf, 24) != 18) + continue; + + char fname[PATH_MAX]; + snprintf(fname, sizeof fname, "%s" SLASH "%s", dname, ent->d_name); + FILE *f = fopen(fname, "r"); + if(!f) { + fprintf(stderr, "Cannot open %s: %s\n", fname, strerror(errno)); + fclose(f); + continue; + } + + buf[0] = 0; + if(!fgets(buf, sizeof buf, f)) { + fprintf(stderr, "Invalid invitation file %s", fname); + fclose(f); + continue; + } + fclose(f); + + char *eol = buf + strlen(buf); + while(strchr("\t \r\n", *--eol)) + *eol = 0; + if(strncmp(buf, "Name = ", 7) || !check_id(buf + 7)) { + fprintf(stderr, "Invalid invitation file %s", fname); + continue; + } + + found = true; + printf("%s %s\n", ent->d_name, buf + 7); + } + + closedir(dir); + + if(!found) + fprintf(stderr, "No outstanding invitations.\n"); + + return 0; +} + static int cmd_dump(int argc, char *argv[]) { bool only_reachable = false; @@ -963,6 +1023,9 @@ static int cmd_dump(int argc, char *argv[]) { return 1; } + if(!strcasecmp(argv[1], "invitations")) + return dump_invitations(); + if(!connect_tincd(true)) return 1; @@ -1371,6 +1434,7 @@ const var_t variables[] = { {"UDPDiscoveryKeepaliveInterval", VAR_SERVER}, {"UDPDiscoveryInterval", VAR_SERVER}, {"UDPDiscoveryTimeout", VAR_SERVER}, + {"MTUInfoInterval", VAR_SERVER}, {"UDPInfoInterval", VAR_SERVER}, {"UDPRcvBuf", VAR_SERVER}, {"UDPSndBuf", VAR_SERVER}, @@ -2226,6 +2290,7 @@ static const struct { {"restart", cmd_restart}, {"reload", cmd_reload}, {"dump", cmd_dump}, + {"list", cmd_dump}, {"purge", cmd_purge}, {"debug", cmd_debug}, {"retry", cmd_retry},