res_pjsip: Preserve target hostname for qualified OPTIONS destination

As Asterisk now does the endpoint resolution manually, we need to also manually
copy the hostname from the resolution target as PJProject only does this when
resolving the endpoint itself.

Fixes: #2232
pull/2323/head
Mike Bradeen 1 month ago
parent 201bb70740
commit fb07b9d315

@ -606,6 +606,7 @@ static int sip_options_qualify_resolve_task(void *obj)
for (idx = 0; idx < task_data->count; ++idx) {
pjsip_tx_data *tdata;
pjsip_host_info target_dest;
pjsip_via_hdr *via;
pjsip_transaction *tsx = NULL;
@ -622,6 +623,12 @@ static int sip_options_qualify_resolve_task(void *obj)
continue;
}
if (pjsip_get_request_dest(tdata, &target_dest) != PJ_SUCCESS) {
pjsip_tx_data_dec_ref(tdata);
sip_options_queue_target_result(batch, UNAVAILABLE);
continue;
}
/*
* Build a new request per resolved target so each send gets its own
* transaction and Via branch. Setting exactly one pre-resolved
@ -638,6 +645,14 @@ static int sip_options_qualify_resolve_task(void *obj)
&task_data->addresses.entry[idx].addr);
pj_strdup(tdata->pool, &tdata->dest_info.addr.entry[0].name,
&task_data->addresses.entry[idx].name);
/*
* PJPROJECT only sets dest_info.name when it does the resolution itself.
* Set it here since TLS/WSS uses it for connection reuse and SNI/certificate
* verification.
*/
pj_strdup(tdata->pool, &tdata->dest_info.name, &target_dest.addr.host);
via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
if (via) {
via->branch_param.slen = 0;

Loading…
Cancel
Save