From 8d8e5a23a6a7841c239d2c87f9a3875a411192fc Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Tue, 7 Jun 2011 13:58:12 +0200 Subject: [PATCH] Mask remote party identity in SIP presence if channel var presence_privacy=true --- src/mod/endpoints/mod_sofia/sofia_presence.c | 8 ++++++-- src/switch_channel.c | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 6c7c0cf648..1d65a15081 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1571,8 +1571,12 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * stream.write_function(&stream, "\n", !strcasecmp(event_status, "hold") ? "no" : "yes"); stream.write_function(&stream, "\n\n"); - stream.write_function(&stream, "\nsip:%s@%s\n", clean_from_user, clean_from_user, - host); + if (switch_true(switch_event_get_header(helper->event, "Presence-Privacy"))) { + stream.write_function(&stream, "\nsip:anonymous@anonymous.invalid\n"); + } else { + stream.write_function(&stream, "\nsip:%s@%s\n", clean_from_user, clean_from_user, + host); + } stream.write_function(&stream, "\n", clean_to_user, host); stream.write_function(&stream, "\n"); } else if (!strcasecmp(proto, "park")) { diff --git a/src/switch_channel.c b/src/switch_channel.c index 01c2937470..ec01c22a52 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -626,6 +626,11 @@ SWITCH_DECLARE(void) switch_channel_perform_presence(switch_channel_t *channel, switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Calling-File", file); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Calling-Function", func); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Presence-Calling-Line", "%d", line); + + if (switch_true(switch_channel_get_variable(channel, "presence_privacy"))) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Privacy", "true"); + } + switch_event_fire(&event); } }