Browse code

topos: fix missing xavu_field_contact_host evaluation for contact_mode 0

- fix missing xavu_field_contact_host evaluation for contact_mode 0
- it works currently only for contact_mode 1 and 2, but not for default mode

Henning Westerholt authored on 08/07/2021 14:57:27
Showing 1 changed files
... ...
@@ -411,13 +411,23 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir,
411 411
 		*td->cp = '@';
412 412
 		td->cp++;
413 413
 
414
-		if (_tps_contact_host.len) {
415
-			/* using configured hostname in the contact header */
416
-			memcpy(td->cp, _tps_contact_host.s, _tps_contact_host.len);
417
-			td->cp += _tps_contact_host.len;
414
+		/* contact_host xavu takes preference */
415
+		if (_tps_xavu_cfg.len>0 && _tps_xavu_field_contact_host.len>0) {
416
+			vavu = xavu_get_child_with_sval(&_tps_xavu_cfg,
417
+					&_tps_xavu_field_contact_host);
418
+		}
419
+		if(vavu!=NULL && vavu->val.v.s.len>0) {
420
+			memcpy(td->cp, vavu->val.v.s.s, vavu->val.v.s.len);
421
+			td->cp += vavu->val.v.s.len;
418 422
 		} else {
419
-			memcpy(td->cp, puri.host.s, puri.host.len);
420
-			td->cp += puri.host.len;
423
+			if (_tps_contact_host.len) {
424
+				/* using configured hostname in the contact header */
425
+				memcpy(td->cp, _tps_contact_host.s, _tps_contact_host.len);
426
+				td->cp += _tps_contact_host.len;
427
+			} else {
428
+				memcpy(td->cp, puri.host.s, puri.host.len);
429
+				td->cp += puri.host.len;
430
+			}
421 431
 		}
422 432
 		if(puri.port.len>0) {
423 433
 			*td->cp = ':';