+ case ANS_PUBKEY: {
+ if(node_read_public_key(mesh, from)) {
+ logger(mesh, MESHLINK_WARNING, "Got ANS_PUBKEY from %s even though we already have his pubkey", from->name);
+ return true;
+ }
+
+ char pubkey[MAX_STRING_SIZE];
+
+ if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, pubkey) != 1 || !(from->ecdsa = ecdsa_set_base64_public_key(pubkey))) {
+ logger(mesh, MESHLINK_ERROR, "Got bad %s from %s: %s", "ANS_PUBKEY", from->name, "invalid pubkey");
+ return true;
+ }
+
+ logger(mesh, MESHLINK_INFO, "Learned ECDSA public key from %s", from->name);
+ from->status.dirty = true;
+
+ if(!node_write_config(mesh, from, true)) {
+ // ignore
+ }
+
+ /* If we are trying to form an outgoing connection to this node, retry immediately */
+ for list_each(outgoing_t, outgoing, mesh->outgoings) {
+ if(outgoing->node == from && outgoing->ev.cb) {
+ outgoing->timeout = 0;
+ timeout_set(&mesh->loop, &outgoing->ev, &(struct timespec) {
+ 0, 0
+ });
+ }
+ }
+
+ /* Also reset any UTCP timers */
+ utcp_reset_timers(from->utcp);