-int del_edge_h(connection_t *c)
-{
- edge_t *e;
- char from_name[MAX_STRING_SIZE];
- char to_name[MAX_STRING_SIZE];
- node_t *from, *to;
- cp();
- if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING"", from_name, to_name) != 2)
- {
- syslog(LOG_ERR, _("Got bad %s from %s (%s)"), "DEL_EDGE",
- c->name, c->hostname);
- return -1;
- }
-
- /* Check if names are valid */
-
- if(check_id(from_name))
- {
- syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "DEL_EDGE", c->name, c->hostname, _("invalid name"));
- return -1;
- }
-
- if(check_id(to_name))
- {
- syslog(LOG_ERR, _("Got bad %s from %s (%s): %s"), "DEL_EDGE", c->name, c->hostname, _("invalid name"));
- return -1;
- }
-
- if(seen_request(c->buffer))
- return 0;
-
- /* Lookup nodes */
-
- from = lookup_node(from_name);
-
- if(!from)
- {
- if(debug_lvl >= DEBUG_PROTOCOL)
- syslog(LOG_ERR, _("Got %s from %s (%s) which does not appear in the edge tree"), "DEL_EDGE", c->name, c->hostname);
- return 0;
- }
-
- to = lookup_node(to_name);
-
- if(!to)
- {
- if(debug_lvl >= DEBUG_PROTOCOL)
- syslog(LOG_ERR, _("Got %s from %s (%s) which does not appear in the edge tree"), "DEL_EDGE", c->name, c->hostname);
- return 0;
- }
-
- /* Check if edge exists */
-
- e = lookup_edge(from, to);
-
- if(!e)
- {
- if(debug_lvl >= DEBUG_PROTOCOL)
- syslog(LOG_WARNING, _("Got %s from %s (%s) which does not appear in the edge tree"), "DEL_EDGE", c->name, c->hostname);
- return 0;
- }
-
- if(e->from == myself)
- {
- if(debug_lvl >= DEBUG_PROTOCOL)
- syslog(LOG_WARNING, _("Got %s from %s (%s) for ourself"), "DEL_EDGE", c->name, c->hostname);
- send_add_edge(c, e); /* Send back a correction */
- return 0;
- }
-
- /* Tell the rest about the deleted edge */
-
- forward_request(c);
-
- /* Delete the edge */
-
- edge_del(e);
-
- /* Run MST before or after we tell the rest? */
-
- graph();
- cp();
- return 0;
+bool del_edge_h(connection_t *c, const char *request) {
+ edge_t *e;
+ char from_name[MAX_STRING_SIZE];
+ char to_name[MAX_STRING_SIZE];
+ node_t *from, *to;
+
+ if(sscanf(request, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "DEL_EDGE", c->name,
+ c->hostname);
+ return false;
+ }
+
+ /* Check if names are valid */
+
+ if(!check_id(from_name) || !check_id(to_name)) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name,
+ c->hostname, "invalid name");
+ return false;
+ }
+
+ if(seen_request(request))
+ return true;
+
+ /* Lookup nodes */
+
+ from = lookup_node(from_name);
+ to = lookup_node(to_name);
+
+ if(tunnelserver &&
+ from != myself && from != c->node &&
+ to != myself && to != c->node) {
+ /* ignore indirect edge registrations for tunnelserver */
+ logger(DEBUG_PROTOCOL, LOG_WARNING,
+ "Ignoring indirect %s from %s (%s)",
+ "DEL_EDGE", c->name, c->hostname);
+ return true;
+ }
+
+ if(!from) {
+ logger(DEBUG_PROTOCOL, LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree",
+ "DEL_EDGE", c->name, c->hostname);
+ return true;
+ }
+
+ if(!to) {
+ logger(DEBUG_PROTOCOL, LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree",
+ "DEL_EDGE", c->name, c->hostname);
+ return true;
+ }
+
+ /* Check if edge exists */
+
+ e = lookup_edge(from, to);
+
+ if(!e) {
+ logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) which does not appear in the edge tree",
+ "DEL_EDGE", c->name, c->hostname);
+ return true;
+ }
+
+ if(e->from == myself) {
+ logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself",
+ "DEL_EDGE", c->name, c->hostname);
+ contradicting_del_edge++;
+ send_add_edge(c, e); /* Send back a correction */
+ return true;
+ }
+
+ /* Tell the rest about the deleted edge */
+
+ if(!tunnelserver)
+ forward_request(c, request);
+
+ /* Delete the edge */
+
+ edge_del(e);
+
+ /* Run MST before or after we tell the rest? */
+
+ graph();
+
+ /* If the node is not reachable anymore but we remember it had an edge to us, clean it up */
+
+ if(!to->status.reachable) {
+ e = lookup_edge(to, myself);
+ if(e) {
+ if(!tunnelserver)
+ send_del_edge(everyone, e);
+ edge_del(e);
+ }
+ }
+
+ return true;