Skip to content

Commit 710a9b6

Browse files
committed
Add IP address to group whois info
When you do a /whois on a group peer you now see their real IP address listed with the rest of their info. If they aren't accepting direct connections then you will see a placeholder value indicating as much. If you /whois yourself, you'll see either your own IP address or a placeholder value, depending on whether or not you're accepting direct connections.
1 parent 94f868a commit 710a9b6

File tree

6 files changed

+48
-12
lines changed

6 files changed

+48
-12
lines changed

Diff for: INSTALL.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ Run `make doc` in the build directory after editing the asciidoc files to regene
6161
* `DISABLE_GAMES=1` → Disable support for games
6262
* `ENABLE_PYTHON=1` → Build toxic with Python scripting support
6363
* `ENABLE_RELEASE=1` → Build toxic without debug symbols and with full compiler optimizations
64-
* `ENABLE_ASAN=1` → Build toxic with LLVM Address Sanitizer enabled
64+
* `ENABLE_ASAN=1` → Build toxic with LLVM Address Sanitizer enabled (reduces performance but increases security)
65+
* `ENABLE_TOX_EXPERIMENTAL=1` → Build with support for Tox's experimental API functionality
6566

6667
* `DESTDIR=""` Specifies the base install directory for binaries and data files (e.g.: DESTDIR="/tmp/build/pkg")
6768

Diff for: cfg/checks/check_features.mk

+11-5
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,42 @@ ifneq ($(GAMES), disabled)
2828
-include $(CHECKS_DIR)/games.mk
2929
endif
3030

31-
# Check if we want build sound notifications support
31+
# Check if we want to build with sound notifications support
3232
SND_NOTIFY := $(shell if [ -z "$(DISABLE_SOUND_NOTIFY)" ] || [ "$(DISABLE_SOUND_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
3333
ifneq ($(SND_NOTIFY), disabled)
3434
-include $(CHECKS_DIR)/sound_notifications.mk
3535
endif
3636

37-
# Check if we want build desktop notifications support
37+
# Check if we want to build with desktop notifications support
3838
DESK_NOTIFY := $(shell if [ -z "$(DISABLE_DESKTOP_NOTIFY)" ] || [ "$(DISABLE_DESKTOP_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
3939
ifneq ($(DESK_NOTIFY), disabled)
4040
-include $(CHECKS_DIR)/desktop_notifications.mk
4141
endif
4242

43-
# Check if we want build QR export support
43+
# Check if we want to build with QR export support
4444
QR_CODE := $(shell if [ -z "$(DISABLE_QRCODE)" ] || [ "$(DISABLE_QRCODE)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
4545
ifneq ($(QR_CODE), disabled)
4646
-include $(CHECKS_DIR)/qr.mk
4747
endif
4848

49-
# Check if we want build QR exported as PNG support
49+
# Check if we want to build with QR exported as PNG support
5050
QR_PNG := $(shell if [ -z "$(DISABLE_QRPNG)" ] || [ "$(DISABLE_QRPNG)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
5151
ifneq ($(QR_PNG), disabled)
5252
-include $(CHECKS_DIR)/qr_png.mk
5353
endif
5454

55-
# Check if we want build Python scripting support
55+
# Check if we want to build with Python scripting support
5656
PYTHON := $(shell if [ -z "$(ENABLE_PYTHON)" ] || [ "$(ENABLE_PYTHON)" = "0" ] ; then echo disabled ; else echo enabled ; fi)
5757
ifneq ($(PYTHON), disabled)
5858
-include $(CHECKS_DIR)/python.mk
5959
endif
6060

61+
# Check if we want to build with tox experimental libaries
62+
TOX_EXPERIMENTAL := $(shell if [ -z "$(ENABLE_TOX_EXPERIMENTAL)" ] || [ "$(ENABLE_TOX_EXPERIMENTAL)" = "0" ] ; then echo disabled; else echo enabled; fi)
63+
ifneq ($(TOX_EXPERIMENTAL), disabled)
64+
-include $(CHECKS_DIR)/tox_experimental.mk
65+
endif
66+
6167
# Check if we can build Toxic
6268
CHECK_LIBS := $(shell $(PKG_CONFIG) --exists $(LIBS) || echo -n "error")
6369
ifneq ($(CHECK_LIBS), error)

Diff for: cfg/checks/tox_experimental.mk

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Variables for supporting Tox's experimental API functionality
2+
TOX_EXPERIMENTAL_CFLAGS = -DTOX_EXPERIMENTAL
3+
CFLAGS += $(TOX_EXPERIMENTAL_CFLAGS)

Diff for: script/build-minimal-static-toxic.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ mkdir -p "$BUILD_DIR"
136136
cd "$BUILD_DIR"
137137

138138
# The git hash of the c-toxcore version we're using
139-
TOXCORE_VERSION="172f279dc0647a538b30e62c96bab8bb1b0c8960"
139+
TOXCORE_VERSION="b2315c50e0838687cd328838f1475be095b358f4"
140140

141141
# The sha256sum of the c-toxcore tarball for TOXCORE_VERSION
142-
TOXCORE_HASH="9884d4ad9b80917e22495c2ebe7a76c509fb98c61031824562883225e66684ae"
142+
TOXCORE_HASH="acad3fee6cb88fc2c9b2f17e06cb788467477a7a336475c2fcc8f35e54a3248d"
143143

144144
TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz"
145145

@@ -237,6 +237,7 @@ CFLAGS="-static" PKG_CONFIG_PATH="$BUILD_DIR/prefix-toxcore/lib64/pkgconfig:$BUI
237237
ENABLE_RELEASE=1 \
238238
ENABLE_ASAN=0 \
239239
DISABLE_GAMES=0 \
240+
ENABLE_TOX_EXPERIMENTAL=1 \
240241
install
241242

242243

Diff for: src/groupchat_commands.c

+25-4
Original file line numberDiff line numberDiff line change
@@ -922,20 +922,41 @@ void cmd_whois(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
922922
strcat(pk_string, d);
923923
}
924924

925-
Tox_Err_Group_Peer_Query conn_err;
926-
Tox_Connection connection_type = tox_group_peer_get_connection_status(m, self->num, peer_id, &conn_err);
925+
Tox_Err_Group_Peer_Query err;
926+
Tox_Connection connection_type = tox_group_peer_get_connection_status(m, self->num, peer_id, &err);
927927

928-
const char *connection_type_str = "Unknown";
928+
const char *connection_type_str = "-";
929929

930-
if (conn_err == TOX_ERR_GROUP_PEER_QUERY_OK || connection_type != TOX_CONNECTION_NONE) {
930+
if (err == TOX_ERR_GROUP_PEER_QUERY_OK || connection_type != TOX_CONNECTION_NONE) {
931931
connection_type_str = connection_type == TOX_CONNECTION_UDP ? "UDP" : "TCP";
932932
}
933933

934+
#ifdef TOX_EXPERIMENTAL
935+
char ip_addr[TOX_GROUP_PEER_IP_STRING_MAX_LENGTH] = {0};
936+
const bool ip_ret = tox_group_peer_get_ip_address(m, self->num, peer_id, (uint8_t *)ip_addr, &err);
937+
938+
if (!ip_ret) {
939+
snprintf(ip_addr, sizeof(ip_addr), "Error %d", err);
940+
} else {
941+
size_t ip_addr_len = tox_group_peer_get_ip_address_size(m, self->num, peer_id, &err);
942+
943+
if (err != TOX_ERR_GROUP_PEER_QUERY_OK) {
944+
snprintf(ip_addr, sizeof(ip_addr), "Error %d", err);
945+
} else {
946+
ip_addr[ip_addr_len] = '\0';
947+
}
948+
}
949+
950+
#endif // TOX_EXPERIMENTAL
951+
934952
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Public key: %s", pk_string);
935953
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Name: %s", peer->name);
936954
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Role: %s", role_str);
937955
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Status: %s", status_str);
938956
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Connection: %s", connection_type_str);
957+
#ifdef TOX_EXPERIMENTAL
958+
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "IP Address: %s", ip_addr);
959+
#endif
939960
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Last active: %s", last_seen_str);
940961
}
941962
}

Diff for: src/toxic.h

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444

4545
#include <tox/tox.h>
4646

47+
#ifdef TOX_EXPERIMENTAL
48+
#include <tox/tox_private.h>
49+
#endif
50+
4751
#define UNKNOWN_NAME "Anonymous"
4852
#define DEFAULT_TOX_NAME "Tox User" /* should always be the same as toxcore's default name */
4953

0 commit comments

Comments
 (0)