summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/TCP_connection.c17
-rw-r--r--toxcore/TCP_connection.h12
2 files changed, 26 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)
diff --git a/toxcore/TCP_connection.h b/toxcore/TCP_connection.h
index 140d6de3..7bc34f86 100644
--- a/toxcore/TCP_connection.h
+++ b/toxcore/TCP_connection.h
@@ -165,6 +165,8 @@ void set_oob_packet_tcp_connection_callback(TCP_Connections *tcp_c, int (*tcp_oo
165 165
166/* Create a new TCP connection to public_key. 166/* Create a new TCP connection to public_key.
167 * 167 *
168 * public_key must be the counterpart to the secret key that the other peer used with new_tcp_connections().
169 *
168 * id is the id in the callbacks for that connection. 170 * id is the id in the callbacks for that connection.
169 * 171 *
170 * return connections_number on success. 172 * return connections_number on success.
@@ -206,6 +208,8 @@ int add_tcp_number_relay_connection(TCP_Connections *tcp_c, int connections_numb
206 208
207/* Add a TCP relay tied to a connection. 209/* Add a TCP relay tied to a connection.
208 * 210 *
211 * This should be called with the same relay by two peers who want to create a TCP connection with each other.
212 *
209 * return 0 on success. 213 * return 0 on success.
210 * return -1 on failure. 214 * return -1 on failure.
211 */ 215 */
@@ -226,7 +230,15 @@ int add_tcp_relay_global(TCP_Connections *tcp_c, IP_Port ip_port, const uint8_t
226 */ 230 */
227unsigned int tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_format *tcp_relays, uint16_t max_num); 231unsigned int tcp_copy_connected_relays(TCP_Connections *tcp_c, Node_format *tcp_relays, uint16_t max_num);
228 232
233/* Returns a new TCP_Connections object associated with the secret_key.
234 *
235 * In order for others to connect to this instance new_tcp_connection_to() must be called with the
236 * public_key associated with secret_key.
237 *
238 * Returns NULL on failure.
239 */
229TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Proxy_Info *proxy_info); 240TCP_Connections *new_tcp_connections(const uint8_t *secret_key, TCP_Proxy_Info *proxy_info);
241
230void do_tcp_connections(TCP_Connections *tcp_c); 242void do_tcp_connections(TCP_Connections *tcp_c);
231void kill_tcp_connections(TCP_Connections *tcp_c); 243void kill_tcp_connections(TCP_Connections *tcp_c);
232 244