Skip to content

Commit

Permalink
add ns to param
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-Sky committed Oct 16, 2024
1 parent 03e9fbf commit 60d302d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void test_basic(void)
for (uint8_t i = 0; i < NUM_PORTS; i++) {
sock = net_socket(ns, net_family_ipv6(), TOX_SOCK_STREAM, TOX_PROTO_TCP);
localhost.port = net_htons(ports[i]);
bool ret = net_connect(mem, logger, sock, &localhost);
bool ret = net_connect(ns, mem, logger, sock, &localhost);
ck_assert_msg(ret, "Failed to connect to created TCP relay server on port %d (%d).", ports[i], errno);

// Leave open one connection for the next test.
Expand Down Expand Up @@ -213,7 +213,7 @@ static struct sec_TCP_con *new_tcp_con(const Logger *logger, const Memory *mem,
localhost.ip = get_loopback();
localhost.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);

bool ok = net_connect(mem, logger, sock, &localhost);
bool ok = net_connect(ns, mem, logger, sock, &localhost);
ck_assert_msg(ok, "Failed to connect to the test TCP relay server.");

uint8_t f_secret_key[CRYPTO_SECRET_KEY_SIZE];
Expand Down
8 changes: 4 additions & 4 deletions toxcore/TCP_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ void tcp_con_set_custom_uint(TCP_Client_Connection *con, uint32_t value)
* @retval false on failure
*/
non_null()
static bool connect_sock_to(const Logger *logger, const Memory *mem, Socket sock, const IP_Port *ip_port, const TCP_Proxy_Info *proxy_info)
static bool connect_sock_to(const Network *ns, const Logger *logger, const Memory *mem, Socket sock, const IP_Port *ip_port, const TCP_Proxy_Info *proxy_info)
{
if (proxy_info->proxy_type != TCP_PROXY_NONE) {
return net_connect(mem, logger, sock, &proxy_info->ip_port);
return net_connect(ns, mem, logger, sock, &proxy_info->ip_port);
} else {
return net_connect(mem, logger, sock, ip_port);
return net_connect(ns, mem, logger, sock, ip_port);
}
}

Expand Down Expand Up @@ -617,7 +617,7 @@ TCP_Client_Connection *new_tcp_connection(
return nullptr;
}

if (!(set_socket_nonblock(ns, sock) && connect_sock_to(logger, mem, sock, ip_port, proxy_info))) {
if (!(set_socket_nonblock(ns, sock) && connect_sock_to(ns, logger, mem, sock, ip_port, proxy_info))) {
kill_sock(ns, sock);
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion toxcore/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,7 @@ bool addr_resolve_or_parse_ip(const Network *ns, const char *address, IP *to, IP
return true;
}

bool net_connect(const Memory *mem, const Logger *log, Socket sock, const IP_Port *ip_port)
bool net_connect(const Network *ns, const Memory *mem, const Logger *log, Socket sock, const IP_Port *ip_port)
{
struct sockaddr_storage addr = {0};
size_t addrsize;
Expand Down
2 changes: 1 addition & 1 deletion toxcore/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void networking_poll(const Networking_Core *net, void *userdata);
* Return false on failure.
*/
non_null()
bool net_connect(const Memory *mem, const Logger *log, Socket sock, const IP_Port *ip_port);
bool net_connect(const Network *ns, const Memory *mem, const Logger *log, Socket sock, const IP_Port *ip_port);

/** @brief High-level getaddrinfo implementation.
*
Expand Down

0 comments on commit 60d302d

Please sign in to comment.