X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finfo.c;h=93be24e4eaacbe6e938e783fb4a5181b8260be25;hb=d6388d782ede1bbe49a5c2643362e2e0f383fa89;hp=18b8e24ac997740a43578e1bb05f666a04fbcad9;hpb=36c6afede36b6956bd86df824f5616c1afee35ed;p=tinc diff --git a/src/info.c b/src/info.c index 18b8e24a..93be24e4 100644 --- a/src/info.c +++ b/src/info.c @@ -59,21 +59,17 @@ static int info_node(int fd, const char *item) { short int pmtu, minmtu, maxmtu; unsigned int options; node_status_t status; + long int last_state_change; while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s at %s port %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %hd (min %hd max %hd)", &code, &req, node, host, port, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu); + int n = sscanf(line, "%d %d %s %s port %s %d %d %d %d %x %x %s %s %d %hd %hd %hd %ld", &code, &req, node, host, port, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change); if(n == 2) break; - if(n != 17) { - *port = 0; - n = sscanf(line, "%d %d %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %hd (min %hd max %hd)", &code, &req, node, host, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu); - - if(n != 16) { - fprintf(stderr, "Unable to parse node dump from tincd.\n"); - return 1; - } + if(n != 18) { + fprintf(stderr, "Unable to parse node dump from tincd.\n"); + return 1; } if(!strcmp(node, item)) { @@ -93,8 +89,17 @@ static int info_node(int fd, const char *item) { } printf("Node: %s\n", item); - if(*port) - printf("Address: %s port %s\n", host, port); + printf("Address: %s port %s\n", host, port); + + char timestr[32] = "never"; + if(last_state_change) + strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&last_state_change)); + + if(status.reachable) + printf("Online since: %s\n", timestr); + else + printf("Last seen: %s\n", timestr); + printf("Status: "); if(status.validkey) printf(" validkey"); @@ -107,6 +112,7 @@ static int info_node(int fd, const char *item) { if(status.sptps) printf(" sptps"); printf("\n"); + printf("Options: "); if(options & OPTION_INDIRECT) printf(" indirect"); @@ -119,7 +125,7 @@ static int info_node(int fd, const char *item) { printf("\n"); printf("Protocol: %d.%d\n", PROT_MAJOR, OPTION_VERSION(options)); printf("Reachability: "); - if(!*port) + if(!strcmp(host, "MYSELF")) printf("can reach itself\n"); else if(!status.reachable) printf("unreachable\n"); @@ -138,7 +144,7 @@ static int info_node(int fd, const char *item) { printf("Edges: "); sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_EDGES, item); while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s to %s", &code, &req, from, to); + int n = sscanf(line, "%d %d %s %s", &code, &req, from, to); if(n == 2) break; if(n != 4) { @@ -154,7 +160,7 @@ static int info_node(int fd, const char *item) { printf("Subnets: "); sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_SUBNETS, item); while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s owner %s", &code, &req, subnet, from); + int n = sscanf(line, "%d %d %s %s", &code, &req, subnet, from); if(n == 2) break; if(n != 4) { @@ -189,7 +195,7 @@ static int info_subnet(int fd, const char *item) { sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_SUBNETS, item); while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s owner %s", &code, &req, netstr, owner); + int n = sscanf(line, "%d %d %s %s", &code, &req, netstr, owner); if(n == 2) break;