void terminate_connection(meshlink_handle_t *mesh, connection_t *c, bool report) {
logger(mesh, MESHLINK_INFO, "Closing connection with %s", c->name);
void terminate_connection(meshlink_handle_t *mesh, connection_t *c, bool report) {
logger(mesh, MESHLINK_INFO, "Closing connection with %s", c->name);
if(c->edge) {
if(report) {
send_del_edge(mesh, mesh->everyone, c->edge, 0);
if(c->edge) {
if(report) {
send_del_edge(mesh, mesh->everyone, c->edge, 0);
int pingtimeout = c->node ? mesh->dev_class_traits[c->node->devclass].pingtimeout : default_timeout;
int pinginterval = c->node ? mesh->dev_class_traits[c->node->devclass].pinginterval : default_interval;
int pingtimeout = c->node ? mesh->dev_class_traits[c->node->devclass].pingtimeout : default_timeout;
int pinginterval = c->node ? mesh->dev_class_traits[c->node->devclass].pinginterval : default_interval;
send_req_key(mesh, c->node);
}
}
if(c->status.active && c->last_key_renewal + 3600 < mesh->loop.now.tv_sec) {
send_req_key(mesh, c->node);
}
}
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);
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);
if(c->status.active) {
if(c->status.pinged) {
logger(mesh, MESHLINK_INFO, "%s didn't respond to PING in %ld seconds", c->name, (long)mesh->loop.now.tv_sec - c->last_ping_time);
if(c->status.active) {
if(c->status.pinged) {
logger(mesh, MESHLINK_INFO, "%s didn't respond to PING in %ld seconds", c->name, (long)mesh->loop.now.tv_sec - c->last_ping_time);
if(mesh->contradicting_del_edge > 100 && mesh->contradicting_add_edge > 100) {
logger(mesh, MESHLINK_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", mesh->sleeptime);
struct timespec ts = {mesh->sleeptime, 0};
if(mesh->contradicting_del_edge > 100 && mesh->contradicting_add_edge > 100) {
logger(mesh, MESHLINK_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", mesh->sleeptime);
struct timespec ts = {mesh->sleeptime, 0};
logger(mesh, MESHLINK_DEBUG, "SPTPS key renewal for node %s", n->name);
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;
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;