X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finfo.c;h=df5d11d18fff969d877f3934260dd3df12b1663f;hb=76a3ada4eb4032172c3d780915a07680f9954d42;hp=d0764da2303ffe61ebcc32f5037c878f56d05c04;hpb=53735a9d964579829d089f4b7572aef50c4e1468;p=tinc diff --git a/src/info.c b/src/info.c index d0764da2..df5d11d1 100644 --- a/src/info.c +++ b/src/info.c @@ -33,6 +33,13 @@ void logger(int level, int priority, const char *format, ...) { va_end(ap); } +static char *strip_weight(char *netstr) { + int len = strlen(netstr); + if(len >= 3 && !strcmp(netstr + len - 3, "#10")) + netstr[len - 3] = 0; + return netstr; +} + static int info_node(int fd, const char *item) { // Check the list of nodes sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_NODES, item); @@ -110,6 +117,7 @@ static int info_node(int fd, const char *item) { if(options & OPTION_CLAMP_MSS) printf(" clamp_mss"); printf("\n"); + printf("Protocol: %d.%d\n", PROT_MAJOR, OPTION_VERSION(options)); printf("Reachability: "); if(!*port) printf("can reach itself\n"); @@ -154,7 +162,7 @@ static int info_node(int fd, const char *item) { return 1; } if(!strcmp(from, item)) - printf(" %s", subnet); + printf(" %s", strip_weight(subnet)); } printf("\n"); @@ -164,8 +172,10 @@ static int info_node(int fd, const char *item) { static int info_subnet(int fd, const char *item) { subnet_t subnet, find; - if(!str2net(&find, item)) + if(!str2net(&find, item)) { + fprintf(stderr, "Could not parse subnet or address '%s'.\n", item); return 1; + } bool address = !strchr(item, '/'); bool weight = strchr(item, '#'); @@ -222,7 +232,7 @@ static int info_subnet(int fd, const char *item) { } found = true; - printf("Subnet: %s\n", netstr); + printf("Subnet: %s\n", strip_weight(netstr)); printf("Owner: %s\n", owner); }