{
struct network_pex *pex = &net->pex;
struct network_pex_host *host, *tmp;
+ uint64_t now = unet_gettime();
uloop_timeout_cancel(&pex->request_update_timer);
list_for_each_entry_safe(host, tmp, &pex->hosts, list) {
if (host->timeout)
continue;
+ if (host->last_active + UNETD_PEX_HOST_ACITVE_TIMEOUT >= now)
+ continue;
+
list_del(&host->list);
free(host);
}
return NULL;
}
+static void
+global_pex_set_active(struct network *net, struct sockaddr_in6 *addr)
+{
+ struct network_pex *pex = &net->pex;
+ struct network_pex_host *host;
+
+ list_for_each_entry(host, &pex->hosts, list) {
+ if (memcmp(&host->endpoint.in6, addr, sizeof(*addr)) != 0)
+ continue;
+
+ host->last_active = unet_gettime();
+ }
+}
+
static void
global_pex_recv(struct pex_hdr *hdr, struct sockaddr_in6 *addr)
{
*(uint64_t *)hdr->id ^= pex_network_hash(net->config.auth_key, ehdr->nonce);
+ global_pex_set_active(net, addr);
+
D("PEX global rx op=%d", hdr->opcode);
switch (hdr->opcode) {
case PEX_MSG_HELLO:
#define UNETD_DATA_UPDATE_DELAY (10 * 1000)
+#define UNETD_PEX_HOST_ACITVE_TIMEOUT 60
+
void unetd_write_hosts(void);
int unetd_attach_mssfix(int ifindex, int mtu);