Skip to content

Commit 84ba154

Browse files
committed
group connection queries now return our own connection type
1 parent a4df286 commit 84ba154

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12972fcd956654a18e367e03d6bcaab12fbe2ae166dfc937474a7bd123e0910f /usr/local/bin/tox-bootstrapd
1+
2e1ae94d48eb1793ec3b42ed1516c53fb0b6b0e41bc89160e6037ee881a872b4 /usr/local/bin/tox-bootstrapd

toxcore/group_chats.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,8 +3510,8 @@ unsigned int gc_get_peer_connection_status(const GC_Chat *chat, uint32_t peer_id
35103510
{
35113511
const int peer_number = get_peer_number_of_peer_id(chat, peer_id);
35123512

3513-
if (peer_number_is_self(peer_number)) { // we cannot have a connection with ourselves
3514-
return 0;
3513+
if (peer_number_is_self(peer_number)) {
3514+
return chat->self_udp_status == SELF_UDP_STATUS_NONE ? 1 : 2;
35153515
}
35163516

35173517
const GC_Connection *gconn = get_gc_connection(chat, peer_number);

toxcore/group_chats.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,13 @@ non_null(1) nullable(3)
391391
int gc_get_peer_public_key_by_peer_id(const GC_Chat *chat, uint32_t peer_id, uint8_t *public_key);
392392

393393
/** @brief Gets the connection status for peer associated with `peer_id`.
394+
*
395+
* If `peer_id` designates ourself, the return value indicates whether we're capable
396+
* of making UDP connections with other peers, or are limited to TCP connections.
394397
*
395398
* Returns 2 if we have a direct (UDP) connection with a peer.
396399
* Returns 1 if we have an indirect (TCP) connection with a peer.
397-
* Returns 0 if peer_id is invalid or corresponds to ourselves.
400+
* Returns 0 if peer_id is invalid.
398401
*
399402
* Note: Return values must correspond to Tox_Connection enum in API.
400403
*/

toxcore/tox.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3967,7 +3967,8 @@ Tox_Group_Role tox_group_peer_get_role(const Tox *tox, uint32_t group_number, ui
39673967
/**
39683968
* Return the type of connection we have established with a peer.
39693969
*
3970-
* This function will return an error if called on ourselves.
3970+
* If `peer_id` designates ourself, the return value indicates whether we're capable
3971+
* of making UDP connections with other peers, or are limited to TCP connections.
39713972
*
39723973
* @param group_number The group number of the group we wish to query.
39733974
* @param peer_id The ID of the peer whose connection status we wish to query.

0 commit comments

Comments
 (0)