Thank you for the response. I did get the other way to work last night with a slight modification to the regex *$var(str2) = "/sip:*.*;tgrp/tgrp/g";* had to add an extra *.** after the first ***, as it wasn't matching the regex expression, causing the issue. However your method looks a lot cleaner. I will give that a try.
The issue I am having now is that the Contact in the 200 OK when sending back to the phone is sending the SBC IP that is in the dispatcher. How do I keep the replies stateful? I was looking at the topology_hiding module, but that looks to be overkill. Is there an easier way to do this? Thank you. Kevin On Tue, Nov 8, 2022 at 2:57 AM Răzvan Crainea <[email protected]> wrote: > Hi, Kevin! > > It would be simpler if you would have used the uri transformations: > https://www.opensips.org/Documentation/Script-Tran-3-2#toc32 > > Simply grab the URI and do something like: > > if ($(var(contacturi){uri.param,tgrp}) != NULL) { > $var(contacthash) = $(var(contacturi){uri.params}); > } else { > $var(contacthash) = $(var(contacturi)); > } > > Răzvan Crainea > OpenSIPS Core Developer > http://www.opensips-solutions.com > > On 11/5/22 16:55, Kevin Kennedy wrote: > > I am trying to find a way to use the pvar_hash in the Dispatcher module > > to hash on the Contact URI. Normally this can be done with using > > $ct.fields(uri) to hash on and this does work, > > > > The caveat that I have is that I am using RFC4904 (SIP Connect) with > > some customers and other customers have a normal Contact URI. > > > > RFC4904 > > sip:1234567890;tgrp=1098765432;trunk-context= > [email protected]:5060 <http://[email protected]:5060> > > > > Normal > > sip:[email protected]:5060 <http://sip:[email protected]:5060> > > > > I am looking for a way to be able to identify if the Contact URI has the > > TGRP parameter, and if it does build the hash with the SIP URI starting > > at the tgrp, ie > > tgrp=1098765432;[email protected]:5076 > > <http://[email protected]:5076> > > > > If it doesn't have the TGRP parameter, build the hash with the full > contact. > > > > I tried with this logic > > > > modparam("dispatcher", "hash_pvar", "$var(contacthash)") > > > > if (is_method("REGISTER|INVITE")) { > > $var(contacturi) = $ct.fields(uri); > > $var(str) = "tgrp="; > > $var(str2) = "/sip:*;tgrp/tgrp/g"; > > if ($(var(contacturi){s.index, $var(str)}) != NULL){ > > xlog("found $var(str) in $var(contacturi)\n"); > > > > $var(contacthash)=$(var(contacturi){re.subst,$var(str2)}); > > } > > else { > > xlog("did not find $var(str) in > > $var(contacturi)\n"); > > $var(contacthash) = $(var(contacturi)); > > } > > ds_select_dst(3, 7, , "default", 1); > > t_relay() > > exit > > } > > > > I am seeing that the hash is still being created on the full Contact > > > > DBG:core:parse_headers: flags=ffffffffffffffff > > found tgrp= in > > sip:1234567890;tgrp=1098765432;trunk-context= > [email protected]:5076 <http://[email protected]:5076> > > DBG:core:tr_eval_re: Trying to apply regexp [/sip:*;tgrp/tgrp/g] on : > > [sip:1234567890;tgrp=1098765432;trunk-context= > [email protected]:5076 <http://[email protected]:5076>] > > DBG:core:tr_eval_re: yay, we can use the pre-compile regexp > > DBG:core:subst_run: running. r=1 > > DBG:core:subst_str: no match > > DBG:core:tr_eval_re: no match for subst expression > > DBG:core:grep_sock_info_ext: checking if host==us: 14==14 && > > [10.255.100.241] == [10.255.100.240] > > DBG:core:grep_sock_info_ext: checking if port 5060 matches port 5060 > > DBG:core:grep_sock_info_ext: checking if host==us: 14==14 && > > [10.255.100.241] == [10.255.100.241] > > DBG:core:grep_sock_info_ext: checking if port 5060 matches port 5060 > > DBG:core:comp_scriptvar: str 20: mydomain.com <http://mydomain.com> > > DBG:dispatcher:w_ds_select: ds_select: 3 7 1 1 > > DBG:dispatcher:ds_select_dst: set [3], using alg [7], size [3], used > > size [2], active size [3] > > *DBG:dispatcher:ds_hash_pvar: Hashing > > sip:1234567890;tgrp=1098765432;trunk-context= > [email protected]:5076 <http://[email protected]:5076>!* > > DBG:dispatcher:ds_select_dst: hash [1435049604], candidate [-1], weight > > sum [20] > > DBG:dispatcher:ds_select_dst: candidate is [0] > > DBG:dispatcher:ds_select_dst: using destination [0] > > DBG:dispatcher:ds_select_dst: selected [7-3/0] <sip:sbc1.sbcdomain.com > > <http://sbc1.sbcdomain.com>> > > > > I am expecting to see the hash as > > *tgrp=1098765432;[email protected]:5076 > > <http://[email protected]:5076>!* > > that way it matches no matter what number is sent in the User field. > > > > Thank you. > > > > Kevin > > > > _______________________________________________ > > Users mailing list > > [email protected] > > http://lists.opensips.org/cgi-bin/mailman/listinfo/users > > _______________________________________________ > Users mailing list > [email protected] > http://lists.opensips.org/cgi-bin/mailman/listinfo/users >
_______________________________________________ Users mailing list [email protected] http://lists.opensips.org/cgi-bin/mailman/listinfo/users
