From 009c4c2765398e52e43c8e354844c98c55bc61db Mon Sep 17 00:00:00 2001 From: fanasina Date: Sat, 18 Oct 2025 15:42:47 +0200 Subject: [PATCH] y_socket: try add manualy ::1 to local address --- y_socket_t/src/y_socket_t/y_file_handler.c | 1 + y_socket_t/src/y_socket_t/y_node_t.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/y_socket_t/src/y_socket_t/y_file_handler.c b/y_socket_t/src/y_socket_t/y_file_handler.c index 8c59d46..cb316e5 100644 --- a/y_socket_t/src/y_socket_t/y_file_handler.c +++ b/y_socket_t/src/y_socket_t/y_file_handler.c @@ -711,6 +711,7 @@ void* y_send_buf_for_other_(void* arg){ for(struct list_y_NODE_T *local_list_current = nodes->begin_list; local_list_current; local_list_current=local_list_current->next ){ if(local_list_current->value.local_addr == 0){ set_addr_str_from_node(tempAddr, local_list_current->value); + printf("debug: not local address:%s\n",tempAddr); c_af=(local_list_current->value).addr.ss_family; diff --git a/y_socket_t/src/y_socket_t/y_node_t.c b/y_socket_t/src/y_socket_t/y_node_t.c index 9df0ea6..27e532f 100644 --- a/y_socket_t/src/y_socket_t/y_node_t.c +++ b/y_socket_t/src/y_socket_t/y_node_t.c @@ -190,6 +190,8 @@ void* update_nodes(void* arg) fprintf(stderr, "getnameinfo: %s\n", gai_strerror(status)); #endif + struct sockaddr_in6 local6; + inet_pton(AF_INET6, "::1", &local6);; if(NULL == search_node_in_list_y_NODE_T(nodes, node)){ int c_af = node.addr.ss_family; for(struct ifaddrs *cur_ifa = if_addr; cur_ifa; cur_ifa=cur_ifa->ifa_next){ @@ -200,7 +202,10 @@ void* update_nodes(void* arg) break; } }else if(c_af==AF_INET6){ - if(memcmp(((struct sockaddr_in6*)&(node.addr))->sin6_addr.s6_addr , ((struct sockaddr_in6*)&(cur_ifa->ifa_addr))->sin6_addr.s6_addr, 8)==0){ + if( + (memcmp(((struct sockaddr_in6*)&(node.addr))->sin6_addr.s6_addr , local6.sin6_addr.s6_addr, 8)==0)|| + (memcmp(((struct sockaddr_in6*)&(node.addr))->sin6_addr.s6_addr , ((struct sockaddr_in6*)&(cur_ifa->ifa_addr))->sin6_addr.s6_addr, 8)==0) + ){ node.local_addr = 1; break; } @@ -208,7 +213,7 @@ void* update_nodes(void* arg) } } push_back_list_y_NODE_T(nodes, node); - ///printf("debug: // /// // // update_nodes local_addr=%d\n",node.local_addr ); + //printf("debug: // /// // // update_nodes local_addr=%d\n",node.local_addr ); } if(if_addr) freeifaddrs(if_addr);