diff options
author | Andrew Cady <d@jerkface.net> | 2020-08-20 17:10:12 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-08-20 17:27:10 -0400 |
commit | a45445e4883c7eeff4f6063ab50c25a983bbec61 (patch) | |
tree | 8717110330024354be7425b299d37bf20f196b59 | |
parent | ed93588e1476e5e75f7a18fd3eec56c5c3238a3c (diff) |
Implement logging of the remote friend IP address
This relies on a patched c-toxcore. For that reason, it is disabled by
an #ifdef.
-rw-r--r-- | main.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -921,11 +921,28 @@ void handle_connection_status_change(Tox *tox, TOX_CONNECTION p_connection_statu | |||
921 | log_printf(L_INFO, "Connection status changed: %s", status); | 921 | log_printf(L_INFO, "Connection status changed: %s", status); |
922 | } | 922 | } |
923 | 923 | ||
924 | #ifdef LOG_IP_ADDRESS | ||
925 | void log_friend_ip_address(Tox *tox, uint32_t friendnumber) | ||
926 | { | ||
927 | IP_Port ip_port = tox_friend_get_connection_info(tox, friendnumber); | ||
928 | if (net_family_is_unspec(ip_port.ip.family)) return; | ||
929 | char ip_str[IP_NTOA_LEN]; | ||
930 | log_printf(L_INFO, "Friend #%d: IP: %s Port: %u\n", | ||
931 | friendnumber, | ||
932 | ip_ntoa(&ip_port.ip, ip_str, sizeof(ip_str)), | ||
933 | net_ntohs(ip_port.port)); | ||
934 | } | ||
935 | #endif | ||
936 | |||
924 | void handle_friend_connection_status(Tox *tox, uint32_t friend_number, TOX_CONNECTION connection_status, void *user_data) | 937 | void handle_friend_connection_status(Tox *tox, uint32_t friend_number, TOX_CONNECTION connection_status, void *user_data) |
925 | { | 938 | { |
926 | const char *status = NULL; | 939 | const char *status = NULL; |
927 | status = readable_connection_status(connection_status); | 940 | status = readable_connection_status(connection_status); |
928 | log_printf(L_INFO, "Friend #%d connection status changed: %s", friend_number, status); | 941 | log_printf(L_INFO, "Friend #%d connection status changed: %s", friend_number, status); |
942 | #ifdef LOG_IP_ADDRESS | ||
943 | if(connection_status == TOX_CONNECTION_UDP) | ||
944 | log_friend_ip_address(tox, friend_number); | ||
945 | #endif | ||
929 | if(client_mode) | 946 | if(client_mode) |
930 | { | 947 | { |
931 | friend_connection_status = connection_status; | 948 | friend_connection_status = connection_status; |