add sub_host to the sip_registrations table to keep track of the original host
This commit is contained in:
parent
61917bb58e
commit
cfa926d781
|
@ -5894,7 +5894,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
" mwi_user VARCHAR(255),\n"
|
||||
" mwi_host VARCHAR(255),\n"
|
||||
" orig_server_host VARCHAR(255),\n"
|
||||
" orig_hostname VARCHAR(255)\n"
|
||||
" orig_hostname VARCHAR(255),\n"
|
||||
" sub_host VARCHAR(255)\n"
|
||||
");\n";
|
||||
|
||||
char recovery_sql[] =
|
||||
|
@ -6011,6 +6012,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
"create index sr_call_id on sip_registrations (call_id)",
|
||||
"create index sr_sip_user on sip_registrations (sip_user)",
|
||||
"create index sr_sip_host on sip_registrations (sip_host)",
|
||||
"create index sr_sub_host on sip_registrations (sub_host)",
|
||||
"create index sr_mwi_user on sip_registrations (mwi_user)",
|
||||
"create index sr_mwi_host on sip_registrations (mwi_host)",
|
||||
"create index sr_profile_name on sip_registrations (profile_name)",
|
||||
|
@ -6094,7 +6096,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
|
|||
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
|
||||
"and network_ip like '%%' and network_port like '%%' and sip_username "
|
||||
"like '%%' and mwi_user like '%%' and mwi_host like '%%' "
|
||||
"and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname);
|
||||
"and orig_server_host like '%%' and orig_hostname like '%%' and sub_host like '%%'", mod_sofia_globals.hostname);
|
||||
|
||||
|
||||
switch_cache_db_test_reactive(dbh, test_sql, "drop table sip_registrations", reg_sql);
|
||||
|
|
|
@ -631,7 +631,7 @@ static void do_normal_probe(sofia_profile_t *profile, switch_event_t *event)
|
|||
switch_safe_free(sql);
|
||||
|
||||
sql = switch_mprintf("select sip_registrations.sip_user, "
|
||||
"sip_registrations.sip_host, "
|
||||
"sip_registrations.sub_host, "
|
||||
"sip_registrations.status, "
|
||||
"sip_registrations.rpid, "
|
||||
"'', "
|
||||
|
@ -649,15 +649,15 @@ static void do_normal_probe(sofia_profile_t *profile, switch_event_t *event)
|
|||
"from sip_registrations "
|
||||
|
||||
"left join sip_dialogs on "
|
||||
"sip_dialogs.presence_id = sip_registrations.sip_user %q '@' %q sip_registrations.sip_host "
|
||||
"sip_dialogs.presence_id = sip_registrations.sip_user %q '@' %q sip_registrations.sub_host "
|
||||
"or (sip_dialogs.sip_from_user = sip_registrations.sip_user "
|
||||
"and sip_dialogs.sip_from_host = sip_registrations.sip_host) "
|
||||
"and sip_dialogs.sip_from_host = sip_registrations.sub_host) "
|
||||
|
||||
"left join sip_presence on "
|
||||
"(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.orig_server_host=sip_presence.sip_host and "
|
||||
"(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.orig_server_host=sip_presence.sip_server and "
|
||||
"sip_registrations.profile_name=sip_presence.profile_name) "
|
||||
"where sip_dialogs.presence_id='%q@%q' or (sip_registrations.sip_user='%q' and "
|
||||
"(sip_registrations.orig_server_host='%q' or sip_registrations.sip_host='%q' "
|
||||
"(sip_registrations.orig_server_host='%q' or sip_registrations.sub_host='%q' "
|
||||
"or sip_registrations.presence_hosts like '%%%q%%'))",
|
||||
dh.status, dh.rpid,
|
||||
switch_sql_concat(), switch_sql_concat(),
|
||||
|
@ -766,9 +766,9 @@ static void do_dialog_probe(sofia_profile_t *profile, switch_event_t *event)
|
|||
"left join sip_registrations on "
|
||||
"(sip_dialogs.sip_from_user = sip_registrations.sip_user "
|
||||
"and (sip_dialogs.sip_from_host = sip_registrations.orig_server_host or "
|
||||
"sip_dialogs.sip_from_host = sip_registrations.sip_host) ) "
|
||||
"sip_dialogs.sip_from_host = sip_registrations.sub_host) ) "
|
||||
"where sip_dialogs.presence_id='%q@%q' or (sip_registrations.sip_user='%q' and "
|
||||
"(sip_registrations.orig_server_host='%q' or sip_registrations.sip_host='%q' "
|
||||
"(sip_registrations.orig_server_host='%q' or sip_registrations.sub_host='%q' "
|
||||
"or sip_registrations.presence_hosts like '%%%q%%'))",
|
||||
probe_euser, probe_host,
|
||||
sub_call_id,
|
||||
|
|
|
@ -1548,12 +1548,12 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
|||
sql = switch_mprintf("insert into sip_registrations "
|
||||
"(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,"
|
||||
"user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,"
|
||||
"mwi_user,mwi_host, orig_server_host, orig_hostname) "
|
||||
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q')",
|
||||
"mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host) "
|
||||
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q')",
|
||||
call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host,
|
||||
contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime + 60,
|
||||
agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm,
|
||||
mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname);
|
||||
mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host);
|
||||
} else {
|
||||
sql = switch_mprintf("update sip_registrations set expires = %ld where sip_user='%q' and sip_host='%q' and contact='%q'", (long) switch_epoch_time_now(NULL) + (long) exptime + 60, to_user, reg_host, contact_str);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue