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.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c
index d26a60de..7a84c0c2 100644
--- a/toxcore/TCP_connection.c
+++ b/toxcore/TCP_connection.c
@@ -423,6 +423,8 @@ static int find_tcp_connection_relay(TCP_Connections *tcp_c, const uint8_t *rela
423 423
424/* Create a new TCP connection to public_key. 424/* Create a new TCP connection to public_key.
425 * 425 *
426 * public_key must be the counterpart to the secret key that the other peer used with new_tcp_connections().
427 *
426 * id is the id in the callbacks for that connection. 428 * id is the id in the callbacks for that connection.
427 * 429 *
428 * return connections_number on success. 430 * return connections_number on success.
@@ -1006,7 +1008,7 @@ static int tcp_relay_on_online(TCP_Connections *tcp_c, int tcp_connections_numbe
1006 return 0; 1008 return 0;
1007} 1009}
1008 1010
1009static int add_tcp_relay(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t *relay_pk) 1011static int add_tcp_relay_instance(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t *relay_pk)
1010{ 1012{
1011 if (ip_port.ip.family == TCP_INET) { 1013 if (ip_port.ip.family == TCP_INET) {
1012 ip_port.ip.family = AF_INET; 1014 ip_port.ip.family = AF_INET;
@@ -1036,7 +1038,7 @@ static int add_tcp_relay(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t
1036 return tcp_connections_number; 1038 return tcp_connections_number;
1037} 1039}
1038 1040
1039/* Add a TCP relay to the instance. 1041/* Add a TCP relay to the TCP_Connections instance.
1040 * 1042 *
1041 * return 0 on success. 1043 * return 0 on success.
1042 * return -1 on failure. 1044 * return -1 on failure.
@@ -1048,7 +1050,7 @@ int add_tcp_relay_global(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t
1048 if (tcp_connections_number != -1) 1050 if (tcp_connections_number != -1)
1049 return -1; 1051 return -1;
1050 1052
1051 if (add_tcp_relay(tcp_c, ip_port, relay_pk) == -1) 1053 if (add_tcp_relay_instance(tcp_c, ip_port, relay_pk) == -1)
1052 return -1; 1054 return -1;
1053 1055
1054 return 0; 1056 return 0;
@@ -1089,6 +1091,8 @@ int add_tcp_number_relay_connection(TCP_Connections *tcp_c, int connections_numb
1089 1091
1090/* Add a TCP relay tied to a connection. 1092/* Add a TCP relay tied to a connection.
1091 * 1093 *
1094 * This should be called with the same relay by two peers who want to create a TCP connection with each other.
1095 *
1092 * return 0 on success. 1096 * return 0 on success.
1093 * return -1 on failure. 1097 * return -1 on failure.
1094 */ 1098 */
@@ -1237,6 +1241,13 @@ int set_tcp_onion_status(TCP_Connections *tcp_c, _Bool status)
1237 return 0; 1241 return 0;
1238} 1242}
1239 1243
1244/* Returns a new TCP_Connections object associated with the secret_key.
1245 *
1246 * In order for others to connect to this instance new_tcp_connection_to() must be called with the
1247 * public_key associated with secret_key.
1248 *
1249 * Returns NULL on failure.
1250 */
1240TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Proxy_Info *proxy_info) 1251TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Proxy_Info *proxy_info)
1241{ 1252{
1242 if (secret_key == NULL) 1253 if (secret_key == NULL)