[Libwebsockets] Websocket header verification

Andy Green andy at warmcat.com
Thu Jan 19 10:29:50 CET 2017



On 01/19/2017 05:21 PM, techi eth wrote:
>
> Hi,
>
> Is it possible to check Header before accepting client connection with 
> libwebsocket ?

Depends what you mean by "accept"... tcp accept, no, because you have to 
make the tcp connection to get the headers.

Accept to perform the ws upgrade... sure...

     LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION            = 20,
     /**< called when the handshake has
      * been received and parsed from the client, but the response is
      * not sent yet.  Return non-zero to disallow the connection.
      * user is a pointer to the connection user space allocation,
      * in is the requested protocol name
      * In your handler you can use the public APIs
      * lws_hdr_total_length() / lws_hdr_copy() to access all of the
      * headers using the header enums lws_token_indexes from
      * libwebsockets.h to check for and read the supported header
      * presence and content before deciding to allow the handshake
      * to proceed or to kill the connection. */

-Andy

>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list