diff --git a/src/modules/topos/doc/topos_admin.xml b/src/modules/topos/doc/topos_admin.xml index 8a423fdc847..3d6e5ac5d76 100644 --- a/src/modules/topos/doc/topos_admin.xml +++ b/src/modules/topos/doc/topos_admin.xml @@ -275,6 +275,31 @@ end ... modparam("topos", "event_mode", 2) ... + + + +
+ <varname>contact_host</varname> (str) + + You may need to control the host part of the Contact header added + by topos. + + For example when using TLS with TOPOS the remote UAS must be able to open + a new TLS socket to the contact header. + In this case, the contact header must contain a domain name with a trusted CA + signed certitificate. + + + + Default value is taken from the Record-Route URI. + + + + Set <varname>contact_host</varname> parameter + +... +modparam("topos", "contact_host", "proxy.domain.com") +...
diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c index 1bd9eb6571a..43711f2fe91 100644 --- a/src/modules/topos/topos_mod.c +++ b/src/modules/topos/topos_mod.c @@ -93,6 +93,7 @@ static str _tps_eventrt_callback = STR_NULL; static str _tps_eventrt_outgoing_name = str_init("topos:msg-outgoing"); static int _tps_eventrt_sending = -1; static str _tps_eventrt_sending_name = str_init("topos:msg-sending"); +str _tps_contact_host = str_init(""); sanity_api_t scb; @@ -129,6 +130,7 @@ static param_export_t params[]={ {"clean_interval", PARAM_INT, &_tps_clean_interval}, {"event_callback", PARAM_STR, &_tps_eventrt_callback}, {"event_mode", PARAM_STR, &_tps_eventrt_mode}, + {"contact_host", PARAM_STR, &_tps_contact_host}, {0,0,0} }; diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c index 08bf15ec8aa..8d9a8883569 100644 --- a/src/modules/topos/tps_storage.c +++ b/src/modules/topos/tps_storage.c @@ -53,6 +53,8 @@ extern sruid_t _tps_sruid; extern db1_con_t* _tps_db_handle; extern db_func_t _tpsdbf; +extern str _tps_contact_host; + #define TPS_STORAGE_LOCK_SIZE 1<<9 static gen_lock_set_t *_tps_storage_lock_set = NULL; @@ -219,14 +221,20 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir) return 0; } - if(td->cp + 8 + (2*uuid->len) + sv.len >= td->cbuf + TPS_DATA_SIZE) { - LM_ERR("insufficient data buffer\n"); - return -1; - } if (parse_uri(sv.s, sv.len, &puri) < 0) { LM_ERR("failed to parse the uri\n"); return -1; } + + int contact_len = sv.len; + if (_tps_contact_host.len) + contact_len = sv.len - puri.host.len + _tps_contact_host.len; + + if(td->cp + 8 + (2*uuid->len) + contact_len >= td->cbuf + TPS_DATA_SIZE) { + LM_ERR("insufficient data buffer\n"); + return -1; + } + if(dir==TPS_DIR_DOWNSTREAM) { td->b_uuid.s = td->cp; *td->cp = 'b'; @@ -263,8 +271,15 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir) td->cp += uuid->len; *td->cp = '@'; td->cp++; - memcpy(td->cp, puri.host.s, puri.host.len); - td->cp += puri.host.len; + + if (_tps_contact_host.len) { // using configured hostname in the contact header + memcpy(td->cp, _tps_contact_host.s, _tps_contact_host.len); + td->cp += _tps_contact_host.len; + } else { + memcpy(td->cp, puri.host.s, puri.host.len); + td->cp += puri.host.len; + } + if(puri.port.len>0) { *td->cp = ':'; td->cp++;