Only do this when it becomes unreachable. This fixes an issue where right
after a meta-connection is established, the initiator sends a proactive
REQ_KEY, before the peer really becomes reachable according to the graph.
When the latter happened, it would reset the session so far, causing a new
REQ_KEY to be sent, which could cross the ANS_KEY from the peer. This would
resolve itself after a few seconds, but causes an unnecessary delay that is
easy to trigger.
/* TODO: only clear status.validkey if node is unreachable? */
- n->status.validkey = false;
- sptps_stop(&n->sptps);
- n->status.waitingforkey = false;
- n->last_req_key = -3600;
+ if(!n->status.reachable) {
+ logger(mesh, MESHLINK_DEBUG, "Resetting validkey/waitingforkey for %s, reachable %d", n->name, n->status.reachable);
+ n->status.validkey = false;
+ sptps_stop(&n->sptps);
+ n->status.waitingforkey = false;
+ n->last_req_key = -3600;
+ }
n->status.udp_confirmed = false;
n->maxmtu = MTU;