From 51a531aaefe3c7c7f966da4a4fb035fec51a2875 Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Fri, 11 Mar 2011 12:40:56 -0500 Subject: [PATCH 1/3] mod_callcenter: Fix a bug when an caller leave the queue from a BREAK Call (Transfer...), it doesn't think an agent answered. --- src/mod/applications/mod_callcenter/mod_callcenter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 12e1960841..99e790db50 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -2302,7 +2302,7 @@ SWITCH_STANDARD_APP(callcenter_function) } /* Hangup any agents been callback */ - if (!switch_channel_up(member_channel)) { /* If channel is still up, it mean that the member didn't hangup, so we should leave the agent alone */ + if (!switch_channel_up(member_channel) || !switch_channel_get_variable(member_channel, "cc_agent_uuid")) { /* If channel is still up, it mean that the member didn't hangup, so we should leave the agent alone */ switch_core_session_hupall_matching_var("cc_member_uuid", member_uuid, SWITCH_CAUSE_ORIGINATOR_CANCEL); sql = switch_mprintf("UPDATE members SET state = '%q', uuid = '', abandoned_epoch = '%ld' WHERE system = 'single_box' AND uuid = '%q'", cc_member_state2str(CC_MEMBER_STATE_ABANDONED), (long) switch_epoch_time_now(NULL), member_uuid); From 6cd5ce7265ce2400dea3715aa0ac9aa3617df3b3 Mon Sep 17 00:00:00 2001 From: Michael S Collins Date: Fri, 11 Mar 2011 10:24:55 -0800 Subject: [PATCH 2/3] Add README_IMPORTANT.txt to default configuration --- conf/README_IMPORTANT.txt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 conf/README_IMPORTANT.txt diff --git a/conf/README_IMPORTANT.txt b/conf/README_IMPORTANT.txt new file mode 100644 index 0000000000..8d82b404f6 --- /dev/null +++ b/conf/README_IMPORTANT.txt @@ -0,0 +1,35 @@ + -= PLEASE READ THIS BEFORE YOU PUT A FreeSWITCH BOX INTO PRODUCTION =- + +This configuration, generally known as the "default configuration" for FreeSWITCH, is *NOT* designed to be put into a production environment without some important modifications. Please keep in mind that the default configuration is designed to demonstrate what FreeSWITCH *can* do, not what it *should* do in your specific scenario. + +*** SECURING YOUR SERVER *** + +By default, FreeSWITCH starts up and does a NATPMP and UPnP request to your router. If your router supports either of these protocols then FreeSWITCH does two things: +#1 - It gets the external IP address, which it uses for SIP communications +#2 - It causes there to be a "pinhole" opened up in the router allowing inbound communications to your FreeSWITCH server + +Please re-read #2. Now, please re-read #2 again. If you do not want a pinhole coming through your router then DO NOT USE the "auto-nat" tools. The way to disable the auto-nat (that is, UPnP/NATPMP) checking is to start FreeSWITCH with the "-nonat" flag. Easy enough. + +If you are planning on putting a system into production then you had better pay attention to security in other areas as well. If you are behind a firewall then make sure your firewall is actually protecting you. If you have your server on a public-facing Internet connection then we recommend a few things: +#1 - Consider using iptables (Linux/Unix) +#2 - Consider using fail2ban (see http://wiki.freeswitch.org/wiki/Fail2ban) + +*** SECURING YOUR USERS *** + +By default, the static XML files have 20 "directory users" in conf/directory/10xx.xml, numbered 1000-1019. Also, the default dialplan has routing for calls to those same extension numbers. (NOTE: the directory and the dialplan are 100% separate concepts. Check out chapters 3-5 of the awesome FreeSWITCH book for details.) + +The default users all have *very* simple passwords for SIP credentials and voicemail. If you put those into a production system then you are either brave, ignorant, or stupid. Please don't be any of those three things! You have a few choices for handling your users: + +#1 - Delete the static XML files and use mod_xml_curl for dynamic users from a back-end database +#2 - Manually edit the static XML user directory files and modify the passwords +#3 - Run the handy randomize-passwords.pl script found in scripts/perl/ subdirectory under the main FreeSWITCH source directory + +*** GETTING HELP *** + +FreeSWITCH has a thriving on-line community - we welcome you to join us! +IRC: #freeswitch on irc.freenode.net +Mailing List: freeswitch-users on lists.freeswitch.org + +You can also get professional FreeSWITCH assistance by visiting http://www.freeswitchsolutions.com or sending an email to consulting@freeswitch.org. + +Happy FreeSWITCHing! From 24a972925b851c39d4f39db5f536d12ef4118a8b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 11 Mar 2011 13:00:16 -0600 Subject: [PATCH 3/3] pass header in X-FS headers on attended transfer CID update to indicate specific situation to flip callee/caller id when targeting a 1 legged call --- src/include/switch_channel.h | 1 + src/include/switch_types.h | 2 ++ src/mod/endpoints/mod_sofia/mod_sofia.c | 11 +++++++ src/mod/endpoints/mod_sofia/sofia.c | 25 +++++++++++++-- src/switch_channel.c | 41 ++++++++++++++++--------- src/switch_ivr_originate.c | 2 ++ 6 files changed, 65 insertions(+), 17 deletions(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 25273bafc4..fdbbc9ab91 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -315,6 +315,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc */ SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension); +SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel, switch_bool_t in); /*! diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 4253d0e542..79494d8979 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1107,6 +1107,8 @@ typedef enum { CF_DIALPLAN, CF_BLOCK_BROADCAST_UNTIL_MEDIA, CF_CNG_PLC, + CF_ATTENDED_TRANSFER, + CF_LAZY_ATTENDED_TRANSFER, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CF_FLAG_MAX } switch_channel_flag_t; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 3bc5cc2231..f50e057d5f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1878,6 +1878,17 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) { snprintf(message, sizeof(message), "X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", name, number); + if (switch_channel_test_flag(tech_pvt->channel, CF_LAZY_ATTENDED_TRANSFER)) { + snprintf(message + strlen(message), sizeof(message) - strlen(message), "X-FS-Lazy-Attended-Transfer: true\n"); + switch_channel_clear_flag(tech_pvt->channel, CF_LAZY_ATTENDED_TRANSFER); + switch_channel_clear_flag(tech_pvt->channel, CF_ATTENDED_TRANSFER); + } + + if (switch_channel_test_flag(tech_pvt->channel, CF_ATTENDED_TRANSFER)) { + snprintf(message + strlen(message), sizeof(message) - strlen(message), "X-FS-Attended-Transfer: true\n"); + switch_channel_clear_flag(tech_pvt->channel, CF_ATTENDED_TRANSFER); + } + nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/update_display"), TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)), TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END()); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 761a03ce62..d612e30f0b 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -637,7 +637,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro char *dup = NULL; switch_event_t *event; const char *val; - int fs = 0; + int fs = 0, lazy = 0, att = 0; if (switch_true(switch_channel_get_variable(channel, SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE))) { return; @@ -656,6 +656,16 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro name = (char *) val; fs++; } + + if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Lazy-Attended-Transfer"))) { + lazy = switch_true(val); + fs++; + } + + if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Attended-Transfer"))) { + att = switch_true(val); + fs++; + } if (!fs) { if ((passerted = sip_p_asserted_identity(sip))) { @@ -727,6 +737,10 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro caller_profile->callee_id_name = switch_sanitize_number(switch_core_strdup(caller_profile->pool, name)); caller_profile->callee_id_number = switch_sanitize_number(switch_core_strdup(caller_profile->pool, number)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Update Callee ID to \"%s\" <%s>\n", switch_channel_get_name(channel), name, number); + + if (lazy || (att && !switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) { + switch_channel_flip_cid(channel); + } } if (send) { @@ -5717,9 +5731,14 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Attended Transfer [%s][%s]\n", switch_str_nil(br_a), switch_str_nil(br_b)); - if ((profile->media_options & MEDIA_OPT_BYPASS_AFTER_ATT_XFER) && (tmp = switch_core_session_locate(br_b))) { + if ((tmp = switch_core_session_locate(br_b))) { switch_channel_t *tchannel = switch_core_session_get_channel(tmp); - switch_channel_set_flag(tchannel, CF_BYPASS_MEDIA_AFTER_BRIDGE); + + if ((profile->media_options & MEDIA_OPT_BYPASS_AFTER_ATT_XFER)) { + switch_channel_set_flag(tchannel, CF_BYPASS_MEDIA_AFTER_BRIDGE); + } + + switch_channel_set_flag(tchannel, CF_ATTENDED_TRANSFER); switch_core_session_rwunlock(tmp); } diff --git a/src/switch_channel.c b/src/switch_channel.c index f737dc53c6..784577c642 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2434,26 +2434,39 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc return status; } +SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel) +{ + switch_mutex_lock(channel->profile_mutex); + if (channel->caller_profile->callee_id_name) { + switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name); + channel->caller_profile->caller_id_name = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name); + } + channel->caller_profile->callee_id_name = SWITCH_BLANK_STRING; + + if (channel->caller_profile->callee_id_number) { + switch_channel_set_variable(channel, "pre_transfer_caller_id_number", channel->caller_profile->caller_id_number); + channel->caller_profile->caller_id_number = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number); + } + channel->caller_profile->callee_id_number = SWITCH_BLANK_STRING; + switch_mutex_unlock(channel->profile_mutex); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n", + switch_channel_get_name(channel), + switch_channel_get_variable(channel, "pre_transfer_caller_id_name"), + switch_channel_get_variable(channel, "pre_transfer_caller_id_number"), + channel->caller_profile->caller_id_name, + channel->caller_profile->caller_id_number + ); + +} + SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel, switch_bool_t in) { if (in) { if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND && !switch_channel_test_flag(channel, CF_DIALPLAN)) { switch_channel_set_flag(channel, CF_DIALPLAN); - - switch_mutex_lock(channel->profile_mutex); - if (channel->caller_profile->callee_id_name) { - switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name); - channel->caller_profile->caller_id_name = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name); - } - channel->caller_profile->callee_id_name = SWITCH_BLANK_STRING; - - if (channel->caller_profile->callee_id_number) { - switch_channel_set_variable(channel, "pre_transfer_caller_id_number", channel->caller_profile->caller_id_number); - channel->caller_profile->caller_id_number = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number); - } - channel->caller_profile->callee_id_number = SWITCH_BLANK_STRING; - switch_mutex_unlock(channel->profile_mutex); + switch_channel_flip_cid(channel); } return; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 92137ea5d8..fe5edac504 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -3264,6 +3264,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_channel_set_variable(switch_core_session_get_channel(holding_session), SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true"); switch_core_session_rwunlock(holding_session); } + switch_channel_set_flag(peer_channel, CF_LAZY_ATTENDED_TRANSFER); switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(peer_session)); holding = NULL; oglobals.idx = IDX_NADA; @@ -3335,6 +3336,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_channel_set_variable(switch_core_session_get_channel(holding_session), SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true"); switch_core_session_rwunlock(holding_session); } + switch_channel_set_flag(originate_status[i].peer_channel, CF_LAZY_ATTENDED_TRANSFER); switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(originate_status[i].peer_session)); holding = NULL; } else {