From af8418fb3ef6a457a99482e5201ae2c3032f2af2 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 23 May 2022 11:25:52 +0200 Subject: [PATCH] Add to JSON logging output, for users: "vhost" and "cloakedhost" Suggested by westor in https://bugs.unrealircd.org/view.php?id=6083 The "vhost" field is added if the visible host of the user differs from the real hostname, such as +x with cloaking or +xt with a vhost. The "cloakedhost" is always included, even if the user does not currently have a cloaked host at all (eg is -x or using a vhost). Both make it easier to search log files based on user reports. Eg a user mentions a vhost or cloaked host from their user logs and then a server admin searches the UnrealIRCd logs on this to retrieve the real host / ip / user based on that. --- src/log.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/log.c b/src/log.c index 46bfa6dc1..eef8f8c73 100644 --- a/src/log.c +++ b/src/log.c @@ -575,6 +575,10 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail) json_object_set_new(user, "username", json_string_unreal(client->user->username)); if (!BadPtr(client->info)) json_object_set_new(user, "realname", json_string_unreal(client->info)); + if (has_user_mode(client, 'x') && client->user->virthost && strcmp(client->user->virthost, client->user->realhost)) + json_object_set_new(user, "vhost", json_string_unreal(client->user->virthost)); + if (client->user->cloakedhost) + json_object_set_new(user, "cloakedhost", json_string_unreal(client->user->cloakedhost)); if (client->uplink) json_object_set_new(user, "servername", json_string_unreal(client->uplink->name)); if (IsLoggedIn(client))