Double-quote node names in dump graph output.
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 30 Nov 2018 13:41:55 +0000 (14:41 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 30 Nov 2018 13:41:55 +0000 (14:41 +0100)
This is needed for all nodes with a name starting with a digit,
otherwise the ID would be interpreted as a numeral.

Based on the patch from Quentin Rameau for tinc 1.0.

src/tincctl.c

index a09ac98522d67ef31cea7753651cecd16ff86144..08f3018944b22587651c695131f31f9bfee8fcce 100644 (file)
@@ -1352,7 +1352,7 @@ static int cmd_dump(int argc, char *argv[]) {
                                        color = "green";
                                }
 
-                               printf(" %s [label = \"%s\", color = \"%s\"%s];\n", node, node, color, strcmp(host, "MYSELF") ? "" : ", style = \"filled\"");
+                               printf(" \"%s\" [label = \"%s\", color = \"%s\"%s];\n", node, node, color, strcmp(host, "MYSELF") ? "" : ", style = \"filled\"");
                        } else {
                                if(only_reachable && !status.reachable) {
                                        continue;
@@ -1382,9 +1382,9 @@ static int cmd_dump(int argc, char *argv[]) {
                                float w = 1 + 65536.0 / weight;
 
                                if(do_graph == 1 && strcmp(node1, node2) > 0) {
-                                       printf(" %s -- %s [w = %f, weight = %f];\n", node1, node2, w, w);
+                                       printf(" \"%s\" -- \"%s\" [w = %f, weight = %f];\n", node1, node2, w, w);
                                } else if(do_graph == 2) {
-                                       printf(" %s -> %s [w = %f, weight = %f];\n", node1, node2, w, w);
+                                       printf(" \"%s\" -> \"%s\" [w = %f, weight = %f];\n", node1, node2, w, w);
                                }
                        } else {
                                printf("%s to %s at %s port %s local %s port %s options %x weight %d\n", from, to, host, port, local_host, local_port, options, weight);