From 85179a274474871b5938568c2056c261e3b8127f Mon Sep 17 00:00:00 2001 From: zoff99 Date: Thu, 14 Mar 2024 19:14:52 +0100 Subject: [PATCH] show ip addresses for group peers --- jni-c-toxcore/jni-c-toxcore.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jni-c-toxcore/jni-c-toxcore.c b/jni-c-toxcore/jni-c-toxcore.c index 0cd425f16..3728296b5 100644 --- a/jni-c-toxcore/jni-c-toxcore.c +++ b/jni-c-toxcore/jni-c-toxcore.c @@ -7744,6 +7744,31 @@ Java_com_zoffcc_applications_trifa_MainActivity_tox_1group_1invite_1friend(JNIEn #endif } +JNIEXPORT jstring JNICALL +Java_com_zoffcc_applications_trifa_MainActivity_tox_1group_1get_1connection_1ip(JNIEnv *env, jobject thiz, + jlong group_number, jlong peer_id) +{ + if(tox_global == NULL) + { + return NULL; + } + +/* + const int ipv6_strlen_max = 39; + const int port_strlen_max = 5; + const int space_char_strlen_max = 1; + const int max_tcp_relays_per_friend = 6; + const int max_length = ((ipv6_strlen_max + space_char_strlen_max + port_strlen_max + 2) * max_tcp_relays_per_friend) + 10; +*/ +// compiler hates humanity, so its a define now. silly. +#define IP_STR_MAX_STR_LEN (((39 + 1 + 5 + 2) * 6) + 10) + char ip_str[IP_STR_MAX_STR_LEN + 1]; + CLEAR(ip_str); + tox_group_get_connection_ip(tox_global, (uint32_t)group_number, (uint32_t)peer_id, uint8_t *ip_str); + jstring js1 = c_safe_string_from_java((char *)ip_str, IP_STR_MAX_STR_LEN); + return js1; +} + JNIEXPORT jlong JNICALL Java_com_zoffcc_applications_trifa_MainActivity_tox_1group_1new(JNIEnv *env, jobject thiz, jint privacy_state, jobject group_name, jobject my_peer_name)