]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_auth.c
Move the routing header out of the SPTPS payload.
[meshlink] / src / protocol_auth.c
index 4ba3ebe4282dc1742942b2944a31309a233559da..6227e45596a72331f44194995e89a1fff2275e94 100644 (file)
@@ -37,8 +37,6 @@
 #include "xalloc.h"
 #include "ed25519/sha512.h"
 
-#include <assert.h>
-
 extern bool node_write_devclass(meshlink_handle_t *mesh, node_t *n);
 
 static bool send_proxyrequest(meshlink_handle_t *mesh, connection_t *c) {
@@ -151,7 +149,7 @@ bool send_id(meshlink_handle_t *mesh, connection_t *c) {
                        return false;
                }
 
-       return send_request(mesh, c, "%d %s %d.%d", ID, mesh->self->connection->name, mesh->self->connection->protocol_major, minor);
+       return send_request(mesh, c, "%d %s %d.%d %s", ID, mesh->self->connection->name, mesh->self->connection->protocol_major, minor, mesh->appname);
 }
 
 static bool finalize_invitation(meshlink_handle_t *mesh, connection_t *c, const void *data, uint16_t len) {
@@ -342,8 +340,8 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
 
                free(mykey);
 
-               c->protocol_minor = 2;
-               c->allow_request = 1;
+               c->protocol_minor = PROT_MINOR;
+               c->allow_request = LAST;
 
                return sptps_start(&c->sptps, c, false, false, mesh->invitation_key, c->ecdsa, meshlink_invitation_label, sizeof(meshlink_invitation_label), send_meta_sptps, receive_invitation_sptps);
        }
@@ -387,6 +385,14 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
                }
        }
 
+       bool blacklisted = false;
+       get_config_bool(lookup_config(c->config_tree, "blacklisted"), &blacklisted);
+
+       if(blacklisted) {
+               logger(mesh, MESHLINK_EPEER, "Peer %s is blacklisted", c->name);
+               return false;
+       }
+
        read_ecdsa_public_key(mesh, c);
 
        if(!ecdsa_active(c->ecdsa)) {
@@ -402,14 +408,6 @@ bool id_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
                return false;
        }
 
-       /* Forbid version rollback for nodes whose ECDSA key we know */
-
-       if(ecdsa_active(c->ecdsa) && c->protocol_minor < 2) {
-               logger(mesh, MESHLINK_ERROR, "Peer %s tries to roll back protocol version to %d.%d",
-                      c->name, c->protocol_major, c->protocol_minor);
-               return false;
-       }
-
        c->allow_request = ACK;
        char label[sizeof(meshlink_tcp_label) + strlen(mesh->self->name) + strlen(c->name) + 2];
 
@@ -438,7 +436,7 @@ static void send_everything(meshlink_handle_t *mesh, connection_t *c) {
 
        for splay_each(node_t, n, mesh->nodes) {
                for splay_each(edge_t, e, n->edge_tree) {
-                       send_add_edge(mesh, c, e);
+                       send_add_edge(mesh, c, e, 0);
                }
        }
 }
@@ -533,7 +531,7 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
 
        /* Notify everyone of the new edge */
 
-       send_add_edge(mesh, mesh->everyone, c->edge);
+       send_add_edge(mesh, mesh->everyone, c->edge, 0);
 
        /* Run MST and SSSP algorithms */