]> git.meshlink.io Git - meshlink/blobdiff - src/net_setup.c
Move pinginterval pingtimeout and maxtimeout to mesh
[meshlink] / src / net_setup.c
index c5632339889edc6bfb185bfce650d2be125e9816..e168f6acd4d8a7416378ea0d962821ed730d2060 100644 (file)
 
 #include "system.h"
 
-#include "cipher.h"
 #include "conf.h"
 #include "connection.h"
-#include "digest.h"
 #include "ecdsa.h"
 #include "graph.h"
 #include "logger.h"
@@ -108,9 +106,9 @@ static bool read_invitation_key(void) {
        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);
@@ -118,14 +116,14 @@ static bool read_invitation_key(void) {
        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) {
@@ -178,7 +176,7 @@ char *get_name(void) {
 bool setup_myself_reloadable(void) {
        mesh->localdiscovery = true;
        keylifetime = 3600; // TODO: check if this can be removed as well
-       maxtimeout = 900;
+       mesh->maxtimeout = 900;
        autoconnect = 3;
        mesh->self->options |= OPTION_PMTU_DISCOVERY;
 
@@ -251,7 +249,7 @@ static bool add_listen_address(char *address, bool bindto) {
                io_add(&mesh->listen_socket[mesh->listen_sockets].tcp, handle_new_meta_connection, &mesh->listen_socket[mesh->listen_sockets], tcp_fd, IO_READ);
                io_add(&mesh->listen_socket[mesh->listen_sockets].udp, handle_incoming_vpn_data, &mesh->listen_socket[mesh->listen_sockets], udp_fd, IO_READ);
 
-               if(debug_level >= DEBUG_CONNECTIONS) {
+               if(mesh->debug_level >= DEBUG_CONNECTIONS) {
                        char *hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr);
                        logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Listening on %s", hostname);
                        free(hostname);
@@ -372,8 +370,8 @@ bool setup_network(void) {
        init_edges();
        init_requests();
 
-       pinginterval = 60;
-       pingtimeout = 5;
+       mesh->pinginterval = 60;
+       mesh->pingtimeout = 5;
        maxoutbufsize = 10 * MTU;
 
        if(!setup_myself())