[Libwebsockets] v2.0 coming very soon

Andy Green andy at warmcat.com
Tue May 17 19:53:29 CEST 2016



On May 18, 2016 12:23:21 AM GMT+08:00, Thomas Spitz <thomas.spitz at hestia-france.com> wrote:
>Everything works fine with lwsws top level function.

Nice.

>This has shown me several interesting functions I would like to use but
>without activating libev/libuv (I am on a restricted resources embedded
>system) and without implementation new plugin approach (I am the only
>one
>using lws):

With plugins, you don't need to write any serving code.  Because all the features are anyway in lws, actually lwsws as the server only costs 16KB of .text.

Libuv isn't so cheap (you might be able to chop it down by configuring it for just file / loop / socket apis) but it buys you the ability to deploy the same generic and well-encapsulated plugin on other OSes with just a recompile.  If it's not interesting, you're free to not use it, at the cost of losing plugins.

>- Redirect certain http port to https port
>- Use cgi (namely cgitest)
>- mountpoint to different system folder (egg: server-status redirects
>to
>server-status/server-status.html)
>
>I suppose that the above functions are not tied to lwsws but I managed
>to
>make it work neither with ./libwebsockets-test-server nor with
>./libwebsockets-test-server-v2.0 (plugin activated)

When we say 'it' work with test-server-v2.0.c what are we talking about?  That code basically shows how to emulate lwsws using static data instead of JSON config.  Everything lwsws does can be done that way; lwsws is more or less just a JSON parser for the config files that uses lws apis to get anything done.  All the actual features are in lws.

>All other functions are working (Dumb Increment Demo, Mirror demo,
>close
>testing, server info, post).
>
>By the way:
>- is it possible (easily) to restrict access (ask for login/pwd) for
>some
>files/folders retrieved by HTTP like Apache do with .htpasswd?

No, but I expect I will need a generic per-vhost auth cookie / login thing soon.  The auth cookie hash (kept persistently by the server side) would be associated with settable server-side attributes that could be tested by mounts to decide authorization for their bit of the url space.

>- I have seen "Lws platform-independent file access apis" but is it
>usable
>with any third party websocket client library? I suppose not...

I don't understand what you're asking.... what that does is let you intercept lws file operations at a low level in lws user code.  Nothing above open / read etc file operations knows it exists.

-Andy

>Sorry for so many general questions.
>
>Best regards,
>Thomas
>
>2016-05-17 16:05 GMT+02:00 Andy Green <andy at warmcat.com>:
>
>>
>>
>> On May 17, 2016 9:29:07 PM GMT+08:00, Andy Green <andy at warmcat.com>
>wrote:
>> >
>> >
>> >On May 17, 2016 8:43:15 PM GMT+08:00, Thomas Spitz
>> ><thomas.spitz at hestia-france.com> wrote:
>> >>Everything work fine except cgitest (the test you explained here :
>>
>>>https://libwebsockets.org/pipermail/libwebsockets/2016-March/002253.html
>> )
>> >
>> >Right, but I didn't put cgitest in the conf.d example.
>> >
>> >If I understood it, you can reproduce the conf.d example as it is
>fine.
>>
>> I added the test cgi script to the example localhost config at
>/testcgi.
>>
>> The test script issues headers to set the output to text/html and
>then
>> sends a html table of /proc/meminfo.
>>
>> Managing spawned cgis has a quirk, to make it work reliably the
>server
>> process is detached from the controlling terminal when spawning the
>cgi.
>> If you run lwsws in daemon mode, which is how the systemd integration
>> works, that doesn't make a problem and everything is normal.  But if
>not,
>> it means after running the cgi, ^C from the controlling tty won't
>reach
>> lwsws.  It's not that lwsws ignores it, it's not attached to the
>terminal
>> any more in a way that receives the signal.
>>
>> You can send it a SIGINT another way, like sudo killall -SIGINT lwsws
>and
>> it will close fine.  But if you're planning on using cgi, you should
>run
>> lwsws as a daemon.
>>
>> There's example systemd integration provided
>>
>>
>>
>https://github.com/warmcat/libwebsockets/blob/master/lwsws/usr-lib-systemd-system-lwsws.service
>>
>> -Andy
>>




More information about the Libwebsockets mailing list