X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet.c;h=85cbf3d442fd1e60e466ca70351bbddeb1d2a126;hb=af87825c8c8479c576af390adae502b2e5bf6e5f;hp=3c1ad3e625ee7b237fb590243719693f41a73297;hpb=4c57e6902219ecca1872e18e34365d8e54a0f407;p=meshlink diff --git a/src/net.c b/src/net.c index 3c1ad3e6..85cbf3d4 100644 --- a/src/net.c +++ b/src/net.c @@ -29,6 +29,7 @@ #include "net.h" #include "netutl.h" #include "protocol.h" +#include "sptps.h" #include "xalloc.h" #include @@ -615,6 +616,20 @@ static void periodic_handler(event_loop_t *loop, void *data) { 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; + } else { + n->last_req_key = mesh->loop.now.tv_sec; + } + } } timeout_set(&mesh->loop, data, &(struct timespec) {