#include "utils.h"
#include "xalloc.h"
-connection_t *everyone;
-
void init_connections(void) {
mesh->connections = list_alloc((list_action_t) free_connection);
- everyone = new_connection();
- everyone->name = xstrdup("everyone");
- everyone->hostname = xstrdup("BROADCAST");
+ mesh->everyone = new_connection();
+ mesh->everyone->name = xstrdup("mesh->everyone");
+ mesh->everyone->hostname = xstrdup("BROADCAST");
}
void exit_connections(void) {
list_delete_list(mesh->connections);
- free_connection(everyone);
+ free_connection(mesh->everyone);
}
connection_t *new_connection(void) {
splay_tree_t *config_tree; /* Pointer to configuration tree belonging to him */
} connection_t;
-extern connection_t *everyone;
-
extern void init_connections(void);
extern void exit_connections(void);
extern connection_t *new_connection(void) __attribute__ ((__malloc__));
#include "system.h"
#include "event.h"
+#include "hash.h"
#include "meshlink.h"
#include "sockaddr.h"
bool localdiscovery;
sockaddr_t localdiscovery_address;
+
+ hash_t *node_udp_cache;
+ struct connection_t *everyone;
+ struct ecdsa *invitation_key;
};
/// A handle for a MeshLink node.
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Purging node %s (%s)", n->name, n->hostname);
for splay_each(edge_t, e, n->edge_tree) {
- send_del_edge(everyone, e);
+ send_del_edge(mesh->everyone, e);
edge_del(e);
}
}
if(c->edge) {
if(report)
- send_del_edge(everyone, c->edge);
+ send_del_edge(mesh->everyone, c->edge);
edge_del(c->edge);
c->edge = NULL;
edge_t *e;
e = lookup_edge(c->node, mesh->self);
if(e) {
- send_del_edge(everyone, e);
+ send_del_edge(mesh->everyone, e);
edge_del(e);
}
}
FILE *fp;
char *fname;
- if(invitation_key) {
- ecdsa_free(invitation_key);
- invitation_key = NULL;
+ if(mesh->invitation_key) {
+ ecdsa_free(mesh->invitation_key);
+ mesh->invitation_key = NULL;
}
xasprintf(&fname, "%s" SLASH "invitations" SLASH "ecdsa_key.priv", mesh->confbase);
fp = fopen(fname, "r");
if(fp) {
- invitation_key = ecdsa_read_pem_private_key(fp);
+ mesh->invitation_key = ecdsa_read_pem_private_key(fp);
fclose(fp);
- if(!invitation_key)
+ if(!mesh->invitation_key)
logger(DEBUG_ALWAYS, LOG_ERR, "Reading ECDSA private key file `%s' failed: %s", fname, strerror(errno));
}
free(fname);
- return invitation_key;
+ return mesh->invitation_key;
}
void load_all_nodes(void) {
request[len++] = '\n';
- if(c == everyone) {
+ if(c == mesh->everyone) {
broadcast_meta(NULL, request, len);
return true;
} else
time_t firstseen;
} past_request_t;
-extern ecdsa_t *invitation_key;
-
/* Maximum size of strings in a request.
* scanf terminates %2048s with a NUL character,
* but the NUL character can be written after the 2048th non-NUL character.
#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: {
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];
/* 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;
}
}
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))
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 */
/* Notify everyone of the new edge */
- send_add_edge(everyone, c->edge);
+ send_add_edge(mesh->everyone, c->edge);
/* Run MST and SSSP algorithms */
if(!to->status.reachable) {
e = lookup_edge(to, mesh->self);
if(e) {
- send_del_edge(everyone, e);
+ send_del_edge(mesh->everyone, e);
edge_del(e);
}
}
static bool mykeyused = false;
void send_key_changed(void) {
- send_request(everyone, "%d %x %s", KEY_CHANGED, rand(), mesh->self->name);
+ send_request(mesh->everyone, "%d %x %s", KEY_CHANGED, rand(), mesh->self->name);
/* Force key exchange for connections using SPTPS */