mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-03 11:58:36 +00:00
fix MODENDP-35
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6275 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a62373c784
commit
a30c635e2a
@ -202,14 +202,14 @@ static switch_status_t do_config()
|
|||||||
var = (char *) switch_xml_attr_soft(param, "name");
|
var = (char *) switch_xml_attr_soft(param, "name");
|
||||||
val = (char *) switch_xml_attr_soft(param, "value");
|
val = (char *) switch_xml_attr_soft(param, "value");
|
||||||
|
|
||||||
if (!strcasecmp(var, "odbc-dsn")) {
|
if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
globals.odbc_dsn = switch_core_strdup(globals.pool, val);
|
globals.odbc_dsn = switch_core_strdup(globals.pool, val);
|
||||||
if ((odbc_user = strchr(globals.odbc_dsn, ':'))) {
|
if ((odbc_user = strchr(globals.odbc_dsn, ':'))) {
|
||||||
*odbc_user++ = '\0';
|
*odbc_user++ = '\0';
|
||||||
}
|
if ((odbc_pass = strchr(odbc_user, ':'))) {
|
||||||
if ((odbc_pass = strchr(odbc_user, ':'))) {
|
*odbc_pass++ = '\0';
|
||||||
*odbc_pass++ = '\0';
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||||
|
@ -416,14 +416,14 @@ static switch_status_t load_config(void)
|
|||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val);
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(var, "odbc-dsn")) {
|
} else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
odbc_dsn = switch_core_strdup(globals.pool, val);
|
odbc_dsn = switch_core_strdup(globals.pool, val);
|
||||||
if ((odbc_user = strchr(odbc_dsn, ':'))) {
|
if ((odbc_user = strchr(odbc_dsn, ':'))) {
|
||||||
*odbc_user++ = '\0';
|
*odbc_user++ = '\0';
|
||||||
}
|
if ((odbc_pass = strchr(odbc_user, ':'))) {
|
||||||
if ((odbc_pass = strchr(odbc_user, ':'))) {
|
*odbc_pass++ = '\0';
|
||||||
*odbc_pass++ = '\0';
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||||
|
@ -1918,14 +1918,14 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
|
|||||||
profile->password = switch_core_strdup(module_pool, val);
|
profile->password = switch_core_strdup(module_pool, val);
|
||||||
} else if (!strcasecmp(var, "avatar")) {
|
} else if (!strcasecmp(var, "avatar")) {
|
||||||
profile->avatar = switch_core_strdup(module_pool, val);
|
profile->avatar = switch_core_strdup(module_pool, val);
|
||||||
} else if (!strcasecmp(var, "odbc-dsn")) {
|
} else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
profile->odbc_dsn = switch_core_strdup(module_pool, val);
|
profile->odbc_dsn = switch_core_strdup(module_pool, val);
|
||||||
if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
|
if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
|
||||||
*profile->odbc_user++ = '\0';
|
*profile->odbc_user++ = '\0';
|
||||||
}
|
if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
|
||||||
if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
|
*profile->odbc_pass++ = '\0';
|
||||||
*profile->odbc_pass++ = '\0';
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1353,7 +1353,7 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
|||||||
cb.profile = profile;
|
cb.profile = profile;
|
||||||
cb.stream = &mystream;
|
cb.stream = &mystream;
|
||||||
|
|
||||||
sql = switch_mprintf("select contact from sip_registrations where user='%q' and host='%q'", user, domain);
|
sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q'", user, domain);
|
||||||
assert(sql);
|
assert(sql);
|
||||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, contact_callback, &cb);
|
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, contact_callback, &cb);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
|
@ -167,7 +167,7 @@ void sofia_event_callback(nua_event_t event,
|
|||||||
user = sip->sip_to->a_url->url_user;
|
user = sip->sip_to->a_url->url_user;
|
||||||
host = sip->sip_to->a_url->url_host;
|
host = sip->sip_to->a_url->url_host;
|
||||||
|
|
||||||
sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", user, host);
|
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", user, host);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Deleting registration for %s@%s\n", user, host);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Deleting registration for %s@%s\n", user, host);
|
||||||
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
|
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
@ -287,7 +287,7 @@ void event_handler(switch_event_t *event)
|
|||||||
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
|
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
|
||||||
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
|
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
|
||||||
} else {
|
} else {
|
||||||
sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", from_user, from_host);
|
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", from_user, from_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_lock(profile->ireg_mutex);
|
switch_mutex_lock(profile->ireg_mutex);
|
||||||
@ -820,14 +820,14 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||||||
} else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
|
} else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
|
||||||
switch_set_flag(profile, TFLAG_TIMER);
|
switch_set_flag(profile, TFLAG_TIMER);
|
||||||
|
|
||||||
} else if (!strcasecmp(var, "odbc-dsn")) {
|
} else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
profile->odbc_dsn = switch_core_strdup(profile->pool, val);
|
profile->odbc_dsn = switch_core_strdup(profile->pool, val);
|
||||||
if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
|
if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
|
||||||
*profile->odbc_user++ = '\0';
|
*profile->odbc_user++ = '\0';
|
||||||
}
|
if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
|
||||||
if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
|
*profile->odbc_pass++ = '\0';
|
||||||
*profile->odbc_pass++ = '\0';
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -1716,19 +1716,20 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||||||
char reg_sql[] =
|
char reg_sql[] =
|
||||||
"CREATE TABLE sip_registrations (\n"
|
"CREATE TABLE sip_registrations (\n"
|
||||||
" call_id VARCHAR(255),\n"
|
" call_id VARCHAR(255),\n"
|
||||||
" user VARCHAR(255),\n"
|
" sip_user VARCHAR(255),\n"
|
||||||
" host VARCHAR(255),\n"
|
" sip_host VARCHAR(255),\n"
|
||||||
" contact VARCHAR(1024),\n"
|
" contact VARCHAR(1024),\n"
|
||||||
" status VARCHAR(255),\n"
|
" status VARCHAR(255),\n"
|
||||||
" rpid VARCHAR(255),\n"
|
" rpid VARCHAR(255),\n"
|
||||||
" expires INTEGER(8)" ");\n";
|
" expires INTEGER"
|
||||||
|
");\n";
|
||||||
|
|
||||||
|
|
||||||
char sub_sql[] =
|
char sub_sql[] =
|
||||||
"CREATE TABLE sip_subscriptions (\n"
|
"CREATE TABLE sip_subscriptions (\n"
|
||||||
" proto VARCHAR(255),\n"
|
" proto VARCHAR(255),\n"
|
||||||
" user VARCHAR(255),\n"
|
" sip_user VARCHAR(255),\n"
|
||||||
" host VARCHAR(255),\n"
|
" sip_host VARCHAR(255),\n"
|
||||||
" sub_to_user VARCHAR(255),\n"
|
" sub_to_user VARCHAR(255),\n"
|
||||||
" sub_to_host VARCHAR(255),\n"
|
" sub_to_host VARCHAR(255),\n"
|
||||||
" event VARCHAR(255),\n"
|
" event VARCHAR(255),\n"
|
||||||
@ -1736,13 +1737,14 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||||||
" call_id VARCHAR(255),\n"
|
" call_id VARCHAR(255),\n"
|
||||||
" full_from VARCHAR(255),\n"
|
" full_from VARCHAR(255),\n"
|
||||||
" full_via VARCHAR(255),\n"
|
" full_via VARCHAR(255),\n"
|
||||||
" expires INTEGER(8)" ");\n";
|
" expires INTEGER"
|
||||||
|
");\n";
|
||||||
|
|
||||||
|
|
||||||
char auth_sql[] =
|
char auth_sql[] =
|
||||||
"CREATE TABLE sip_authentication (\n"
|
"CREATE TABLE sip_authentication (\n"
|
||||||
" nonce VARCHAR(255),\n"
|
" nonce VARCHAR(255),\n"
|
||||||
" expires INTEGER(8)"
|
" expires INTEGER"
|
||||||
");\n";
|
");\n";
|
||||||
|
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
@ -1757,12 +1759,12 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
|
||||||
|
|
||||||
if (switch_odbc_handle_exec(profile->master_odbc, "select call_id from sip_registrations", NULL) != SWITCH_ODBC_SUCCESS) {
|
if (switch_odbc_handle_exec(profile->master_odbc, "select sip_user from sip_registrations", NULL) != SWITCH_ODBC_SUCCESS) {
|
||||||
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_registrations", NULL);
|
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_registrations", NULL);
|
||||||
switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL);
|
switch_odbc_handle_exec(profile->master_odbc, reg_sql, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_subscriptions", NULL) != SWITCH_ODBC_SUCCESS) {
|
if (switch_odbc_handle_exec(profile->master_odbc, "delete from sip_subscriptions where sip_user != ''", NULL) != SWITCH_ODBC_SUCCESS) {
|
||||||
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL);
|
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_subscriptions", NULL);
|
||||||
switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
|
switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
|
||||||
}
|
}
|
||||||
@ -1777,8 +1779,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_core_db_test_reactive(profile->master_db, "select call_id from sip_registrations", "DROP TABLE sip_registrations", reg_sql);
|
switch_core_db_test_reactive(profile->master_db, "select sip_user from sip_registrations", "DROP TABLE sip_registrations", reg_sql);
|
||||||
switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions", "DROP TABLE sip_subscriptions", sub_sql);
|
switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions where sip_user != ''", "DROP TABLE sip_subscriptions", sub_sql);
|
||||||
switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
|
switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
|
||||||
|
|
||||||
#ifdef SWITCH_HAVE_ODBC
|
#ifdef SWITCH_HAVE_ODBC
|
||||||
|
@ -136,7 +136,7 @@ void sofia_presence_establish_presence(sofia_profile_t *profile)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex,
|
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex,
|
||||||
"select user,host,'Registered','unknown','' from sip_registrations",
|
"select sip_user,sip_host,'Registered','unknown','' from sip_registrations",
|
||||||
sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
|
sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ void sofia_presence_event_handler(switch_event_t *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (euser && host &&
|
if (euser && host &&
|
||||||
(sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where user='%q' and host='%q'",
|
(sql = switch_mprintf("select user,host,status,rpid,'' from sip_registrations where sip_user='%q' and sip_host='%q'",
|
||||||
euser, host)) && (profile = sofia_glue_find_profile(host))) {
|
euser, host)) && (profile = sofia_glue_find_profile(host))) {
|
||||||
|
|
||||||
sofia_glue_execute_sql_callback(profile,
|
sofia_glue_execute_sql_callback(profile,
|
||||||
@ -846,7 +846,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||||||
|
|
||||||
switch_safe_free(sstr);
|
switch_safe_free(sstr);
|
||||||
|
|
||||||
if ((sql = switch_mprintf("select * from sip_subscriptions where user='%q' and host='%q'", to_user, to_host, to_user, to_host))) {
|
if ((sql = switch_mprintf("select * from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, to_host, to_user, to_host))) {
|
||||||
sofia_glue_execute_sql_callback(profile,
|
sofia_glue_execute_sql_callback(profile,
|
||||||
SWITCH_FALSE,
|
SWITCH_FALSE,
|
||||||
profile->ireg_mutex,
|
profile->ireg_mutex,
|
||||||
@ -941,7 +941,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((sql =
|
if ((sql =
|
||||||
switch_mprintf("update sip_registrations set status='%q',rpid='%q' where user='%q' and host='%q'",
|
switch_mprintf("update sip_registrations set status='%q',rpid='%q' where sip_user='%q' and sip_host='%q'",
|
||||||
note_txt, rpid, from_user, from_host))) {
|
note_txt, rpid, from_user, from_host))) {
|
||||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
|
@ -269,9 +269,9 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c
|
|||||||
cbt.len = len;
|
cbt.len = len;
|
||||||
|
|
||||||
if (host) {
|
if (host) {
|
||||||
snprintf(val, len, "select contact from sip_registrations where user='%s' and host='%s'", user, host);
|
snprintf(val, len, "select contact from sip_registrations where sip_user='%s' and sip_host='%s'", user, host);
|
||||||
} else {
|
} else {
|
||||||
snprintf(val, len, "select contact from sip_registrations where user='%s'", user);
|
snprintf(val, len, "select contact from sip_registrations where sip_user='%s'", user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
|||||||
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
|
if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
|
||||||
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
|
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
|
||||||
} else {
|
} else {
|
||||||
sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", to_user, to_host);
|
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, to_host);
|
||||||
}
|
}
|
||||||
switch_mutex_lock(profile->ireg_mutex);
|
switch_mutex_lock(profile->ireg_mutex);
|
||||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||||
@ -536,7 +536,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
|||||||
if ((p = strchr(icontact + 4, ':'))) {
|
if ((p = strchr(icontact + 4, ':'))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
if ((sql = switch_mprintf("delete from sip_subscriptions where user='%q' and host='%q' and contact like '%%%q%%'", to_user, to_host, icontact))) {
|
if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact like '%%%q%%'", to_user, to_host, icontact))) {
|
||||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
sql = NULL;
|
sql = NULL;
|
||||||
@ -549,13 +549,13 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
|||||||
}
|
}
|
||||||
switch_safe_free(icontact);
|
switch_safe_free(icontact);
|
||||||
} else {
|
} else {
|
||||||
if ((sql = switch_mprintf("delete from sip_subscriptions where user='%q' and host='%q'", to_user, to_host))) {
|
if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, to_host))) {
|
||||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
sql = NULL;
|
sql = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sql = switch_mprintf("delete from sip_registrations where user='%q' and host='%q'", to_user, to_host))) {
|
if ((sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, to_host))) {
|
||||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
sql = NULL;
|
sql = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user