From a0a47e4deac74cae8426db35d19b6911ea3d8794 Mon Sep 17 00:00:00 2001 From: Sebastian Blunt Date: Wed, 16 Nov 2016 21:44:22 +0100 Subject: [PATCH] Add show-addresses option, to optionally hide user's IP addresses Currently IP addresses of every connected user are visible to everybody through the user information dialog. This adds an option of whether or not to show them, if set to true (default) then everything will be as before, whereas with false they will not be shown to anybody. IP addresses will still be logged in log messages and so forth. Fixes #81. --- src/conf.c | 7 +++++++ src/conf.h | 1 + src/messagehandler.c | 26 +++++++++++++++----------- umurmur.conf.example | 1 + 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/conf.c b/src/conf.c index bf21d99..557e0f8 100644 --- a/src/conf.c +++ b/src/conf.c @@ -320,6 +320,13 @@ bool_t getBoolConf(param_t param) else return config_setting_get_bool(setting); break; + case SHOW_ADDRESSES: + setting = config_lookup(&configuration, "show_addresses"); + if (!setting) + return true; + else + return config_setting_get_bool(setting); + break; default: doAssert(false); } diff --git a/src/conf.h b/src/conf.h index 9a9591c..5f028d0 100644 --- a/src/conf.h +++ b/src/conf.h @@ -57,6 +57,7 @@ typedef enum param { BANFILE, SYNC_BANFILE, OPUS_THRESHOLD, + SHOW_ADDRESSES, } param_t; typedef struct { diff --git a/src/messagehandler.c b/src/messagehandler.c index a847287..c9dad4a 100644 --- a/src/messagehandler.c +++ b/src/messagehandler.c @@ -870,17 +870,21 @@ void Mh_handle_message(client_t *client, message_t *msg) sendmsg->payload.userStats->opus = target->bOpus; /* Address */ - sendmsg->payload.userStats->has_address = true; - sendmsg->payload.userStats->address.data - = Memory_safeMalloc(16, sizeof(uint8_t)); - memset(sendmsg->payload.userStats->address.data, 0, 16); - /* ipv4 representation as ipv6 address. Supposedly correct. */ - memset(&sendmsg->payload.userStats->address.data[10], 0xff, 2); /* IPv4 */ - if(target->remote_tcp.ss_family == AF_INET) - memcpy(&sendmsg->payload.userStats->address.data[12], &((struct sockaddr_in*)&target->remote_tcp)->sin_addr, 4); - else - memcpy(&sendmsg->payload.userStats->address.data[0], &((struct sockaddr_in6*)&target->remote_tcp)->sin6_addr, 16); - sendmsg->payload.userStats->address.len = 16; + if (getBoolConf(SHOW_ADDRESSES)) { + sendmsg->payload.userStats->has_address = true; + sendmsg->payload.userStats->address.data + = Memory_safeMalloc(16, sizeof(uint8_t)); + memset(sendmsg->payload.userStats->address.data, 0, 16); + /* ipv4 representation as ipv6 address. Supposedly correct. */ + memset(&sendmsg->payload.userStats->address.data[10], 0xff, 2); /* IPv4 */ + if(target->remote_tcp.ss_family == AF_INET) + memcpy(&sendmsg->payload.userStats->address.data[12], &((struct sockaddr_in*)&target->remote_tcp)->sin_addr, 4); + else + memcpy(&sendmsg->payload.userStats->address.data[0], &((struct sockaddr_in6*)&target->remote_tcp)->sin6_addr, 16); + sendmsg->payload.userStats->address.len = 16; + } else { + sendmsg->payload.userStats->has_address = false; + } } /* BW */ sendmsg->payload.userStats->has_bandwidth = true; diff --git a/umurmur.conf.example b/umurmur.conf.example index 8dbc18b..1c32a78 100644 --- a/umurmur.conf.example +++ b/umurmur.conf.example @@ -10,6 +10,7 @@ password = ""; # sync_banfile = false; # Keep banfile synced. Default is false, which means it is saved to at shutdown only. # allow_textmessage = true; # Default is true # opus_threshold = 100; # Percentage of users supporting Opus codec for it to be chosen. Default is 100. +# show_addresses = true; # Whether to show client's IP addresses under user information max_users = 10; # bindport = 64738; -- 2.30.2