summaryrefslogtreecommitdiff
path: root/toxcore/TCP_connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/TCP_connection.c')
-rw-r--r--toxcore/TCP_connection.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c
index b0b26d20..d26a60de 100644
--- a/toxcore/TCP_connection.c
+++ b/toxcore/TCP_connection.c
@@ -691,7 +691,7 @@ static int reconnect_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connec
691 uint8_t relay_pk[crypto_box_PUBLICKEYBYTES]; 691 uint8_t relay_pk[crypto_box_PUBLICKEYBYTES];
692 memcpy(relay_pk, tcp_con->connection->public_key, crypto_box_PUBLICKEYBYTES); 692 memcpy(relay_pk, tcp_con->connection->public_key, crypto_box_PUBLICKEYBYTES);
693 kill_TCP_connection(tcp_con->connection); 693 kill_TCP_connection(tcp_con->connection);
694 tcp_con->connection = new_TCP_connection(ip_port, relay_pk, tcp_c->dht->self_public_key, tcp_c->dht->self_secret_key, 694 tcp_con->connection = new_TCP_connection(ip_port, relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key,
695 &tcp_c->proxy_info); 695 &tcp_c->proxy_info);
696 696
697 if (!tcp_con->connection) { 697 if (!tcp_con->connection) {
@@ -776,8 +776,8 @@ static int unsleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connecti
776 if (tcp_con->status != TCP_CONN_SLEEPING) 776 if (tcp_con->status != TCP_CONN_SLEEPING)
777 return -1; 777 return -1;
778 778
779 tcp_con->connection = new_TCP_connection(tcp_con->ip_port, tcp_con->relay_pk, tcp_c->dht->self_public_key, 779 tcp_con->connection = new_TCP_connection(tcp_con->ip_port, tcp_con->relay_pk, tcp_c->self_public_key,
780 tcp_c->dht->self_secret_key, &tcp_c->proxy_info); 780 tcp_c->self_secret_key, &tcp_c->proxy_info);
781 781
782 if (!tcp_con->connection) { 782 if (!tcp_con->connection) {
783 kill_tcp_relay_connection(tcp_c, tcp_connections_number); 783 kill_tcp_relay_connection(tcp_c, tcp_connections_number);
@@ -1025,7 +1025,7 @@ static int add_tcp_relay(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t
1025 TCP_con *tcp_con = &tcp_c->tcp_connections[tcp_connections_number]; 1025 TCP_con *tcp_con = &tcp_c->tcp_connections[tcp_connections_number];
1026 1026
1027 1027
1028 tcp_con->connection = new_TCP_connection(ip_port, relay_pk, tcp_c->dht->self_public_key, tcp_c->dht->self_secret_key, 1028 tcp_con->connection = new_TCP_connection(ip_port, relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key,
1029 &tcp_c->proxy_info); 1029 &tcp_c->proxy_info);
1030 1030
1031 if (!tcp_con->connection) 1031 if (!tcp_con->connection)
@@ -1237,9 +1237,9 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, _Bool status)
1237 return 0; 1237 return 0;
1238} 1238}
1239 1239
1240TCP_Connections *new_tcp_connections(DHT *dht, TCP_Proxy_Info *proxy_info) 1240TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Proxy_Info *proxy_info)
1241{ 1241{
1242 if (dht == NULL) 1242 if (secret_key == NULL)
1243 return NULL; 1243 return NULL;
1244 1244
1245 TCP_Connections *temp = calloc(1, sizeof(TCP_Connections)); 1245 TCP_Connections *temp = calloc(1, sizeof(TCP_Connections));
@@ -1247,7 +1247,8 @@ TCP_Connections *new_tcp_connections(DHT *dht, TCP_Proxy_Info *proxy_info)
1247 if (temp == NULL) 1247 if (temp == NULL)
1248 return NULL; 1248 return NULL;
1249 1249
1250 temp->dht = dht; 1250 memcpy(temp->self_secret_key, secret_key, crypto_box_SECRETKEYBYTES);
1251 crypto_scalarmult_curve25519_base(temp->self_public_key, temp->self_secret_key);
1251 temp->proxy_info = *proxy_info; 1252 temp->proxy_info = *proxy_info;
1252 1253
1253 return temp; 1254 return temp;