[sr-dev] git:master:279de091: topoh: modparam to control header masking

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 12 16:04:38 CEST 2022


Module: kamailio
Branch: master
Commit: 279de09111c0884f01fa002fabc8a200fcc26846
URL: https://github.com/kamailio/kamailio/commit/279de09111c0884f01fa002fabc8a200fcc26846

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-10-12T13:20:19+02:00

topoh: modparam to control header masking

- mask_mode - a new parameter
- if bit 1 is set, the masking of contact header in 3xx replies is
  skipped
- GH #3256

---

Modified: src/modules/topoh/topoh_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/279de09111c0884f01fa002fabc8a200fcc26846.diff
Patch: https://github.com/kamailio/kamailio/commit/279de09111c0884f01fa002fabc8a200fcc26846.patch

---

diff --git a/src/modules/topoh/topoh_mod.c b/src/modules/topoh/topoh_mod.c
index b8f7e3a852c..55bb18145b0 100644
--- a/src/modules/topoh/topoh_mod.c
+++ b/src/modules/topoh/topoh_mod.c
@@ -60,6 +60,8 @@
 MODULE_VERSION
 
 
+#define TH_MASKMODE_SLIP3XXCONTACT 1
+
 /** module parameters */
 str _th_key = str_init("aL9.n8~Hm]Z");
 str th_cookie_name = str_init("TH"); /* lost parameter? */
@@ -75,6 +77,7 @@ str th_via_prefix = {0, 0};
 str th_uri_prefix = {0, 0};
 
 int th_param_mask_callid = 0;
+int th_param_mask_mode = 0;
 
 int th_sanity_checks = 0;
 int th_uri_prefix_checks = 0;
@@ -103,6 +106,7 @@ static param_export_t params[]={
 	{"mask_key",		PARAM_STR, &_th_key},
 	{"mask_ip",			PARAM_STR, &th_ip},
 	{"mask_callid",		PARAM_INT, &th_param_mask_callid},
+	{"mask_mode",		PARAM_INT, &th_param_mask_mode},
 	{"uparam_name",		PARAM_STR, &th_uparam_name},
 	{"uparam_prefix",	PARAM_STR, &th_uparam_prefix},
 	{"vparam_name",		PARAM_STR, &th_vparam_name},
@@ -515,7 +519,11 @@ int th_msg_sent(sr_event_param_t *evp)
 			}
 		} else {
 			th_flip_record_route(&msg, 1);
-			th_mask_contact(&msg);
+			if(!(th_param_mask_mode & TH_MASKMODE_SLIP3XXCONTACT)
+					|| msg.first_line.u.reply.statuscode < 300
+					|| msg.first_line.u.reply.statuscode > 399) {
+				th_mask_contact(&msg);
+			}
 			if(th_cookie_value.s[0]=='d') {
 				th_mask_callid(&msg);
 			}




More information about the sr-dev mailing list