<HTML>
<HEAD>
<TITLE>Re: [Freeswitch-users] Matching context based on sip_req_host</TITLE>
</HEAD>
<BODY>
<FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:11pt'>If you are trying to match on the IP of the client, you probably really want network_addr which reports from the ip stack which ip the invite came from, using any other IP unless it is coming from a 100% trusted source leaves you vulnerable to people spoofing the IPs inside the sip packets.<BR>
<BR>
Also, the context on unauthenticated users goes with what is defined on the sip profile, so you may need a sorting context<BR>
<BR>
<BR>
On 8/21/13 7:25 AM, "Peter Olsson" <<a href="peter@olssononline.se">peter@olssononline.se</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:11pt'>That should probably be: </SPAN></FONT><FONT SIZE="2"><FONT FACE="Arial"><SPAN STYLE='font-size:10pt'> <condition field="${sip_req_host}" expression="^62\.180\.237\.73$"><BR>
<BR>
/Peter<BR>
</SPAN></FONT></FONT><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:11pt'><BR>
<BR>
2013/8/21 Grant Bagdasarian <<a href="GB@cm.nl">GB@cm.nl</a>><BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:11pt'>The following line: <condition field="sip_req_host" expression="^10\.0\.0\.1$"><BR>
Should be <condition field="sip_req_host" expression="^62\.180\.237\.73$"><BR>
<BR>
Wrong sample.<BR>
<FONT COLOR="#1F497D"> <BR>
</FONT><BR>
</SPAN><FONT SIZE="2"><SPAN STYLE='font-size:10pt'><B>From:</B> Grant Bagdasarian <BR>
<B>Sent:</B> Wednesday, August 21, 2013 1:50 PM<BR>
<B>To:</B> FreeSWITCH Users Help (<a href="freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>)<BR>
<B>Subject:</B> Matching context based on sip_req_host<BR>
</SPAN></FONT><SPAN STYLE='font-size:11pt'> <BR>
Hello,<BR>
<BR>
I want to match a context based on the value of sip_req_host, but the context isn’t matched.<BR>
<BR>
<extension name="internal_to_external"><BR>
<condition field="sip_req_host" expression="^10\.0\.0\.1$"><BR>
<action application="set" data="hangup_after_bridge=false"/><BR>
<action application="set" data="continue_on_fail=true"/><BR>
<action application="bridge" data="sofia/external/${sip_req_uri}"/><BR>
</condition><BR>
</extension><BR>
<BR>
Debug output:<BR>
Dialplan: <a href="sofia/internal/31765727000@192.168.18.6">sofia/internal/31765727000@192.168.18.6</a> Regex (FAIL) [internal_to_external] sip_req_host() =~ /^62\.180\.237\.73$/ break=on-false<BR>
<BR>
I checked with an online regex validator and it seems that the first and last ‘/’ character is causing it to not match. I’m not a regex expert, so I would appreciate it if someone could help me out with this.<BR>
<BR>
Thanks!<BR>
<BR>
_________________________________________________________________________<BR>
Professional FreeSWITCH Consulting Services:<BR>
<a href="consulting@freeswitch.org">consulting@freeswitch.org</a><BR>
<a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a><BR>
<BR>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR>
<a href="http://www.cudatel.com">http://www.cudatel.com</a><BR>
<BR>
Official FreeSWITCH Sites<BR>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
<a href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a><BR>
<a href="http://www.cluecon.com">http://www.cluecon.com</a><BR>
<BR>
FreeSWITCH-users mailing list<BR>
<a href="FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><BR>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><BR>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><BR>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:11pt'><BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></SPAN></FONT><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'>_________________________________________________________________________<BR>
Professional FreeSWITCH Consulting Services:<BR>
<a href="consulting@freeswitch.org">consulting@freeswitch.org</a><BR>
<a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a><BR>
<BR>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR>
<a href="http://www.cudatel.com">http://www.cudatel.com</a><BR>
<BR>
Official FreeSWITCH Sites<BR>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
<a href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a><BR>
<a href="http://www.cluecon.com">http://www.cluecon.com</a><BR>
<BR>
FreeSWITCH-users mailing list<BR>
<a href="FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><BR>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><BR>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><BR>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'><BR>
</SPAN></FONT></FONT><FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:11pt'>-- <BR>
Ken<BR>
<FONT COLOR="#0000FF"><U><a href="http://www.FreeSWITCH.org">http://www.FreeSWITCH.org</a><BR>
<a href="http://www.ClueCon.com">http://www.ClueCon.com</a><BR>
<a href="http://www.OSTAG.org">http://www.OSTAG.org</a><BR>
</U></FONT>irc.freenode.net #freeswitch<BR>
</SPAN></FONT>
</BODY>
</HTML>