]> git.meshlink.io Git - meshlink/commitdiff
Renew SPTPS keys every hour.
authorGuus Sliepen <guus@meshlink.io>
Sun, 29 Mar 2020 22:24:30 +0000 (00:24 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 29 Mar 2020 22:24:30 +0000 (00:24 +0200)
We did do this in the past, but in some commit we stopped automatically
renewing keys every hour.

src/net.c

index 3c1ad3e625ee7b237fb590243719693f41a73297..020ffd4f75de85855620a169349216b9b6cf8efe 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -29,6 +29,7 @@
 #include "net.h"
 #include "netutl.h"
 #include "protocol.h"
 #include "net.h"
 #include "netutl.h"
 #include "protocol.h"
+#include "sptps.h"
 #include "xalloc.h"
 
 #include <assert.h>
 #include "xalloc.h"
 
 #include <assert.h>
@@ -615,6 +616,18 @@ static void periodic_handler(event_loop_t *loop, void *data) {
 
                        n->status.dirty = false;
                }
 
                        n->status.dirty = false;
                }
+
+               if(n->status.validkey && n->last_req_key + 3600 < mesh->loop.now.tv_sec) {
+                       logger(mesh, MESHLINK_DEBUG, "SPTPS key renewal for node %s", n->name);
+
+                       if(!sptps_force_kex(&n->sptps)) {
+                               logger(mesh, MESHLINK_ERROR, "SPTPS key renewal for node %s failed", n->name);
+                               n->status.validkey = false;
+                               sptps_stop(&n->sptps);
+                               n->status.waitingforkey = false;
+                               n->last_req_key = 0;
+                       }
+               }
        }
 
        timeout_set(&mesh->loop, data, &(struct timespec) {
        }
 
        timeout_set(&mesh->loop, data, &(struct timespec) {