fix: auto_socket TCP duplicate sockets + NAT v4 address resolution
auto_socket.c: create_iface_tcp_socket returns stcp_server* instead of int, ifa->v4_tcp/ifa->v6_tcp now properly track the created server, preventing duplicate bind/listen on every reconcile_iface call. etcp_connections.c: tcp_socket_add now resolves interface_addr via get_interface_ip_by_index/get_interface_ipv6_addr_nl for any type (not just PUBLIC), preventing NAT TCP v4 sockets from being destroyed due to INADDR_ANY.
This commit is contained in:
1 parent
de61a2dacc
commit
80e77f12c2
12 files changed
+202
-66
No files matched your search
@@ -623,8 +623,8 @@ struct TOPO_NODE* topo_node_sqlite_node_load(sqlite3* db, struct TOPO_GROUPS* gr
|
||||
{
|
||||
sqlite3_stmt* s = NULL;
|
||||
if (sqlite3_prepare_v2(db,
|
||||
"SELECT address,port,addr_type,socket_id FROM node_addresses"
|
||||
" WHERE node_id=? AND family=4 AND protocol=1 ORDER BY addr_type",
|
||||
"SELECT address,port,addr_type,socket_id,protocol FROM node_addresses"
|
||||
" WHERE node_id=? AND family=4 ORDER BY addr_type",
|
||||
-1, &s, NULL) == SQLITE_OK) {
|
||||
sqlite3_bind_int64(s, 1, (sqlite3_int64)node_id);
|
||||
while (sqlite3_step(s) == SQLITE_ROW) {
|
||||
@@ -638,8 +638,9 @@ struct TOPO_NODE* topo_node_sqlite_node_load(sqlite3* db, struct TOPO_GROUPS* gr
|
||||
struct TOPO_ADDR4* a4 = memory_pool_alloc(groups->v4_addr_pool);
|
||||
if (!a4) continue;
|
||||
memset(a4, 0, sizeof(*a4));
|
||||
int proto = sqlite3_column_int(s, 4);
|
||||
memcpy(a4->addr, addr, 4); a4->port = (uint16_t)port;
|
||||
a4->type = type; a4->socket_id = sock_id; a4->protocol = TOPO_PROTO_UDP;
|
||||
a4->type = type; a4->socket_id = sock_id; a4->protocol = (uint8_t)proto;
|
||||
if (!v4_head) v4_head = v4_tail = a4;
|
||||
else { v4_tail->next = a4; v4_tail = a4; }
|
||||
}
|
||||
@@ -651,8 +652,8 @@ struct TOPO_NODE* topo_node_sqlite_node_load(sqlite3* db, struct TOPO_GROUPS* gr
|
||||
{
|
||||
sqlite3_stmt* s = NULL;
|
||||
if (sqlite3_prepare_v2(db,
|
||||
"SELECT address,port,addr_type,socket_id FROM node_addresses"
|
||||
" WHERE node_id=? AND family=6 AND protocol=1 ORDER BY addr_type",
|
||||
"SELECT address,port,addr_type,socket_id,protocol FROM node_addresses"
|
||||
" WHERE node_id=? AND family=6 ORDER BY addr_type",
|
||||
-1, &s, NULL) == SQLITE_OK) {
|
||||
sqlite3_bind_int64(s, 1, (sqlite3_int64)node_id);
|
||||
while (sqlite3_step(s) == SQLITE_ROW) {
|
||||
@@ -666,8 +667,9 @@ struct TOPO_NODE* topo_node_sqlite_node_load(sqlite3* db, struct TOPO_GROUPS* gr
|
||||
struct TOPO_ADDR6* a6 = memory_pool_alloc(groups->v6_addr_pool);
|
||||
if (!a6) continue;
|
||||
memset(a6, 0, sizeof(*a6));
|
||||
int proto6 = sqlite3_column_int(s, 4);
|
||||
memcpy(a6->addr, addr, 16); a6->port = (uint16_t)port;
|
||||
a6->type = type; a6->socket_id = sock_id; a6->protocol = TOPO_PROTO_UDP;
|
||||
a6->type = type; a6->socket_id = sock_id; a6->protocol = (uint8_t)proto6;
|
||||
if (!v6_head) v6_head = v6_tail = a6;
|
||||
else { v6_tail->next = a6; v6_tail = a6; }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user