X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finfo.c;h=ee60a3fe4671c4f2aa9b5f0dd1287b22c9e18ed2;hb=9ade39b7d5564fb6f5a41946c9a23cfa7851a19f;hp=eb0d395aac978350632ceaa88ea3f176e648eae6;hpb=248d300f1be0d5f2aae39202041699ab2b46c56b;p=tinc diff --git a/src/info.c b/src/info.c index eb0d395a..ee60a3fe 100644 --- a/src/info.c +++ b/src/info.c @@ -33,7 +33,7 @@ void logger(int level, int priority, const char *format, ...) { va_end(ap); } -static char *strip_weight(char *netstr) { +char *strip_weight(char *netstr) { int len = strlen(netstr); if(len >= 3 && !strcmp(netstr + len - 3, "#10")) netstr[len - 3] = 0; @@ -59,18 +59,19 @@ 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 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) %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) { + if(n != 18) { *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); + 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) %ld", &code, &req, node, host, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change); - if(n != 16) { + if(n != 17) { fprintf(stderr, "Unable to parse node dump from tincd.\n"); return 1; } @@ -95,6 +96,16 @@ static int info_node(int fd, const char *item) { printf("Node: %s\n", item); if(*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"); @@ -104,7 +115,10 @@ static int info_node(int fd, const char *item) { printf(" reachable"); if(status.indirect) printf(" indirect"); + if(status.sptps) + printf(" sptps"); printf("\n"); + printf("Options: "); if(options & OPTION_INDIRECT) printf(" indirect"); @@ -117,7 +131,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");