X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;ds=sidebyside;f=src%2Fcontrol.c;h=b8e5204b9db0a58d6e1b2e2fbe1bd1f6d82a01f8;hb=55ef2f806f9840103bceb472564a711b22e73d58;hp=e3901a6da8e496a36c85f58eb67beb4f9a8c13dd;hpb=f12c36afd5293ddbecccf13f36edb8d36e56f040;p=tinc diff --git a/src/control.c b/src/control.c index e3901a6d..b8e5204b 100644 --- a/src/control.c +++ b/src/control.c @@ -92,6 +92,27 @@ bool control_h(connection_t *c, char *request) { int result = reload_configuration(); return control_return(c, REQ_RELOAD, result); + case REQ_DISCONNECT: { + char name[MAX_STRING_SIZE]; + connection_t *other; + splay_node_t *node, *next; + bool found = false; + + if(sscanf(request, "%*d %*d " MAX_STRING, name) != 1) + return control_return(c, REQ_DISCONNECT, -1); + + for(node = connection_tree->head; node; node = next) { + next = node->next; + other = node->data; + if(strcmp(other->name, name)) + continue; + terminate_connection(other, other->status.active); + found = true; + } + + return control_return(c, REQ_DISCONNECT, found ? 0 : -2); + } + default: return send_request(c, "%d %d", CONTROL, REQ_INVALID); }