]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_auth.c
Remove support for UNIX signals in the event library.
[meshlink] / src / protocol_auth.c
index be4d2ea084688525e34134ec5204343c56fbfe16..9bd5ffca6dc007652af6a4b35e8d69f3247c2af0 100644 (file)
@@ -135,7 +135,7 @@ bool send_id(meshlink_handle_t *mesh, connection_t *c) {
        return send_request(mesh, c, "%d %s %d.%d", ID, mesh->self->connection->name, mesh->self->connection->protocol_major, minor);
 }
 
-static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const char *data, uint16_t len) {
+static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const void *data, uint16_t len) {
        if(strchr(data, '\n')) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname);
                return false;
@@ -155,7 +155,7 @@ static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const
                return false;
        }
 
-       fprintf(f, "ECDSAPublicKey = %s\n", data);
+       fprintf(f, "ECDSAPublicKey = %s\n", (const char *)data);
        fclose(f);
 
        logger(DEBUG_CONNECTIONS, LOG_INFO, "Key succesfully received from %s (%s)", c->name, c->hostname);
@@ -163,10 +163,13 @@ static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const
        //TODO: callback to application to inform of an accepted invitation
 
        sptps_send_record(&c->sptps, 2, data, 0);
+
+       load_all_nodes(mesh);
+
        return true;
 }
 
-static bool receive_invitation_sptps(void *handle, uint8_t type, const char *data, uint16_t len) {
+static bool receive_invitation_sptps(void *handle, uint8_t type, const void *data, uint16_t len) {
        connection_t *c = handle;
        meshlink_handle_t *mesh = c->mesh;
 
@@ -281,8 +284,9 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
                free(mykey);
 
                c->protocol_minor = 2;
+               c->allow_request = 1;
 
-               return sptps_start(&c->sptps, c, false, false, mesh->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, "meshlink invitation", 15, send_meta_sptps, receive_invitation_sptps);
        }
 
        /* Check if identity is a valid name */
@@ -341,9 +345,9 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        char label[25 + strlen(mesh->self->name) + strlen(c->name)];
 
        if(c->outgoing)
-               snprintf(label, sizeof label, "tinc TCP key expansion %s %s", mesh->self->name, c->name);
+               snprintf(label, sizeof label, "meshlink TCP key expansion %s %s", mesh->self->name, c->name);
        else
-               snprintf(label, sizeof label, "tinc TCP key expansion %s %s", c->name, mesh->self->name);
+               snprintf(label, sizeof label, "meshlink TCP key expansion %s %s", c->name, mesh->self->name);
 
        return sptps_start(&c->sptps, c, c->outgoing, false, mesh->self->connection->ecdsa, c->ecdsa, label, sizeof label, send_meta_sptps, receive_meta_sptps);
 }
@@ -353,7 +357,6 @@ bool send_ack(meshlink_handle_t *mesh, connection_t *c) {
           to create node_t and edge_t structures. */
 
        struct timeval now;
-       bool choice;
 
        /* Estimate weight */
 
@@ -380,10 +383,9 @@ static void send_everything(meshlink_handle_t *mesh, connection_t *c) {
 bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        char hisport[MAX_STRING_SIZE];
        char *hisaddress;
-       int weight, mtu;
+       int weight;
        uint32_t options;
        node_t *n;
-       bool choice;
 
        if(sscanf(request, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name,