diff options
-rw-r--r-- | src/fastd.c | 3 | ||||
-rw-r--r-- | src/fastd.h | 2 | ||||
-rw-r--r-- | src/peer.c | 8 | ||||
-rw-r--r-- | src/protocol_ec25519_fhmqvc.c | 6 |
4 files changed, 14 insertions, 5 deletions
diff --git a/src/fastd.c b/src/fastd.c index 7c702c1..6ce10fc 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -769,6 +769,9 @@ int main(int argc, char *argv[]) { update_time(&ctx); + conf.long_ago = ctx.now; + conf.long_ago.tv_sec -= 86400; /* 24h in the past */ + ctx.next_keepalives = ctx.now; ctx.next_keepalives.tv_sec += conf.keepalive_interval; diff --git a/src/fastd.h b/src/fastd.h index 848a5d3..dcb35b4 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -162,6 +162,8 @@ struct fastd_peer_group { }; struct fastd_config { + struct timespec long_ago; + fastd_loglevel_t log_stderr_level; fastd_loglevel_t log_syslog_level; char *log_syslog_ident; @@ -201,16 +201,16 @@ static void setup_peer(fastd_context_t *ctx, fastd_peer_t *peer) { fastd_remote_t *remote; for (remote = peer->remotes; remote; remote = remote->next) { - remote->last_resolve = (struct timespec){0, 0}; - remote->last_resolve_return = (struct timespec){0, 0}; + remote->last_resolve = ctx->conf->long_ago; + remote->last_resolve_return = ctx->conf->long_ago; } peer->next_remote = peer->remotes; - peer->last_handshake = (struct timespec){0, 0}; + peer->last_handshake = ctx->conf->long_ago; peer->last_handshake_address.sa.sa_family = AF_UNSPEC; - peer->last_handshake_response = (struct timespec){0, 0}; + peer->last_handshake_response = ctx->conf->long_ago; peer->last_handshake_response_address.sa.sa_family = AF_UNSPEC; if (!peer->protocol_state) diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c index bb75404..73fbc5e 100644 --- a/src/protocol_ec25519_fhmqvc.c +++ b/src/protocol_ec25519_fhmqvc.c @@ -240,8 +240,12 @@ static bool protocol_peer_check_temporary(fastd_context_t *ctx, fastd_peer_t *pe } static void init_protocol_state(fastd_context_t *ctx) { - if (!ctx->protocol_state) + if (!ctx->protocol_state) { ctx->protocol_state = calloc(1, sizeof(fastd_protocol_state_t)); + + ctx->protocol_state->prev_handshake_key.preferred_till = ctx->conf->long_ago; + ctx->protocol_state->handshake_key.preferred_till = ctx->conf->long_ago; + } } static void new_handshake_key(fastd_context_t *ctx, keypair_t *key) { |