summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/peer.h4
-rw-r--r--src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c4
-rw-r--r--src/protocol_null.c4
3 files changed, 9 insertions, 3 deletions
diff --git a/src/peer.h b/src/peer.h
index 0e258a0..b100739 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -111,6 +111,10 @@ static inline void fastd_peer_set_established(fastd_context *ctx, fastd_peer *pe
}
}
+static inline void fastd_peer_seen(fastd_context *ctx, fastd_peer *peer) {
+ peer->seen = ctx->now;
+}
+
static inline bool fastd_eth_addr_is_unicast(const fastd_eth_addr *addr) {
return ((addr->data[0] & 1) == 0);
}
diff --git a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
index 5b05041..4888589 100644
--- a/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
+++ b/src/protocol_ec25519_fhmqvc_xsalsa20_poly1305.c
@@ -362,7 +362,7 @@ static void establish(fastd_context *ctx, fastd_peer *peer, const fastd_peer_con
peer->protocol_state->session.receive_nonce[i] = 0;
}
- peer->seen = ctx->now;
+ fastd_peer_seen(ctx, peer);
if (peer_config != peer->config) {
fastd_peer *perm_peer;
@@ -614,6 +614,8 @@ static void protocol_handle_recv(fastd_context *ctx, fastd_peer *peer, fastd_buf
goto end;
}
+ fastd_peer_seen(ctx, peer);
+
fastd_buffer_push_head(&recv_buffer, crypto_secretbox_xsalsa20poly1305_ZEROBYTES);
fastd_task_put_handle_recv(ctx, peer, recv_buffer);
diff --git a/src/protocol_null.c b/src/protocol_null.c
index d9588b3..8648c88 100644
--- a/src/protocol_null.c
+++ b/src/protocol_null.c
@@ -53,7 +53,7 @@ static void protocol_handshake_init(fastd_context *ctx, fastd_peer *peer) {
}
static void establish(fastd_context *ctx, fastd_peer *peer) {
- peer->seen = ctx->now;
+ fastd_peer_seen(ctx, peer);
if (fastd_peer_is_temporary(peer)) {
fastd_peer *perm_peer;
@@ -100,7 +100,7 @@ static void protocol_handshake_handle(fastd_context *ctx, fastd_peer *peer, cons
static void protocol_handle_recv(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) {
if (fastd_peer_is_established(peer) && buffer.len) {
- peer->seen = ctx->now;
+ fastd_peer_seen(ctx, peer);
fastd_task_put_handle_recv(ctx, peer, buffer);
}
else {