<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><title>Re: [Freeswitch-users] Matching context based on sip_req_host</title><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Right, I forgot the ${&#8230;}. That did the trick. Thanks Peter!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I&#8217;ll keep that in mind Ken. I&#8217;m not matching the IP of the client. The R-URI is set by our SIP Proxy, and this FS instance functions as our SBC which is connected to multiple carriers. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] <b>On Behalf Of </b>Ken Rice<br><b>Sent:</b> Wednesday, August 21, 2013 2:40 PM<br><b>To:</b> FreeSWITCH Users Help<br><b>Subject:</b> Re: [Freeswitch-users] Matching context based on sip_req_host<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;font-family:"Courier New"'>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, &quot;Peter Olsson&quot; &lt;<a href="peter@olssononline.se">peter@olssononline.se</a>&gt; wrote:</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New"'>That should probably be:&nbsp;</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&lt;condition field=&quot;${sip_req_host}&quot; expression=&quot;^62\.180\.237\.73$&quot;&gt;<br><br>/Peter<br></span><span style='font-size:11.0pt;font-family:"Courier New"'><br><br>2013/8/21 Grant Bagdasarian &lt;<a href="GB@cm.nl">GB@cm.nl</a>&gt;</span><o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;font-family:"Courier New"'>The following line: &lt;condition field=&quot;sip_req_host&quot; expression=&quot;^10\.0\.0\.1$&quot;&gt;<br>Should be &nbsp;&lt;condition field=&quot;sip_req_host&quot; expression=&quot;^62\.180\.237\.73$&quot;&gt;<br>&nbsp;<br>Wrong sample.<br><span style='color:#1F497D'>&nbsp;<br></span><br></span><b><span style='font-size:10.0pt;font-family:"Courier New"'>From:</span></b><span style='font-size:10.0pt;font-family:"Courier New"'> 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><span style='font-size:11.0pt;font-family:"Courier New"'>&nbsp;<br>Hello,<br>&nbsp;<br>I want to match a context based on the value of sip_req_host, but the context isn&#8217;t matched.<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; &lt;extension name=&quot;internal_to_external&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;condition field=&quot;sip_req_host&quot; expression=&quot;^10\.0\.0\.1$&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action application=&quot;set&quot; data=&quot;hangup_after_bridge=false&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action application=&quot;set&quot; data=&quot;continue_on_fail=true&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action application=&quot;bridge&quot; data=&quot;sofia/external/${sip_req_uri}&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/condition&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/extension&gt;<br>&nbsp;<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>&nbsp;<br>I checked with an online regex validator and it seems that the first and last &#8216;/&#8217; character is causing it to not match. I&#8217;m not a regex expert, so I would appreciate it if someone could help me out with this.<br>&nbsp;<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></span><o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p><div class=MsoNormal align=center style='text-align:center'><span style='font-size:11.0pt;font-family:"Courier New"'><hr size=3 width="95%" align=center></span></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'>_________________________________________________________________________<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></span><o:p></o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:Consolas'><br></span><span style='font-size:11.0pt;font-family:"Courier New"'>-- <br>Ken<br><u><span style='color:blue'><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></span></u>irc.freenode.net #freeswitch</span><o:p></o:p></p></div></body></html>