From 0a7ae5073d1e9e9abbaa07d17030b5d6cc118a62 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Tue, 18 Apr 2023 13:28:26 +0000 Subject: [PATCH] Feature: Report source's instance UUID when known --- src/event.c | 5 ++++- src/event.h | 3 ++- src/event_exec.c | 3 ++- src/event_url.c | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/event.c b/src/event.c index cf36b895..daa737bc 100644 --- a/src/event.c +++ b/src/event.c @@ -3,7 +3,7 @@ * This program is distributed under the GNU General Public License, version 2. * A copy of this license is included with this source. * - * Copyright 2014-2022, Philipp "ph3-der-loewe" Schafft , + * Copyright 2014-2023, Philipp "ph3-der-loewe" Schafft , */ /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */ @@ -94,6 +94,7 @@ const char * event_extra_key_name(event_extra_key_t key) case EVENT_EXTRA_KEY_CLIENT_USERNAME: return "client-username"; break; case EVENT_EXTRA_KEY_CLIENT_USERAGENT: return "client-useragent"; break; case EVENT_EXTRA_KEY_SOURCE_MEDIA_TYPE: return "source-media-type"; break; + case EVENT_EXTRA_KEY_SOURCE_INSTANCE_UUID: return "source-instance"; break; case EVENT_EXTRA_KEY_DUMPFILE_FILENAME: return "dumpfile-filename"; break; #ifndef DEVEL_LOGGING default: break; @@ -108,6 +109,7 @@ igloo_error_t event_to_string_renderer(const event_t *event, string_renderer_t * static const event_extra_key_t key_list[] = { EVENT_EXTRA_KEY_URI, EVENT_EXTRA_KEY_SOURCE_MEDIA_TYPE, + EVENT_EXTRA_KEY_SOURCE_INSTANCE_UUID, EVENT_EXTRA_KEY_CONNECTION_IP, EVENT_EXTRA_KEY_CLIENT_ROLE, EVENT_EXTRA_KEY_CLIENT_USERNAME, @@ -513,6 +515,7 @@ void event_emit_va(const char *trigger, ...) { if (source->format && source->format->contenttype) { extra_add(event, EVENT_EXTRA_KEY_SOURCE_MEDIA_TYPE, source->format->contenttype); } + extra_add(event, EVENT_EXTRA_KEY_SOURCE_INSTANCE_UUID, source->instance_uuid); } if (client) { diff --git a/src/event.h b/src/event.h index 9bbae1f2..9c4cc80e 100644 --- a/src/event.h +++ b/src/event.h @@ -3,7 +3,7 @@ * This program is distributed under the GNU General Public License, version 2. * A copy of this license is included with this source. * - * Copyright 2014-2022, Philipp "ph3-der-loewe" Schafft , + * Copyright 2014-2023, Philipp "ph3-der-loewe" Schafft , */ #ifndef __EVENT_H__ @@ -42,6 +42,7 @@ typedef enum { EVENT_EXTRA_KEY_CLIENT_USERNAME, EVENT_EXTRA_KEY_CLIENT_USERAGENT, EVENT_EXTRA_KEY_SOURCE_MEDIA_TYPE, + EVENT_EXTRA_KEY_SOURCE_INSTANCE_UUID, EVENT_EXTRA_KEY_DUMPFILE_FILENAME, } event_extra_key_t; diff --git a/src/event_exec.c b/src/event_exec.c index 13e9f3ab..bef4edb2 100644 --- a/src/event_exec.c +++ b/src/event_exec.c @@ -3,7 +3,7 @@ * This program is distributed under the GNU General Public License, version 2. * A copy of this license is included with this source. * - * Copyright 2014-2022, Philipp "ph3-der-loewe" Schafft , + * Copyright 2014-2023, Philipp "ph3-der-loewe" Schafft , */ #ifdef HAVE_CONFIG_H @@ -154,6 +154,7 @@ static inline void __setup_environ(ice_config_t *config, event_exec_t *self, eve __update_environ("SOURCE_ACTION", event->trigger); /* old name (deprecated) */ __update_environ_with_key(event, "EVENT_URI", EVENT_EXTRA_KEY_URI); __update_environ_with_key(event, "SOURCE_MEDIA_TYPE", EVENT_EXTRA_KEY_SOURCE_MEDIA_TYPE); + __update_environ_with_key(event, "SOURCE_INSTANCE", EVENT_EXTRA_KEY_SOURCE_INSTANCE_UUID); __update_environ_with_key(event, "CLIENT_IP", EVENT_EXTRA_KEY_CONNECTION_IP); __update_environ_with_key(event, "CLIENT_ROLE", EVENT_EXTRA_KEY_CLIENT_ROLE); __update_environ_with_key(event, "CLIENT_USERNAME", EVENT_EXTRA_KEY_CLIENT_USERNAME); diff --git a/src/event_url.c b/src/event_url.c index 1e00729c..ab6368ff 100644 --- a/src/event_url.c +++ b/src/event_url.c @@ -3,7 +3,7 @@ * This program is distributed under the GNU General Public License, version 2. * A copy of this license is included with this source. * - * Copyright 2014-2022, Philipp "ph3-der-loewe" Schafft , + * Copyright 2014-2023, Philipp "ph3-der-loewe" Schafft , */ #ifdef HAVE_CONFIG_H @@ -59,6 +59,7 @@ static int event_url_emit(void *state, event_t *event) { string_renderer_add_kv_with_options(renderer, "role", event_extra_get(event, EVENT_EXTRA_KEY_CLIENT_ROLE), STRING_RENDERER_ENCODING_PLAIN, true, true); string_renderer_add_kv_with_options(renderer, "username", event_extra_get(event, EVENT_EXTRA_KEY_CLIENT_USERNAME), STRING_RENDERER_ENCODING_PLAIN, true, true); string_renderer_add_kv_with_options(renderer, "ip", event_extra_get(event, EVENT_EXTRA_KEY_CONNECTION_IP), STRING_RENDERER_ENCODING_PLAIN, true, true); + string_renderer_add_kv_with_options(renderer, "source-instance", event_extra_get(event, EVENT_EXTRA_KEY_SOURCE_INSTANCE_UUID), STRING_RENDERER_ENCODING_PLAIN, true, true); string_renderer_add_kv_with_options(renderer, "agent", event_extra_get(event, EVENT_EXTRA_KEY_CLIENT_USERAGENT) ? event_extra_get(event, EVENT_EXTRA_KEY_CLIENT_USERAGENT) : "-", STRING_RENDERER_ENCODING_PLAIN, true, true); string_renderer_add_ki_with_options(renderer, "duration", duration, STRING_RENDERER_ENCODING_PLAIN, true, true); string_renderer_add_ki_with_options(renderer, "admin", event->client_admin_command, STRING_RENDERER_ENCODING_PLAIN, true, true);