X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprotocol_auth.c;h=9cb96b6590aecd6dd47f1af1fb23fc2ca694178c;hb=e4e5a81447142da0fb1291b2d2119ed6981b89e5;hp=82254593e36aa0a5982ad447dae801c5baa76f89;hpb=a021bf25db676353b8ea50740ce343962c3dddb9;p=meshlink diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 82254593..9cb96b65 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -36,7 +36,9 @@ #include "utils.h" #include "xalloc.h" #include "ed25519/sha512.h" - + +#include + extern bool node_write_devclass(meshlink_handle_t *mesh, node_t *n); static bool send_proxyrequest(meshlink_handle_t *mesh, connection_t *c) { @@ -327,11 +329,20 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { logger(mesh, MESHLINK_ERROR, "Peer %s had unknown identity (%s)", c->hostname, c->name); return false; } + } - read_ecdsa_public_key(mesh, c); - } else { - if(c->protocol_minor && !ecdsa_active(c->ecdsa)) - c->protocol_minor = 1; + read_ecdsa_public_key(mesh, c); + + if(!ecdsa_active(c->ecdsa)) { + logger(mesh, MESHLINK_ERROR, "No key known for peer %s (%s)", c->name, c->hostname); + + node_t *n = lookup_node(mesh, c->name); + if(n && !n->status.waitingforkey) { + logger(mesh, MESHLINK_INFO, "Requesting key from peer %s (%s)", c->name, c->hostname); + send_req_key(mesh, n); + } + + return false; } /* Forbid version rollback for nodes whose ECDSA key we know */ @@ -444,6 +455,8 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { /* Create an edge_t for this connection */ + assert(devclass >= 0 && devclass <= _DEV_CLASS_MAX); + c->edge = new_edge(); c->edge->from = mesh->self; c->edge->to = n;