<div dir="ltr">Hello Andy, hello everyone,<div><br></div><div>I want to filter access to my application according to the IP source of my client.</div><div>My application use both WSS and HTTP "protocol" therefore I would like to filter access before lws switches to either WSS or HTTP "protocol".</div><div>Thus I tried to filter access in callback_http_dummy -> case LWS_CALLBACK_FILTER_NETWORK_CONNECTION using ws_get_peer_simple(wsi, buf, sizeof(buf)) but at that stage I get:</div><div> lwsts[3404]: getpeername: Transport endpoint is not connected</div><div>whereas the same function gives the correct client IP when run in my WSS or HTTP "protocol" callback...</div><div><br></div><div>I'm also surprised that case LWS_CALLBACK_FILTER_NETWORK_CONNECTION is never triggered in my WSS or HTTP "protocol" callbacks.</div><div><br></div><div>Thanks again for this great library!</div><div><br></div><div>Best regards,</div><div>Thomas</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><span style="font-family:arial,helvetica,sans-serif"></span><a href="http://www.hestia-france.com/logiciels.html#Superviseur_domotique_Mitra" target="_blank"><span style="font-family:arial,helvetica,sans-serif"></span></a><a href="http://www.hestia-france.com" target="_blank"><img src="http://www.hestia-france.com/images/news/Hestia_france_domotique_logo.png"></a><br><span style="font-family:arial,helvetica,sans-serif">Hestia France</span> S.A.S<br style="font-family:arial,helvetica,sans-serif"><i style="font-family:arial,helvetica,sans-serif"><span>Fabricant de systèmes domotiques et d'alarme pour l'habitat et le tertiaire</span></i><span></span><br style="font-family:arial,helvetica,sans-serif"><i style="font-family:arial,helvetica,sans-serif">Manufacturer of Home and Building Management System</i><span style="font-family:arial,helvetica,sans-serif"> </span><i style="font-family:arial,helvetica,sans-serif">including alarm </i><i>security</i><br style="font-family:arial,helvetica,sans-serif"><br style="font-family:arial,helvetica,sans-serif"><div align="left"><span style="font-size:10pt;font-family:arial,helvetica,sans-serif"></span><span style="font-family:arial,helvetica,sans-serif"><font size="1">2</font></span><span style="font-size:10pt;font-family:Arial"><font size="1"><span style="font-family:arial,helvetica,sans-serif">, rue du Zécart - 59242 Templeuve - France<br></span></font></span><span style="font-size:10pt;font-family:arial,helvetica,sans-serif"><font size="1">Tel: +33 (0)3 20 04 43 68 - Portable: +33 (0)6 26 87 13 93 - ID Skype: hestia-france - Fax: +33 (0)3 20 64 55 02</font></span><span style="font-family:arial,helvetica,sans-serif"></span><br></div><span style="font-size:10pt;font-family:Arial"><font size="1"><span style="font-family:arial,helvetica,sans-serif">
</span></font></span><span style="font-size:10pt;font-family:arial,helvetica,sans-serif"><font size="1">Site web: <a href="http://www.hestia-france.com" target="_blank">www.hestia-france.com</a> - Email : <a href="mailto:hestia@hestia-france.com" target="_blank">thomas.spitz@hestia-france.com</a> </font></span></div></div>
<br><div class="gmail_quote">2014-01-02 15:14 GMT+01:00 Thomas Spitz <span dir="ltr"><<a href="mailto:thomas.spitz@hestia-france.com" target="_blank">thomas.spitz@hestia-france.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all,<div><br></div><div>Is there someone who tried to filter client connection using their IP (using white and/or black list approach).</div><div><br></div><div>In test-server.c I have uncommented the following line</div>
<div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">libwebsockets_get_peer_<wbr>addresses(context, wsi, (int)(long)in, client_name,<span style="white-space:pre-wrap"> </span>sizeof(client_<wbr>name), client_ip, sizeof(client_ip));<br>
<span style="white-space:pre-wrap">             </span>fprintf(stderr, "Received network connect from %s (%s)\n",<span style="white-space:pre-wrap"> </span>client_name, client_ip);</blockquote><div>But all I get is :</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 gethostbyaddr: Connection refused<br>Received network connect from  ()</blockquote><div> </div></div><div>It seems that this line <span style="white-space:pre-wrap">  </span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
host = gethostbyaddr((char *) &sin.sin_addr, sizeof(sin.sin_addr), AF_INET)<wbr>; </blockquote><div>always returns NULL..</div><div><br></div><div>I haven't investigate much yet...</div><div><br></div><div>BR,</div><div>
Thomas  </div></div>
</blockquote></div><br></div>