Merge pull request #99 from C4K3/show-addresses-option
authorFelix Morgner <felix.morgner@gmail.com>
Sat, 26 Nov 2016 10:57:51 +0000 (11:57 +0100)
committerFelix Morgner <felix.morgner@gmail.com>
Sat, 26 Nov 2016 10:57:51 +0000 (11:57 +0100)
src/conf.c
src/conf.h
src/messagehandler.c
umurmur.conf.example

index bf21d99bb84cbe41f00caad5d82d34b07a789505..557e0f86b18fc9b9e096ecf50de741321a1055a7 100644 (file)
@@ -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);
        }
index 9a9591c22f2c3ff553265699506b24a98adfa539..5f028d0e4debc0b635858fb6dc937f34bdfa23c4 100644 (file)
@@ -57,6 +57,7 @@ typedef enum param {
        BANFILE,
        SYNC_BANFILE,
        OPUS_THRESHOLD,
+       SHOW_ADDRESSES,
 } param_t;
 
 typedef struct {
index a8472871ae86f38ad5c391266eedb2053c11e974..c9dad4a57b6858515cce1a42039617bf7e368c8b 100644 (file)
@@ -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;
index 8dbc18b3e5bb2a4097b7bbe4a81d64ebc5f9bb7c..1c32a7887016942a8c89472bcddf9bf7f31415c1 100644 (file)
@@ -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;