Use the TCP socket infrastructure for control sockets.

The control socket code was completely different from how meta connections are
handled, resulting in lots of extra code to handle requests.  Also, not every
operating system has UNIX sockets, so we have to resort to another type of
sockets or pipes for those anyway.  To reduce code duplication and make control
sockets work the same on all platforms, we now just connect to the TCP port
where tincd is already listening on.

To authenticate, the program that wants to control a running tinc daemon must
send the contents of a cookie file. The cookie is a random 256 bits number that
is regenerated every time tincd starts. The cookie file should only be readable
by the same user that can start a tincd.

Instead of the binary-ish protocol previously used, we now use an ASCII
protocol similar to that of the meta connections, but this can still change.
This commit is contained in:
Guus Sliepen 2009-11-07 23:43:25 +01:00
parent c388527e34
commit edebf579f2
18 changed files with 294 additions and 552 deletions

View file

@ -382,44 +382,8 @@ void check_reachability() {
}
}
/* Dump nodes and edges to a graphviz file.
The file can be converted to an image with
dot -Tpng graph_filename -o image_filename.png -Gconcentrate=true
*/
int dump_graph(struct evbuffer *out) {
splay_node_t *node;
node_t *n;
edge_t *e;
if(evbuffer_add_printf(out, "digraph {\n") == -1)
return errno;
/* dump all nodes first */
for(node = node_tree->head; node; node = node->next) {
n = node->data;
if(evbuffer_add_printf(out, " %s [label = \"%s\"];\n",
n->name, n->name) == -1)
return errno;
}
/* now dump all edges */
for(node = edge_weight_tree->head; node; node = node->next) {
e = node->data;
if(evbuffer_add_printf(out, " %s -> %s;\n",
e->from->name, e->to->name) == -1)
return errno;
}
if(evbuffer_add_printf(out, "}\n") == -1)
return errno;
return 0;
}
void graph(void) {
subnet_cache_flush();
subnet_cache_flush();
sssp_dijkstra();
check_reachability();
mst_kruskal();