From 565d73713aa75f0d5437f0152ee7cb22f3113c59 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 16 Apr 2015 14:17:57 -0400 Subject: Store TCP relays tied to friend and reconnect to some when reconnecting. --- toxcore/friend_connection.c | 61 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'toxcore/friend_connection.c') diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 074021da..d38ad73a 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -146,6 +146,58 @@ int getfriend_conn_id_pk(Friend_Connections *fr_c, const uint8_t *real_pk) return -1; } +/* Add a TCP relay associated to the friend. + * + * return -1 on failure. + * return 0 on success. + */ +int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_port, const uint8_t *public_key) +{ + Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); + + if (!friend_con) + return -1; + + unsigned int i; + + uint16_t index = friend_con->tcp_relay_counter; + + for (i = 0; i < FRIEND_MAX_STORED_TCP_RELAYS; ++i) { + if (friend_con->tcp_relays[i].ip_port.ip.family != 0 + && memcmp(friend_con->tcp_relays[i].public_key, public_key, crypto_box_PUBLICKEYBYTES) == 0) { + memset(&friend_con->tcp_relays[i], 0, sizeof(Node_format)); + } + } + + friend_con->tcp_relays[index % FRIEND_MAX_STORED_TCP_RELAYS].ip_port = ip_port; + memcpy(friend_con->tcp_relays[index % FRIEND_MAX_STORED_TCP_RELAYS].public_key, public_key, crypto_box_PUBLICKEYBYTES); + ++friend_con->tcp_relay_counter; + + return add_tcp_relay_peer(fr_c->net_crypto, friend_con->crypt_connection_id, ip_port, public_key); +} + +/* Connect to number saved relays for friend. */ +static void connect_to_saved_tcp_relays(Friend_Connections *fr_c, int friendcon_id, unsigned int number) +{ + Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); + + if (!friend_con) + return; + + unsigned int i; + + for (i = 0; (i < FRIEND_MAX_STORED_TCP_RELAYS) && (number != 0); ++i) { + uint16_t index = (friend_con->tcp_relay_counter - (i + 1)) % FRIEND_MAX_STORED_TCP_RELAYS; + + if (friend_con->tcp_relays[index].ip_port.ip.family) { + if (add_tcp_relay_peer(fr_c->net_crypto, friend_con->crypt_connection_id, friend_con->tcp_relays[index].ip_port, + friend_con->tcp_relays[index].public_key) == 0) { + --number; + } + } + } +} + /* callback for recv TCP relay nodes. */ static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_port, const uint8_t *public_key) { @@ -156,7 +208,7 @@ static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_por return -1; if (friend_con->crypt_connection_id != -1) { - return add_tcp_relay_peer(fr_c->net_crypto, friend_con->crypt_connection_id, ip_port, public_key); + return friend_add_tcp_relay(fr_c, number, ip_port, public_key); } else { return add_tcp_relay(fr_c->net_crypto, ip_port, public_key); } @@ -190,7 +242,7 @@ static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_pub if (!friend_con) return; - friend_con->dht_ping_lastrecv = unix_time(); + friend_con->dht_pk_lastrecv = unix_time(); if (memcmp(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) return; @@ -234,7 +286,7 @@ static int handle_status(void *object, int number, uint8_t status) } else { /* Went offline. */ if (friend_con->status != FRIENDCONN_STATUS_CONNECTING) { call_cb = 1; - friend_con->dht_ping_lastrecv = unix_time(); + friend_con->dht_pk_lastrecv = unix_time(); onion_set_friend_online(fr_c->onion_c, friend_con->onion_friendnum, status); } @@ -647,7 +699,7 @@ void do_friend_connections(Friend_Connections *fr_c) if (friend_con) { if (friend_con->status == FRIENDCONN_STATUS_CONNECTING) { - if (friend_con->dht_ping_lastrecv + FRIEND_DHT_TIMEOUT < temp_time) { + if (friend_con->dht_pk_lastrecv + FRIEND_DHT_TIMEOUT < temp_time) { if (friend_con->dht_lock) { DHT_delfriend(fr_c->dht, friend_con->dht_temp_pk, friend_con->dht_lock); friend_con->dht_lock = 0; @@ -662,6 +714,7 @@ void do_friend_connections(Friend_Connections *fr_c) if (friend_new_connection(fr_c, i) == 0) { set_connection_dht_public_key(fr_c->net_crypto, friend_con->crypt_connection_id, friend_con->dht_temp_pk); set_direct_ip_port(fr_c->net_crypto, friend_con->crypt_connection_id, friend_con->dht_ip_port); + connect_to_saved_tcp_relays(fr_c, i, (MAX_FRIEND_TCP_CONNECTIONS / 2)); /* Only fill it half up. */ } } -- cgit v1.2.3 From 1a2fa1b7e639e5e94612c774894baa50b3514265 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 18 Apr 2015 22:14:37 -0400 Subject: Some changes to net crypto. Should fix certain connection issues that sometimes happen. The dht public key of the peer must be known to create the connection. If the dht pk of the peer changes when a connection is active, it is killed to make way for the new one. --- toxcore/friend_connection.c | 60 ++++++++---- toxcore/net_crypto.c | 228 ++++++++++++++++++-------------------------- toxcore/net_crypto.h | 27 +----- 3 files changed, 138 insertions(+), 177 deletions(-) (limited to 'toxcore/friend_connection.c') diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index d38ad73a..0f171100 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -160,7 +160,7 @@ int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_ unsigned int i; - uint16_t index = friend_con->tcp_relay_counter; + uint16_t index = friend_con->tcp_relay_counter % FRIEND_MAX_STORED_TCP_RELAYS; for (i = 0; i < FRIEND_MAX_STORED_TCP_RELAYS; ++i) { if (friend_con->tcp_relays[i].ip_port.ip.family != 0 @@ -169,8 +169,8 @@ int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_ } } - friend_con->tcp_relays[index % FRIEND_MAX_STORED_TCP_RELAYS].ip_port = ip_port; - memcpy(friend_con->tcp_relays[index % FRIEND_MAX_STORED_TCP_RELAYS].public_key, public_key, crypto_box_PUBLICKEYBYTES); + friend_con->tcp_relays[index].ip_port = ip_port; + memcpy(friend_con->tcp_relays[index].public_key, public_key, crypto_box_PUBLICKEYBYTES); ++friend_con->tcp_relay_counter; return add_tcp_relay_peer(fr_c->net_crypto, friend_con->crypt_connection_id, ip_port, public_key); @@ -233,20 +233,15 @@ static void dht_ip_callback(void *object, int32_t number, IP_Port ip_port) friend_con->dht_ip_port_lastrecv = unix_time(); } -/* Callback for dht public key changes. */ -static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) +static void change_dht_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t *dht_public_key) { - Friend_Connections *fr_c = object; - Friend_Conn *friend_con = get_conn(fr_c, number); + Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); if (!friend_con) return; friend_con->dht_pk_lastrecv = unix_time(); - if (memcmp(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) - return; - if (friend_con->dht_lock) { if (DHT_delfriend(fr_c->dht, friend_con->dht_temp_pk, friend_con->dht_lock) != 0) { printf("a. Could not delete dht peer. Please report this.\n"); @@ -256,16 +251,32 @@ static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_pub friend_con->dht_lock = 0; } - DHT_addfriend(fr_c->dht, dht_public_key, dht_ip_callback, object, number, &friend_con->dht_lock); + DHT_addfriend(fr_c->dht, dht_public_key, dht_ip_callback, fr_c, friendcon_id, &friend_con->dht_lock); + memcpy(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES); +} - if (friend_con->crypt_connection_id == -1) { - friend_new_connection(fr_c, number); +/* Callback for dht public key changes. */ +static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) +{ + Friend_Connections *fr_c = object; + Friend_Conn *friend_con = get_conn(fr_c, number); + + if (!friend_con) + return; + + if (memcmp(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) + return; + + change_dht_pk(fr_c, number, dht_public_key); + + /* if pk changed, create a new connection.*/ + if (friend_con->crypt_connection_id != -1) { + crypto_kill(fr_c->net_crypto, friend_con->crypt_connection_id); + friend_con->crypt_connection_id = -1; } - set_connection_dht_public_key(fr_c->net_crypto, friend_con->crypt_connection_id, dht_public_key); + friend_new_connection(fr_c, number); onion_set_friend_DHT_pubkey(fr_c->onion_c, friend_con->onion_friendnum, dht_public_key); - - memcpy(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES); } static int handle_status(void *object, int number, uint8_t status) @@ -385,6 +396,11 @@ static int handle_new_connections(void *object, New_Connection *n_c) return -1; int id = accept_crypto_connection(fr_c->net_crypto, n_c); + + if (id == -1) { + return -1; + } + connection_status_handler(fr_c->net_crypto, id, &handle_status, fr_c, friendcon_id); connection_data_handler(fr_c->net_crypto, id, &handle_packet, fr_c, friendcon_id); connection_lossy_data_handler(fr_c->net_crypto, id, &handle_lossy_packet, fr_c, friendcon_id); @@ -397,7 +413,9 @@ static int handle_new_connections(void *object, New_Connection *n_c) friend_con->dht_ip_port_lastrecv = unix_time(); } - dht_pk_callback(fr_c, friendcon_id, n_c->dht_public_key); + if (memcmp(friend_con->dht_temp_pk, n_c->dht_public_key, crypto_box_PUBLICKEYBYTES) != 0) { + change_dht_pk(fr_c, friendcon_id, n_c->dht_public_key); + } nc_dht_pk_callback(fr_c->net_crypto, id, &dht_pk_callback, fr_c, friendcon_id); return 0; @@ -417,7 +435,12 @@ static int friend_new_connection(Friend_Connections *fr_c, int friendcon_id) return -1; } - int id = new_crypto_connection(fr_c->net_crypto, friend_con->real_public_key); + /* If dht_temp_pk does not contains a pk. */ + if (!friend_con->dht_lock) { + return -1; + } + + int id = new_crypto_connection(fr_c->net_crypto, friend_con->real_public_key, friend_con->dht_temp_pk); if (id == -1) return -1; @@ -712,7 +735,6 @@ void do_friend_connections(Friend_Connections *fr_c) if (friend_con->dht_lock) { if (friend_new_connection(fr_c, i) == 0) { - set_connection_dht_public_key(fr_c->net_crypto, friend_con->crypt_connection_id, friend_con->dht_temp_pk); set_direct_ip_port(fr_c->net_crypto, friend_con->crypt_connection_id, friend_con->dht_ip_port); connect_to_saved_tcp_relays(fr_c, i, (MAX_FRIEND_TCP_CONNECTIONS / 2)); /* Only fill it half up. */ } diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 38fd85b7..f3ca9397 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -35,7 +35,16 @@ static uint8_t crypt_connection_id_not_valid(const Net_Crypto *c, int crypt_connection_id) { - return (uint32_t)crypt_connection_id >= c->crypto_connections_length; + if ((uint32_t)crypt_connection_id >= c->crypto_connections_length) + return 1; + + if (c->crypto_connections == NULL) + return 1; + + if (c->crypto_connections[crypt_connection_id].status == CRYPTO_CONN_NO_CONNECTION) + return 1; + + return 0; } /* cookie timeout in seconds */ @@ -1085,13 +1094,26 @@ static int send_kill_packet(Net_Crypto *c, int crypt_connection_id) &kill_packet, sizeof(kill_packet)); } +static void connection_kill(Net_Crypto *c, int crypt_connection_id) +{ + Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); + + if (conn == 0) + return; + + if (conn->connection_status_callback) { + conn->connection_status_callback(conn->connection_status_callback_object, conn->connection_status_callback_id, 0); + } + + crypto_kill(c, crypt_connection_id); +} + /* Handle a received data packet. * * return -1 on failure. * return 0 on success. */ -static int handle_data_packet_helper(const Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, - uint16_t length) +static int handle_data_packet_helper(Net_Crypto *c, int crypt_connection_id, const uint8_t *packet, uint16_t length) { if (length > MAX_CRYPTO_PACKET_SIZE || length <= CRYPTO_DATA_PACKET_MIN_SIZE) return -1; @@ -1128,7 +1150,7 @@ static int handle_data_packet_helper(const Net_Crypto *c, int crypt_connection_i } if (real_data[0] == PACKET_ID_KILL) { - conn->killed = 1; + connection_kill(c, crypt_connection_id); return 0; } @@ -1243,19 +1265,19 @@ static int handle_packet_connection(Net_Crypto *c, int crypt_connection_id, cons packet, length, conn->public_key) != 0) return -1; - encrypt_precompute(conn->peersessionpublic_key, conn->sessionsecret_key, conn->shared_key); - - if (conn->status == CRYPTO_CONN_COOKIE_REQUESTING) { - if (create_send_handshake(c, crypt_connection_id, cookie, dht_public_key) != 0) - return -1; - } + if (public_key_cmp(dht_public_key, conn->dht_public_key) == 0) { + encrypt_precompute(conn->peersessionpublic_key, conn->sessionsecret_key, conn->shared_key); - conn->status = CRYPTO_CONN_NOT_CONFIRMED; - /* Status needs to be CRYPTO_CONN_NOT_CONFIRMED for this to work. */ - set_connection_dht_public_key(c, crypt_connection_id, dht_public_key); + if (conn->status == CRYPTO_CONN_COOKIE_REQUESTING) { + if (create_send_handshake(c, crypt_connection_id, cookie, dht_public_key) != 0) + return -1; + } - if (conn->dht_pk_callback) - conn->dht_pk_callback(conn->dht_pk_callback_object, conn->dht_pk_callback_number, dht_public_key); + conn->status = CRYPTO_CONN_NOT_CONFIRMED; + } else { + if (conn->dht_pk_callback) + conn->dht_pk_callback(conn->dht_pk_callback_object, conn->dht_pk_callback_number, dht_public_key); + } } else { return -1; @@ -1397,24 +1419,6 @@ static int getcryptconnection_id(const Net_Crypto *c, const uint8_t *public_key) return -1; } -/* Get crypto connection id from public key of peer. - * - * return -1 if there are no connections like we are looking for. - * return id if it found it. - */ -static int getcryptconnection_id_dht_pubkey(const Net_Crypto *c, const uint8_t *dht_public_key) -{ - uint32_t i; - - for (i = 0; i < c->crypto_connections_length; ++i) { - if (c->crypto_connections[i].status != CRYPTO_CONN_NO_CONNECTION && c->crypto_connections[i].dht_public_key_set) - if (memcmp(dht_public_key, c->crypto_connections[i].dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) - return i; - } - - return -1; -} - /* Add a source to the crypto connection. * This is to be used only when we have received a packet from that source. * @@ -1488,30 +1492,28 @@ static int handle_new_connection_handshake(Net_Crypto *c, IP_Port source, const int crypt_connection_id = getcryptconnection_id(c, n_c.public_key); if (crypt_connection_id != -1) { - int ret = -1; Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); - if (conn != 0 && (conn->status == CRYPTO_CONN_COOKIE_REQUESTING || conn->status == CRYPTO_CONN_HANDSHAKE_SENT)) { - memcpy(conn->recv_nonce, n_c.recv_nonce, crypto_box_NONCEBYTES); - memcpy(conn->peersessionpublic_key, n_c.peersessionpublic_key, crypto_box_PUBLICKEYBYTES); - encrypt_precompute(conn->peersessionpublic_key, conn->sessionsecret_key, conn->shared_key); - - crypto_connection_add_source(c, crypt_connection_id, source); + if (public_key_cmp(n_c.dht_public_key, conn->dht_public_key) != 0) { + connection_kill(c, crypt_connection_id); + } else { + int ret = -1; - if (create_send_handshake(c, crypt_connection_id, n_c.cookie, n_c.dht_public_key) == 0) { - conn->status = CRYPTO_CONN_NOT_CONFIRMED; - /* Status needs to be CRYPTO_CONN_NOT_CONFIRMED for this to work. */ - set_connection_dht_public_key(c, crypt_connection_id, n_c.dht_public_key); + if (conn && (conn->status == CRYPTO_CONN_COOKIE_REQUESTING || conn->status == CRYPTO_CONN_HANDSHAKE_SENT)) { + memcpy(conn->recv_nonce, n_c.recv_nonce, crypto_box_NONCEBYTES); + memcpy(conn->peersessionpublic_key, n_c.peersessionpublic_key, crypto_box_PUBLICKEYBYTES); + encrypt_precompute(conn->peersessionpublic_key, conn->sessionsecret_key, conn->shared_key); - if (conn->dht_pk_callback) - conn->dht_pk_callback(conn->dht_pk_callback_object, conn->dht_pk_callback_number, n_c.dht_public_key); + crypto_connection_add_source(c, crypt_connection_id, source); - ret = 0; + if (create_send_handshake(c, crypt_connection_id, n_c.cookie, n_c.dht_public_key) == 0) { + ret = 0; + } } - } - free(n_c.cookie); - return ret; + free(n_c.cookie); + return ret; + } } int ret = c->new_connection_callback(c->new_connection_callback_object, &n_c); @@ -1534,28 +1536,33 @@ int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c) if (crypt_connection_id == -1) return -1; - Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); + Crypto_Connection *conn = &c->crypto_connections[crypt_connection_id]; - if (conn == 0) + if (n_c->cookie_length != COOKIE_LENGTH) + return -1; + + pthread_mutex_lock(&c->tcp_mutex); + conn->connection_number_tcp = new_tcp_connection_to(c->tcp_c, n_c->dht_public_key, crypt_connection_id); + pthread_mutex_unlock(&c->tcp_mutex); + + if (conn->connection_number_tcp == -1) return -1; - conn->connection_number_tcp = -1; memcpy(conn->public_key, n_c->public_key, crypto_box_PUBLICKEYBYTES); memcpy(conn->recv_nonce, n_c->recv_nonce, crypto_box_NONCEBYTES); memcpy(conn->peersessionpublic_key, n_c->peersessionpublic_key, crypto_box_PUBLICKEYBYTES); random_nonce(conn->sent_nonce); crypto_box_keypair(conn->sessionpublic_key, conn->sessionsecret_key); encrypt_precompute(conn->peersessionpublic_key, conn->sessionsecret_key, conn->shared_key); + conn->status = CRYPTO_CONN_NOT_CONFIRMED; - if (n_c->cookie_length != COOKIE_LENGTH) - return -1; - - if (create_send_handshake(c, crypt_connection_id, n_c->cookie, n_c->dht_public_key) != 0) + if (create_send_handshake(c, crypt_connection_id, n_c->cookie, n_c->dht_public_key) != 0) { + pthread_mutex_lock(&c->tcp_mutex); + kill_tcp_connection_to(c->tcp_c, conn->connection_number_tcp); + pthread_mutex_unlock(&c->tcp_mutex); return -1; - - conn->status = CRYPTO_CONN_NOT_CONFIRMED; - /* Status needs to be CRYPTO_CONN_NOT_CONFIRMED for this to work. */ - set_connection_dht_public_key(c, crypt_connection_id, n_c->dht_public_key); + } + memcpy(conn->dht_public_key, n_c->dht_public_key, crypto_box_PUBLICKEYBYTES); conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE; conn->packets_left = CRYPTO_MIN_QUEUE_LENGTH; crypto_connection_add_source(c, crypt_connection_id, n_c->source); @@ -1568,7 +1575,7 @@ int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c) * return -1 on failure. * return connection id on success. */ -int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key) +int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key, const uint8_t *dht_public_key) { int crypt_connection_id = getcryptconnection_id(c, real_public_key); @@ -1580,82 +1587,40 @@ int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key) if (crypt_connection_id == -1) return -1; - Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); + Crypto_Connection *conn = &c->crypto_connections[crypt_connection_id]; if (conn == 0) return -1; - conn->connection_number_tcp = -1; + pthread_mutex_lock(&c->tcp_mutex); + conn->connection_number_tcp = new_tcp_connection_to(c->tcp_c, dht_public_key, crypt_connection_id); + pthread_mutex_unlock(&c->tcp_mutex); + + if (conn->connection_number_tcp == -1) + return -1; + memcpy(conn->public_key, real_public_key, crypto_box_PUBLICKEYBYTES); random_nonce(conn->sent_nonce); crypto_box_keypair(conn->sessionpublic_key, conn->sessionsecret_key); conn->status = CRYPTO_CONN_COOKIE_REQUESTING; conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE; conn->packets_left = CRYPTO_MIN_QUEUE_LENGTH; - return crypt_connection_id; -} - -/* Copy friends DHT public key into dht_key. - * - * return 0 on failure (no key copied). - * return 1 on success (key copied). - */ -unsigned int get_connection_dht_key(const Net_Crypto *c, int crypt_connection_id, uint8_t *dht_public_key) -{ - Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); - - if (conn == 0) - return 0; - - if (conn->dht_public_key_set == 0) - return 0; - - memcpy(dht_public_key, conn->dht_public_key, crypto_box_PUBLICKEYBYTES); - return 1; -} - - -/* Set the DHT public key of the crypto connection. - * - * return -1 on failure. - * return 0 on success. - */ -int set_connection_dht_public_key(Net_Crypto *c, int crypt_connection_id, const uint8_t *dht_public_key) -{ - Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); - - if (conn == 0) - return -1; + memcpy(conn->dht_public_key, dht_public_key, crypto_box_PUBLICKEYBYTES); - if (conn->dht_public_key_set == 1 && memcmp(conn->dht_public_key, dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) - return -1; + conn->cookie_request_number = random_64b(); + uint8_t cookie_request[COOKIE_REQUEST_LENGTH]; - if (conn->dht_public_key_set == 1) { + if (create_cookie_request(c, cookie_request, conn->dht_public_key, conn->cookie_request_number, + conn->shared_key) != sizeof(cookie_request) + || new_temp_packet(c, crypt_connection_id, cookie_request, sizeof(cookie_request)) != 0) { pthread_mutex_lock(&c->tcp_mutex); kill_tcp_connection_to(c->tcp_c, conn->connection_number_tcp); pthread_mutex_unlock(&c->tcp_mutex); - conn->connection_number_tcp = -1; + conn->status = CRYPTO_CONN_NO_CONNECTION; + return -1; } - memcpy(conn->dht_public_key, dht_public_key, crypto_box_PUBLICKEYBYTES); - conn->dht_public_key_set = 1; - - if (conn->status == CRYPTO_CONN_COOKIE_REQUESTING) { - conn->cookie_request_number = random_64b(); - uint8_t cookie_request[COOKIE_REQUEST_LENGTH]; - - if (create_cookie_request(c, cookie_request, conn->dht_public_key, conn->cookie_request_number, - conn->shared_key) != sizeof(cookie_request)) - return -1; - - if (new_temp_packet(c, crypt_connection_id, cookie_request, sizeof(cookie_request)) != 0) - return -1; - }//TODO - - pthread_mutex_lock(&c->tcp_mutex); - conn->connection_number_tcp = new_tcp_connection_to(c->tcp_c, conn->dht_public_key, crypt_connection_id); - pthread_mutex_unlock(&c->tcp_mutex); - return 0; + return crypt_connection_id; } /* Set the direct ip of the crypto connection. @@ -1899,8 +1864,10 @@ int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id, } -/* Set the function for this friend that will be callbacked with object and number - * when that friend gives us his DHT temporary public key. +/* Set the function for this friend that will be callbacked with object and number if + * the friend sends us a different dht public key than we have associated to him. + * + * If this function is called, the connection should be recreated with the new public key. * * object and number will be passed as argument to this function. * @@ -2391,7 +2358,7 @@ static void kill_timedout(Net_Crypto *c) if (conn == 0) return; - if (conn->status == CRYPTO_CONN_NO_CONNECTION || conn->status == CRYPTO_CONN_TIMED_OUT) + if (conn->status == CRYPTO_CONN_NO_CONNECTION) continue; if (conn->status == CRYPTO_CONN_COOKIE_REQUESTING || conn->status == CRYPTO_CONN_HANDSHAKE_SENT @@ -2399,19 +2366,8 @@ static void kill_timedout(Net_Crypto *c) if (conn->temp_packet_num_sent < MAX_NUM_SENDPACKET_TRIES) continue; - conn->killed = 1; - - } + connection_kill(c, i); - if (conn->killed) { - if (conn->connection_status_callback) { - conn->connection_status_callback(conn->connection_status_callback_object, conn->connection_status_callback_id, 0); - crypto_kill(c, i); - continue; - } - - conn->status = CRYPTO_CONN_TIMED_OUT; - continue; } if (conn->status == CRYPTO_CONN_ESTABLISHED) { diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index c525c0c5..f6dd4702 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -34,7 +34,6 @@ #define CRYPTO_CONN_HANDSHAKE_SENT 2 //send handshake packets #define CRYPTO_CONN_NOT_CONFIRMED 3 //send handshake packets, we have received one from the other #define CRYPTO_CONN_ESTABLISHED 4 -#define CRYPTO_CONN_TIMED_OUT 5 /* Maximum size of receiving and sending packet buffers. */ #define CRYPTO_PACKET_BUFFER_SIZE 16384 /* Must be a power of 2 */ @@ -107,11 +106,9 @@ typedef struct { * 2 if we are sending handshake packets * 3 if connection is not confirmed yet (we have received a handshake but no data packets yet), * 4 if the connection is established. - * 5 if the connection is timed out. */ uint64_t cookie_request_number; /* number used in the cookie request packets for this connection */ uint8_t dht_public_key[crypto_box_PUBLICKEYBYTES]; /* The dht public key of the peer */ - uint8_t dht_public_key_set; /* True if the dht public key is set, false if it isn't. */ uint8_t *temp_packet; /* Where the cookie request/handshake packet is stored while it is being sent. */ uint16_t temp_packet_length; @@ -150,8 +147,6 @@ typedef struct { long signed int last_num_packets_sent[CONGESTION_QUEUE_ARRAY_SIZE]; uint32_t packets_sent; - uint8_t killed; /* set to 1 to kill the connection. */ - /* TCP_connection connection_number */ unsigned int connection_number_tcp; @@ -225,21 +220,7 @@ int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c); * return -1 on failure. * return connection id on success. */ -int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key); - -/* Copy friends DHT public key into dht_key. - * - * return 0 on failure (no key copied). - * return 1 on success (key copied). - */ -unsigned int get_connection_dht_key(const Net_Crypto *c, int crypt_connection_id, uint8_t *dht_public_key); - -/* Set the DHT public key of the crypto connection. - * - * return -1 on failure. - * return 0 on success. - */ -int set_connection_dht_public_key(Net_Crypto *c, int crypt_connection_id, const uint8_t *dht_public_key); +int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key, const uint8_t *dht_public_key); /* Set the direct ip of the crypto connection. * @@ -285,8 +266,10 @@ int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id, int (*connection_lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length), void *object, int id); -/* Set the function for this friend that will be callbacked with object and number - * when that friend gives us his DHT temporary public key. +/* Set the function for this friend that will be callbacked with object and number if + * the friend sends us a different dht public key than we have associated to him. + * + * If this function is called, the connection should be recreated with the new public key. * * object and number will be passed as argument to this function. * -- cgit v1.2.3 From 3bd4f5902cb4dd4301ba9a8433f073fe31d6d2b5 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 21 Apr 2015 20:12:24 -0400 Subject: Move the send tcp relay packet from Messenger to friend connection. --- toxcore/Messenger.c | 52 ------------------------------------ toxcore/Messenger.h | 10 +------ toxcore/friend_connection.c | 64 +++++++++++++++++++++++++++++++++++++++++---- toxcore/friend_connection.h | 9 +++++++ 4 files changed, 69 insertions(+), 66 deletions(-) (limited to 'toxcore/friend_connection.c') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 1c9510ab..efb66961 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -749,37 +749,6 @@ static int send_user_istyping(const Messenger *m, int32_t friendnumber, uint8_t return write_cryptpacket_id(m, friendnumber, PACKET_ID_TYPING, &typing, sizeof(typing), 0); } -static int send_relays(const Messenger *m, int32_t friendnumber) -{ - if (friend_not_valid(m, friendnumber)) - return 0; - - Node_format nodes[MAX_SHARED_RELAYS]; - uint8_t data[1024]; - int n, length; - - n = copy_connected_tcp_relays(m->net_crypto, nodes, MAX_SHARED_RELAYS); - - unsigned int i; - - for (i = 0; i < n; ++i) { - /* Associated the relays being sent with this connection. - On receiving the peer will do the same which will establish the connection. */ - friend_add_tcp_relay(m->fr_c, m->friendlist[friendnumber].friendcon_id, nodes[i].ip_port, nodes[i].public_key); - } - - length = pack_nodes(data, sizeof(data), nodes, n); - - int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_SHARE_RELAYS, data, length, 0); - - if (ret == 1) - m->friendlist[friendnumber].share_relays_lastsent = unix_time(); - - return ret; -} - - - static int set_friend_statusmessage(const Messenger *m, int32_t friendnumber, const uint8_t *status, uint16_t length) { if (friend_not_valid(m, friendnumber)) @@ -1922,7 +1891,6 @@ static int handle_status(void *object, int i, uint8_t status) m->friendlist[i].userstatus_sent = 0; m->friendlist[i].statusmessage_sent = 0; m->friendlist[i].user_istyping_sent = 0; - m->friendlist[i].share_relays_lastsent = 0; } else { /* Went offline. */ if (m->friendlist[i].status == FRIEND_ONLINE) { set_friend_status(m, i, FRIEND_CONFIRMED); @@ -2187,22 +2155,6 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len) break; } - case PACKET_ID_SHARE_RELAYS: { - Node_format nodes[MAX_SHARED_RELAYS]; - int n; - - if ((n = unpack_nodes(nodes, MAX_SHARED_RELAYS, NULL, data, data_length, 1)) == -1) - break; - - int j; - - for (j = 0; j < n; j++) { - friend_add_tcp_relay(m->fr_c, m->friendlist[i].friendcon_id, nodes[j].ip_port, nodes[j].public_key); - } - - break; - } - default: { handle_custom_lossless_packet(object, i, temp, len); break; @@ -2260,10 +2212,6 @@ void do_friends(Messenger *m) m->friendlist[i].user_istyping_sent = 1; } - if (m->friendlist[i].share_relays_lastsent + FRIEND_SHARE_RELAYS_INTERVAL < temp_time) { - send_relays(m, i); - } - check_friend_tcp_udp(m, i); do_receipts(m, i); do_reqchunk_filecb(m, i); diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index e17bbb42..c9573639 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -42,8 +42,7 @@ enum { MESSAGE_ACTION }; -/* NOTE: Packet ids below 20 must never be used. */ -#define PACKET_ID_SHARE_RELAYS 23 +/* NOTE: Packet ids below 24 must never be used. */ #define PACKET_ID_ONLINE 24 #define PACKET_ID_OFFLINE 25 #define PACKET_ID_NICKNAME 48 @@ -62,9 +61,6 @@ enum { #define PACKET_ID_MESSAGE_GROUPCHAT 99 #define PACKET_ID_LOSSY_GROUPCHAT 199 -/* Max number of tcp relays sent to friends */ -#define MAX_SHARED_RELAYS (RECOMMENDED_FRIEND_TCP_CONNECTIONS) - /* All packets starting with a byte in this range can be used for anything. */ #define PACKET_ID_LOSSLESS_RANGE_START 160 #define PACKET_ID_LOSSLESS_RANGE_SIZE 32 @@ -110,9 +106,6 @@ enum { /* Default start timeout in seconds between friend requests. */ #define FRIENDREQUEST_TIMEOUT 5; -/* Interval between the sending of tcp relay information */ -#define FRIEND_SHARE_RELAYS_INTERVAL (5 * 60) - enum { CONNECTION_NONE, CONNECTION_TCP, @@ -199,7 +192,6 @@ typedef struct { uint32_t message_id; // a semi-unique id used in read receipts. uint32_t friendrequest_nospam; // The nospam number used in the friend request. uint64_t last_seen_time; - uint64_t share_relays_lastsent; uint8_t last_connection_udp_tcp; struct File_Transfers file_sending[MAX_CONCURRENT_FILE_PIPES]; unsigned int num_sending_files; diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 0f171100..892048ad 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -198,6 +198,43 @@ static void connect_to_saved_tcp_relays(Friend_Connections *fr_c, int friendcon_ } } +static unsigned int send_relays(Friend_Connections *fr_c, int friendcon_id) +{ + Friend_Conn *friend_con = get_conn(fr_c, friendcon_id); + + if (!friend_con) + return 0; + + Node_format nodes[MAX_SHARED_RELAYS]; + uint8_t data[1024]; + int n, length; + + n = copy_connected_tcp_relays(fr_c->net_crypto, nodes, MAX_SHARED_RELAYS); + + unsigned int i; + + for (i = 0; i < n; ++i) { + /* Associated the relays being sent with this connection. + On receiving the peer will do the same which will establish the connection. */ + friend_add_tcp_relay(fr_c, friendcon_id, nodes[i].ip_port, nodes[i].public_key); + } + + length = pack_nodes(data + 1, sizeof(data) - 1, nodes, n); + + if (length <= 0) + return 0; + + data[0] = PACKET_ID_SHARE_RELAYS; + ++length; + + if (write_cryptpacket(fr_c->net_crypto, friend_con->crypt_connection_id, data, length, 0) != -1) { + friend_con->share_relays_lastsent = unix_time(); + return 1; + } + + return 0; +} + /* callback for recv TCP relay nodes. */ static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_port, const uint8_t *public_key) { @@ -293,6 +330,7 @@ static int handle_status(void *object, int number, uint8_t status) call_cb = 1; friend_con->status = FRIENDCONN_STATUS_CONNECTED; friend_con->ping_lastrecv = unix_time(); + friend_con->share_relays_lastsent = 0; onion_set_friend_online(fr_c->onion_c, friend_con->onion_friendnum, status); } else { /* Went offline. */ if (friend_con->status != FRIENDCONN_STATUS_CONNECTING) { @@ -326,18 +364,30 @@ static int handle_packet(void *object, int number, uint8_t *data, uint16_t lengt Friend_Connections *fr_c = object; Friend_Conn *friend_con = get_conn(fr_c, number); + if (!friend_con) + return -1; + if (data[0] == PACKET_ID_FRIEND_REQUESTS) { if (fr_c->fr_request_callback) fr_c->fr_request_callback(fr_c->fr_request_object, friend_con->real_public_key, data, length); return 0; - } + } else if (data[0] == PACKET_ID_ALIVE) { + friend_con->ping_lastrecv = unix_time(); + return 0; + } else if (data[0] == PACKET_ID_SHARE_RELAYS) { + Node_format nodes[MAX_SHARED_RELAYS]; + int n; - if (!friend_con) - return -1; + if ((n = unpack_nodes(nodes, MAX_SHARED_RELAYS, NULL, data + 1, length - 1, 1)) == -1) + return -1; + + int j; + + for (j = 0; j < n; j++) { + friend_add_tcp_relay(fr_c, number, nodes[j].ip_port, nodes[j].public_key); + } - if (data[0] == PACKET_ID_ALIVE) { - friend_con->ping_lastrecv = unix_time(); return 0; } @@ -745,6 +795,10 @@ void do_friend_connections(Friend_Connections *fr_c) send_ping(fr_c, i); } + if (friend_con->share_relays_lastsent + SHARE_RELAYS_INTERVAL < temp_time) { + send_relays(fr_c, i); + } + if (friend_con->ping_lastrecv + FRIEND_CONNECTION_TIMEOUT < temp_time) { /* If we stopped receiving ping packets, kill it. */ crypto_kill(fr_c->net_crypto, friend_con->crypt_connection_id); diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index 641d2872..60b62646 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h @@ -36,6 +36,7 @@ #define GROUPCHAT_CALLBACK_INDEX 1 #define PACKET_ID_ALIVE 16 +#define PACKET_ID_SHARE_RELAYS 17 #define PACKET_ID_FRIEND_REQUESTS 18 /* Interval between the sending of ping packets. */ @@ -49,6 +50,13 @@ #define FRIEND_MAX_STORED_TCP_RELAYS (MAX_FRIEND_TCP_CONNECTIONS * 4) +/* Max number of tcp relays sent to friends */ +#define MAX_SHARED_RELAYS (RECOMMENDED_FRIEND_TCP_CONNECTIONS) + +/* Interval between the sending of tcp relay information */ +#define SHARE_RELAYS_INTERVAL (5 * 60) + + enum { FRIENDCONN_STATUS_NONE, FRIENDCONN_STATUS_CONNECTING, @@ -68,6 +76,7 @@ typedef struct { int crypt_connection_id; uint64_t ping_lastrecv, ping_lastsent; + uint64_t share_relays_lastsent; struct { int (*status_callback)(void *object, int id, uint8_t status); -- cgit v1.2.3 From 6a1efc32e635a86b0d848d058ba152403c49bec2 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sun, 26 Apr 2015 12:19:13 -0400 Subject: Fixed one case of the connection callback not getting called on reconnection. --- toxcore/friend_connection.c | 49 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'toxcore/friend_connection.c') diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 892048ad..5182ce28 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -292,30 +292,6 @@ static void change_dht_pk(Friend_Connections *fr_c, int friendcon_id, const uint memcpy(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES); } -/* Callback for dht public key changes. */ -static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) -{ - Friend_Connections *fr_c = object; - Friend_Conn *friend_con = get_conn(fr_c, number); - - if (!friend_con) - return; - - if (memcmp(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) - return; - - change_dht_pk(fr_c, number, dht_public_key); - - /* if pk changed, create a new connection.*/ - if (friend_con->crypt_connection_id != -1) { - crypto_kill(fr_c->net_crypto, friend_con->crypt_connection_id); - friend_con->crypt_connection_id = -1; - } - - friend_new_connection(fr_c, number); - onion_set_friend_DHT_pubkey(fr_c->onion_c, friend_con->onion_friendnum, dht_public_key); -} - static int handle_status(void *object, int number, uint8_t status) { Friend_Connections *fr_c = object; @@ -356,6 +332,31 @@ static int handle_status(void *object, int number, uint8_t status) return 0; } +/* Callback for dht public key changes. */ +static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) +{ + Friend_Connections *fr_c = object; + Friend_Conn *friend_con = get_conn(fr_c, number); + + if (!friend_con) + return; + + if (memcmp(friend_con->dht_temp_pk, dht_public_key, crypto_box_PUBLICKEYBYTES) == 0) + return; + + change_dht_pk(fr_c, number, dht_public_key); + + /* if pk changed, create a new connection.*/ + if (friend_con->crypt_connection_id != -1) { + crypto_kill(fr_c->net_crypto, friend_con->crypt_connection_id); + friend_con->crypt_connection_id = -1; + handle_status(object, number, 0); /* Going offline. */ + } + + friend_new_connection(fr_c, number); + onion_set_friend_DHT_pubkey(fr_c->onion_c, friend_con->onion_friendnum, dht_public_key); +} + static int handle_packet(void *object, int number, uint8_t *data, uint16_t length) { if (length == 0) -- cgit v1.2.3 From 69e3e5f3a4510e4883edecc78b5556d38cb61318 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Mon, 27 Apr 2015 16:13:04 -0400 Subject: Move LAN discovery from Messenger to friend_connection. --- toxcore/LAN_discovery.c | 5 +++++ toxcore/LAN_discovery.h | 3 +++ toxcore/Messenger.c | 11 ----------- toxcore/Messenger.h | 2 -- toxcore/friend_connection.c | 13 +++++++++++++ toxcore/friend_connection.h | 2 ++ 6 files changed, 23 insertions(+), 13 deletions(-) (limited to 'toxcore/friend_connection.c') diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index bc020d87..dbce762e 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c @@ -336,3 +336,8 @@ void LANdiscovery_init(DHT *dht) { networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, &handle_LANdiscovery, dht); } + +void LANdiscovery_kill(DHT *dht) +{ + networking_registerhandler(dht->net, NET_PACKET_LAN_DISCOVERY, NULL, NULL); +} diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h index 5dffc3ad..5243bd93 100644 --- a/toxcore/LAN_discovery.h +++ b/toxcore/LAN_discovery.h @@ -37,6 +37,9 @@ int send_LANdiscovery(uint16_t port, DHT *dht); /* Sets up packet handlers. */ void LANdiscovery_init(DHT *dht); +/* Clear packet handlers. */ +void LANdiscovery_kill(DHT *dht); + /* checks if a given IP isn't routable * * return 0 if ip is a LAN ip. diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index fd17ab98..a7e0a9fe 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1765,15 +1765,6 @@ static int friend_already_added(const uint8_t *real_pk, void *data) return -1; } -/* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */ -static void LANdiscovery(Messenger *m) -{ - if (m->last_LANdiscovery + LAN_DISCOVERY_INTERVAL < unix_time()) { - send_LANdiscovery(htons(TOX_PORT_DEFAULT), m->dht); - m->last_LANdiscovery = unix_time(); - } -} - /* Run this at startup. */ Messenger *new_messenger(Messenger_Options *options, unsigned int *error) { @@ -1842,7 +1833,6 @@ Messenger *new_messenger(Messenger_Options *options, unsigned int *error) m->options = *options; friendreq_init(&(m->fr), m->fr_c); - LANdiscovery_init(m->dht); set_nospam(&(m->fr), random_int()); set_filter_function(&(m->fr), &friend_already_added, m); @@ -2308,7 +2298,6 @@ void do_messenger(Messenger *m) do_onion_client(m->onion_c); do_friend_connections(m->fr_c); do_friends(m); - LANdiscovery(m); connection_status_cb(m); #ifdef LOGGING diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 5221e639..6943475f 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -234,8 +234,6 @@ struct Messenger { uint32_t numonline_friends; - uint64_t last_LANdiscovery; - #define NUM_SAVED_TCP_RELAYS 8 uint8_t has_added_relays; // If the first connection has occurred in do_messenger Node_format loaded_relays[NUM_SAVED_TCP_RELAYS]; // Relays loaded from config diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 5182ce28..c13ca949 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -758,10 +758,20 @@ Friend_Connections *new_friend_connections(Onion_Client *onion_c) temp->onion_c = onion_c; new_connection_handler(temp->net_crypto, &handle_new_connections, temp); + LANdiscovery_init(temp->dht); return temp; } +/* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */ +static void LANdiscovery(Friend_Connections *fr_c) +{ + if (fr_c->last_LANdiscovery + LAN_DISCOVERY_INTERVAL < unix_time()) { + send_LANdiscovery(htons(TOX_PORT_DEFAULT), fr_c->dht); + fr_c->last_LANdiscovery = unix_time(); + } +} + /* main friend_connections loop. */ void do_friend_connections(Friend_Connections *fr_c) { @@ -809,6 +819,8 @@ void do_friend_connections(Friend_Connections *fr_c) } } } + + LANdiscovery(fr_c); } /* Free everything related with friend_connections. */ @@ -823,5 +835,6 @@ void kill_friend_connections(Friend_Connections *fr_c) kill_friend_connection(fr_c, i); } + LANdiscovery_kill(fr_c->dht); free(fr_c); } diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index 60b62646..baca4b76 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h @@ -109,6 +109,8 @@ typedef struct { int (*fr_request_callback)(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len); void *fr_request_object; + + uint64_t last_LANdiscovery; } Friend_Connections; /* return friendcon_id corresponding to the real public key on success. -- cgit v1.2.3