X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprotocol_auth.c;h=107280c153898cd7c12520ac00256b631d76e7d9;hb=cf3f161b0cbe847a484ea2c4fb215b963acbb805;hp=a990caffdc3548fd82628a4851db6327d19bc4aa;hpb=4ea5d218c5c8e5739071bc6e57cf8404db5323ef;p=meshlink diff --git a/src/protocol_auth.c b/src/protocol_auth.c index a990caff..107280c1 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -21,9 +21,6 @@ #include "conf.h" #include "connection.h" -#include "cipher.h" -#include "crypto.h" -#include "digest.h" #include "ecdsa.h" #include "edge.h" #include "graph.h" @@ -40,8 +37,6 @@ #include "xalloc.h" #include "ed25519/sha512.h" -ecdsa_t *invitation_key = NULL; - static bool send_proxyrequest(connection_t *c) { switch(mesh->proxytype) { case PROXY_HTTP: { @@ -184,7 +179,7 @@ static bool receive_invitation_sptps(void *handle, uint8_t type, const char *dat return false; // Recover the filename from the cookie and the key - char *fingerprint = ecdsa_get_base64_public_key(invitation_key); + char *fingerprint = ecdsa_get_base64_public_key(mesh->invitation_key); char hash[64]; char hashbuf[18 + strlen(fingerprint)]; char cookie[25]; @@ -265,7 +260,7 @@ bool id_h(connection_t *c, const char *request) { /* Check if this is an invitation */ if(name[0] == '?') { - if(!invitation_key) { + if(!mesh->invitation_key) { logger(DEBUG_ALWAYS, LOG_ERR, "Got invitation from %s but we don't have an invitation key", c->hostname); return false; } @@ -277,7 +272,7 @@ bool id_h(connection_t *c, const char *request) { } c->status.invitation = true; - char *mykey = ecdsa_get_base64_public_key(invitation_key); + char *mykey = ecdsa_get_base64_public_key(mesh->invitation_key); if(!mykey) return false; if(!send_request(c, "%d %s", ACK, mykey)) @@ -286,7 +281,7 @@ bool id_h(connection_t *c, const char *request) { c->protocol_minor = 2; - return sptps_start(&c->sptps, c, false, false, invitation_key, c->ecdsa, "tinc invitation", 15, send_meta_sptps, receive_invitation_sptps); + return sptps_start(&c->sptps, c, false, false, mesh->invitation_key, c->ecdsa, "tinc invitation", 15, send_meta_sptps, receive_invitation_sptps); } /* Check if identity is a valid name */ @@ -319,22 +314,15 @@ bool id_h(connection_t *c, const char *request) { return false; } - if(bypass_security) { - if(!c->config_tree) - init_configuration(&c->config_tree); - c->allow_request = ACK; - return send_ack(c); - } - if(!c->config_tree) { init_configuration(&c->config_tree); - if(!read_host_config(c->config_tree, c->name)) { + if(!read_host_config(mesh, c->config_tree, c->name)) { logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, c->name); return false; } - read_ecdsa_public_key(c); + read_ecdsa_public_key(mesh, c); } else { if(c->protocol_minor && !ecdsa_active(c->ecdsa)) c->protocol_minor = 1; @@ -466,7 +454,7 @@ bool ack_h(connection_t *c, const char *request) { /* Notify everyone of the new edge */ - send_add_edge(everyone, c->edge); + send_add_edge(mesh->everyone, c->edge); /* Run MST and SSSP algorithms */