diff options
-rw-r--r-- | toxcore/TCP_connection.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index 352a58d9..e11e1318 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c | |||
@@ -670,11 +670,15 @@ static int tcp_oob_callback(void *object, const uint8_t *public_key, const uint8 | |||
670 | if (!tcp_con) | 670 | if (!tcp_con) |
671 | return -1; | 671 | return -1; |
672 | 672 | ||
673 | uint8_t relay_pk[crypto_box_PUBLICKEYBYTES]; | 673 | /* TODO: optimize */ |
674 | memcpy(relay_pk, tcp_con->connection->public_key, crypto_box_PUBLICKEYBYTES); | 674 | int connections_number = find_tcp_connection_to(tcp_c, public_key); |
675 | 675 | ||
676 | if (tcp_c->tcp_oob_callback) | 676 | if (connections_number == -1) { |
677 | tcp_c->tcp_oob_callback(tcp_c->tcp_oob_callback_object, public_key, tcp_connections_number, data, length); | 677 | if (tcp_c->tcp_oob_callback) |
678 | tcp_c->tcp_oob_callback(tcp_c->tcp_oob_callback_object, public_key, tcp_connections_number, data, length); | ||
679 | } else { | ||
680 | return tcp_data_callback(object, connections_number, 0, data, length); | ||
681 | } | ||
678 | 682 | ||
679 | return 0; | 683 | return 0; |
680 | } | 684 | } |