[OpenSIPS-Users] How to test if a message is from myself

Dave Singer dave.singer at wideideas.com
Mon Feb 7 19:21:54 CET 2011


Thanks Stefano,
Though, X-src-ip would be a header added by a trusted back 2 back
server (which I would fist verify before trusting the header). So it
wouldn't ever be the same as $si.

Thanks Bogdan,
I thought of a workaround. :-) (a little messy though)
        if ( $avp(s:dr_gw_attrs) =~ "origin_ips=" ) {
                $var(origin_ips) =
$(avp(s:dr_gw_attrs){param.value,origin_ips});
                $var(i) = 0;
                $var(found) = 0;
                while ( $(var(origin_ips){s.select,$var(i),:}) != null
&& ! $var(found) ) {
                        $var(potential_fs_ip) =
$(var(origin_ips){s.select,$var(i),|});
                        $var(tmp_rd) = $rd;
                        $rd = $var(potential_fs_ip);
                        if ( uri == myself ) {
                                $fs =  $var(potential_fs_ip) + ":5060";
                                $var(found) = 1;
                        } else
                                $var(i) = $var(i) + 1;
                }
                if ( $var(i) ) {
                        $rd = $var(tmp_rd);
                        if ( ! $var(found) )
                                return(-1);
                }
        }

On Thu, Feb 3, 2011 at 4:32 AM, Stefano Pisani
<stefano.pisani at omnianet.it> wrote:
> Hi Dave
> you could try
>
> if ($si == $hdr(X-src-ip)){...}
>
>
> Il 03/02/2011 12:59, Bogdan-Andrei Iancu ha scritto:
>>
>> Hi Dave,
>>
>> Unfortunately does not work with variables.
>>
>> Regards,
>> Bogdan
>>
>> Dave Singer wrote:
>>>
>>> Wow I missed that one. Thanks.
>>> Does that work for PVs so I can test other IPs like one from another
>>> header, say "X-src-ip:192.168.0.5". Last I tried I couldn't get it to
>>> work. Not sure if that was 1.6.2 or 1.6.3. I'm using 1.6.4 now. :)
>>>
>>> Thanks Again
>>> Dave
>>>
>>> On Wed, Feb 2, 2011 at 4:37 AM, Bogdan-Andrei Iancu <bogdan at opensips.org>
>>> wrote:
>>>>
>>>> Hi Dave,
>>>>
>>>> do :  if (src_ip==myself) {}
>>>>
>>>> Regards,
>>>> Bogdan
>>>>
>>>> Dave Singer wrote:
>>>>>
>>>>> Is there any way to check if the source IP/port is one that opensips
>>>>> is listening on or one ? something like if ("sip:$si:$sp" == myself) {
>>>>> ...bla; bla;}
>>>>>
>>>>> Thanks
>>>>> Dave
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.opensips.org
>>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>>
>>>>>
>>>> --
>>>> Bogdan-Andrei Iancu
>>>> OpenSIPS Event - expo, conf, social, bootcamp
>>>> 2 - 4 February 2011, ITExpo, Miami,  USA
>>>> OpenSIPS solutions and "know-how"
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.opensips.org
>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>



More information about the Users mailing list