@@ -795,12 +795,16 @@ void network_pex_close(struct network *net)
795
795
{
796
796
struct network_pex * pex = & net -> pex ;
797
797
struct network_pex_host * host , * tmp ;
798
+ uint64_t now = unet_gettime ();
798
799
799
800
uloop_timeout_cancel (& pex -> request_update_timer );
800
801
list_for_each_entry_safe (host , tmp , & pex -> hosts , list ) {
801
802
if (host -> timeout )
802
803
continue ;
803
804
805
+ if (host -> last_active + UNETD_PEX_HOST_ACITVE_TIMEOUT >= now )
806
+ continue ;
807
+
804
808
list_del (& host -> list );
805
809
free (host );
806
810
}
@@ -837,6 +841,20 @@ global_pex_find_network(const uint8_t *id)
837
841
return NULL ;
838
842
}
839
843
844
+ static void
845
+ global_pex_set_active (struct network * net , struct sockaddr_in6 * addr )
846
+ {
847
+ struct network_pex * pex = & net -> pex ;
848
+ struct network_pex_host * host ;
849
+
850
+ list_for_each_entry (host , & pex -> hosts , list ) {
851
+ if (memcmp (& host -> endpoint .in6 , addr , sizeof (* addr )) != 0 )
852
+ continue ;
853
+
854
+ host -> last_active = unet_gettime ();
855
+ }
856
+ }
857
+
840
858
static void
841
859
global_pex_recv (struct pex_hdr * hdr , struct sockaddr_in6 * addr )
842
860
{
@@ -856,6 +874,8 @@ global_pex_recv(struct pex_hdr *hdr, struct sockaddr_in6 *addr)
856
874
857
875
* (uint64_t * )hdr -> id ^= pex_network_hash (net -> config .auth_key , ehdr -> nonce );
858
876
877
+ global_pex_set_active (net , addr );
878
+
859
879
D ("PEX global rx op=%d" , hdr -> opcode );
860
880
switch (hdr -> opcode ) {
861
881
case PEX_MSG_HELLO :
0 commit comments