Only ping once after the idle time exceeds keepalive time.
Do not ping if no endpoint address is known yet
Signed-off-by: Felix Fietkau <nbd@nbd.name>
bool connected;
bool handshake;
bool has_local_ep_addr;
+ bool pinged;
union network_addr local_ep_addr;
union network_endpoint endpoint;
static void
network_pex_send_ping(struct network *net, struct network_peer *peer)
{
+ if (peer->state.pinged || !peer->state.endpoint.sa.sa_family)
+ return;
+
pex_msg_init(net, PEX_MSG_PING);
pex_msg_send(net, peer);
+ peer->state.pinged = true;
}
static void
if (peer->state.idle > sec)
peer->state.idle = sec;
wg_peer_set_connected(net, peer, true);
+ peer->state.pinged = false;
}
}