Also renew SPTPS keys for meta-connections.
authorGuus Sliepen <guus@meshlink.io>
Sat, 11 Apr 2020 15:25:53 +0000 (17:25 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sat, 11 Apr 2020 15:25:53 +0000 (17:25 +0200)
src/connection.h
src/net.c
src/protocol_auth.c

index 25e122d..5160422 100644 (file)
@@ -67,6 +67,7 @@ typedef struct connection_t {
        int tcplen;                     /* length of incoming TCPpacket */
        int allow_request;              /* defined if there's only one request possible */
        time_t last_ping_time;          /* last time we saw some activity from the other end or pinged them */
+       time_t last_key_renewal;        /* last time we renewed the SPTPS key */
 
        struct outgoing_t *outgoing;    /* used to keep track of outgoing connections */
 
index d80df2f..2ee8aee 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -123,6 +123,16 @@ static void timeout_handler(event_loop_t *loop, void *data) {
                        }
                }
 
+               if(c->status.active && c->last_key_renewal + 3600 < mesh->loop.now.tv_sec) {
+                       if(!sptps_force_kex(&c->sptps)) {
+                               logger(mesh, MESHLINK_ERROR, "SPTPS key renewal for connection with %s failed", c->name);
+                               terminate_connection(mesh, c, true);
+                               continue;
+                       } else {
+                               c->last_key_renewal = mesh->loop.now.tv_sec;
+                       }
+               }
+
                if(c->last_ping_time + pingtimeout <= mesh->loop.now.tv_sec) {
                        if(c->status.active) {
                                if(c->status.pinged) {
index 5632c5a..c17d9e8 100644 (file)
@@ -365,6 +365,7 @@ bool ack_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        /* Activate this connection */
 
        c->allow_request = ALL;
+       c->last_key_renewal = mesh->loop.now.tv_sec;
        c->status.active = true;
 
        logger(mesh, MESHLINK_INFO, "Connection with %s activated", c->name);