[sr-dev] [kamailio/kamailio] websocket: X-Forwarded-For and X-Real-IP support (#1002)

Michael Ricordeau notifications at github.com
Mon Feb 20 19:18:09 CET 2017


@miconda I found a simple way to get the value of the X-Forwarded-For header without changing the code in the websocket module.
I thought about this after reading again the comment for Juha.
I'm retrieving the X-Forwarded-For header in the event:xhttp and use htable to track the conid associated:
```shell
event_route[xhttp:request] {
....
        $var(orig_ip) = $hdr(X-Forwarded-For);
        if (($var(orig_ip) != $null) && ($var(orig_ip) != "")) {
            $sht(ws_src=>$conid) = $var(orig_ip);
            xlog("L_INFO", "WebSocket $conid original source ip is $var(orig_ip)\n");
        }
```

And in any context where $conid is available, I can retrieve the value with (in my case to set xavp attr in the location_attrs table when the phone registers) :
```shell
        $var(real_src_ip) = $sht(ws_src=>$conid);
        if (($var(real_src_ip) != "") && ($var(real_src_ip) != $null)) {
            xavp_params_explode("real_src_ip=$var(real_src_ip)", "contact_extras");
        }
```

-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1002#issuecomment-281148921
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20170220/14eafd5e/attachment.html>


More information about the sr-dev mailing list