1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

316 commits

Author SHA1 Message Date
Andy Green
297aa86b60 lws_context_create: clean up cancel pipes on fail
https://github.com/warmcat/libwebsockets/issues/1765
2019-11-16 16:56:27 +00:00
Andy Green
37c198d40b format strings: fixes for when toolchain has uint32_t as unsigned long 2019-11-05 21:00:45 +00:00
Andy Green
d3cda2b1d7 humanize: explicitly do decimal rendering
Work around some toolchains with PRIu64 but bugged rendering
2019-11-04 14:21:11 +00:00
Kristján Valur Jónsson
f5ccdd1825 windows: clean warnings around int usage
Change all plat instances of lws_plat_setnonblocking() to use lws_sockfd_type
2019-10-23 06:39:35 +01:00
Andy Green
6f7051920a cgi: call init_destroy even though not on available roles list
cgi is a role, but it's not an externally-selectable role... it's only
used when the mount indicates it should be.

That means it's not in the list of EVERY_AVAILABLE_ROLE... make sure
its zombie child reaping timer is started at context creation and
stopped at destruction.
2019-10-20 07:13:09 +01:00
Andy Green
1c09e6e822 buflist: overallocate by 1
We overallocate at the start by LWS_PRE so we can use
buflist content directly with lws_write, this has us also
overallocate by 1 at the end.  There's a corner case with
cgi where it's receiving bulk POST data to pass on to cgi
stdin and wants to make sure there's a NUL just past the
end... this makes sure we have space for it.
2019-10-13 07:17:03 +01:00
Andy Green
300e22c815 lws_system: auth token handling using buflist 2019-10-12 12:41:14 +01:00
Andy Green
f9e9977534 lws_buflist: extra apis for in-place use 2019-10-12 12:41:14 +01:00
Andy Green
d0fa39af7f lws_system: dhcpclient
Generic lws_system IPv4 DHCP client

 - netif and route control via lib/plat apis
 - linux plat pieces implemented
 - Uses raw ip socket for UDP broadcast and rx
 - security-aware
 - usual stuff plus up to 4 x dns server

If it's enabled for build, it holds the system
state at DHCP until at least one registered interface
has acquired a set of IP / mask / router / DNS server

It uses PF_PACKET which is Linux-only atm.  But those
areas are isolated into plat code.

TODOs

 - lease timing and reacquire
 - plat pieces for other than Linux
2019-10-12 12:41:14 +01:00
Zhiwen Zheng
14746d9014 illumos: fixes for build warnings 2019-10-12 12:41:14 +01:00
Andy Green
41b7716a52 lws_system: auth callback 2019-10-12 12:41:14 +01:00
Andy Green
5013162b1e abstract: existing connection compare 2019-10-10 16:34:37 +01:00
Andy Green
94f1c7b0c1 lws_system: ntpclient 2019-10-10 16:34:37 +01:00
Andy Green
ab4478587a logs: avoid monotonic time
lws_now_usecs() uses monotonic time now.  It's not sync'd with
wallclock time and the two can't be mixed.  Switch to
gettimeofday which is nonmonotonic and use also for fractional
time to avoid fractional secs in logs being unrelated to integer
seconds boundary.
2019-10-10 16:34:37 +01:00
Andy Green
04f99f1499 lws_retry: udp support 2019-10-10 16:34:37 +01:00
Andy Green
bb7f96d32b cmdline: introduce builtin switches
Rather than do all switches by hand on the minimal examples,
add a helper that knows some "builtin" ones like -d and
others to set context options you might want to use in
any example.
2019-10-10 16:34:37 +01:00
Andy Green
bce1f01370 lws_state and system state
Introduce a generic lws_state object with notification handlers
that may be registered in a chain.

Implement one of those in the context to manage the "system state".

Allow other pieces of lws and user code to register notification
handlers on a context list.  Handlers can object to or take over
responsibility to move forward and retry system state changes if
they know that some dependent action must succeed first.

For example if the system time is invalid, we cannot move on to
a state where anything can do tls until that has been corrected.
2019-09-22 09:35:07 -07:00
Andy Green
6a6f365ce7 semmle: fix warnings
They're all cosmetic or minor js stuff.

Add related shield.io icons to README.
2019-09-22 09:35:07 -07:00
Andy Green
f9f6bb66fe lws_validity: unified connection validity tracking
Refactor everything around ping / pong handling in ws and h2, so there
is instead a protocol-independent validity lws_sul tracking how long it
has been since the last exchange that confirms the operation of the
network connection in both directions.

Clean out periodic role callback and replace the last two role users
with discrete lws_sul for each pt.
2019-09-22 09:35:07 -07:00
Andy Green
4e8497b28a context-vhost options: move to uint64_t 2019-09-22 03:08:36 -07:00
Andy Green
6710279e21 client: use block parse and buflist
With http, the protocol doesn't indicate where the headers end and the
next transaction or body begin.  Until now, we handled that for client
header response parsing by reading from the tls buffer bytewise.

This modernizes the code to read in up to 256-byte chunks and parse
the chunks in one hit (the parse API is already set up for doing this
elsewhere).

Now we have a generic input buflist, adapt the parser loop to go through
that and arrange that any leftovers are placed on there.
2019-09-22 03:08:36 -07:00
Andy Green
78c7b0651e buflist: add static reason logging to internal aware apis 2019-09-22 03:08:36 -07:00
Andy Green
32a35d0c4b fixes: various small fixes 2019-09-22 03:08:36 -07:00
Andy Green
d808748cd6 detailed latency stats
Remove LWS_LATENCY.

Add the option LWS_WITH_DETAILED_LATENCY, allowing lws to collect very detailed
information on every read and write, and allow the user code to provide
a callback to process events.
2019-09-22 03:06:59 -07:00
Andy Green
c591e1adfc asynchronous dns for ipv4 and ipv6
This adds the option to have lws do its own dns resolution on
the event loop, without blocking.  Existing implementations get
the name resolution done by the libc, which is blocking.  In
the case you are opening client connections but need to carefully
manage latency, another connection opening and doing the name
resolution becomes a big problem.

Currently it supports

 - ipv4 / A records
 - ipv6 / AAAA records
 - ipv4-over-ipv6 ::ffff:1.2.3.4 A record promotion for ipv6
 - only one server supported over UDP :53
 - nameserver discovery on linux, windows, freertos

It also has some nice advantages

 - lws-style paranoid response parsing
 - random unique tid generation to increase difficulty of poisoning
 - it's really integrated with the lws event loop, it does not spawn
   threads or use the libc resolver, and of course no blocking at all
 - platform-specific server address capturing (from /etc/resolv.conf
   on linux, windows apis on windows)
 - it has LRU caching
 - piggybacking (multiple requests before the first completes go on
   a list on the first request, not spawn multiple requests)
 - observes TTL in cache
 - TTL and timeout use lws_sul timers on the event loop
 - ipv6 pieces only built if cmake LWS_IPV6 enabled
2019-09-19 06:54:53 +01:00
Andy Green
8b37f98feb tokenize: flag for # as rest of line comment
Add a flag for tokenizing config where # indicates
the rest of the line is a comment (eg, /etc/resolv.conf)
2019-09-16 11:09:05 +01:00
Andy Green
5f238ed86d unaligned serialization and deserialization helpers
u16, u32 and u64 read and write, plus VBI read and write for up to
64bit / 10 bytes, all to and from uint8_t.
2019-09-06 15:30:51 +01:00
Andy Green
0fa5563d18 freertos: rename esp32 plat to freertos 2019-08-26 09:58:57 +01:00
Andy Green
ae69bfbd10 debloat: remove things from being built by default that should be conditional 2019-08-26 09:58:57 +01:00
Andy Green
c099e7be92 client: do client stash in a single alloc
Improve the code around stash, getting rid of the strdups for a net
code reduction.  Remove the special destroy helper for stash since
it becomes a one-liner.

Trade several stack allocs in the client reset function for a single
sized brief heap alloc to reduce peak stack alloc by around 700 bytes.
2019-08-19 10:12:20 +01:00
Andy Green
d7f0521aeb private.h: rename to contain dir
Having unique private header names is a requirement of a particular
platform build system it's desirable to work with
2019-08-15 10:49:52 +01:00
Andy Green
26319663f7 license: switch LGPLv2.1+SLE parts to MIT 2019-08-14 10:44:38 +01:00
Andy Green
b606c883f3 lws_system 2019-08-14 08:59:12 +01:00
Andy Green
f00194c321 lws_dsh 2019-08-12 12:45:31 +01:00
Andy Green
69447d0445 logs: just use a single char for most loglevels 2019-08-12 12:44:36 +01:00
Andy Green
2fc35ef6bd stats: move to pt and improve presentation 2019-08-12 06:18:04 +01:00
Andy Green
498a4e2bd7 sul: all timed objects use a single pt sul list
wsi timeout, wsi hrtimer, sequencer timeout and vh-protocol timer
all now participate on a single sorted us list.

The whole idea of polling wakes is thrown out, poll waits ignore the
timeout field and always use infinite timeouts.

Introduce a public api that can schedule its own callback from the event
loop with us resolution (usually ms is all the platform can do).

Upgrade timeouts and sequencer timeouts to also be able to use us resolution.

Introduce a prepared fakewsi in the pt, so we don't have to allocate
one on the heap when we need it.

Directly handle vh-protocol timer if LWS_MAX_SMP == 1
2019-08-09 10:12:09 +01:00
Andy Green
5bbe26474a seq: LWS_WITH_SEQUENCER default-on
force off if NO_NETWORK (which is tested in travis)
2019-08-09 09:14:48 +01:00
Andy Green
3c12fd72e8 unify us sorted waits
There are quite a few linked-lists of things that want events after
some period.  This introduces a type binding an lws_dll2 for the
list and a lws_usec_t for the duration.

The wsi timeouts, the hrtimer and the sequencer timeouts are converted
to use these, also in the common event wait calculation.
2019-08-08 22:39:47 +01:00
Andy Green
fed78bef42 sequencer: upgrade timeout to use us
Adapt service loops and event libs to use microsecond waits
internally, for hrtimer and sequencer.  Reduce granularity
according to platform / event lib wait.

Add a helper so there's a single place to extend it.
2019-08-08 09:45:09 +01:00
Andy Green
c27c38ffbc rtos: use mbedtls random api 2019-08-08 09:45:09 +01:00
Andy Green
20923db2b5 COVA14455: unused var init 2019-08-08 09:45:09 +01:00
Andy Green
71b7fd8597 sequencer: cleanup on pt takedown 2019-08-08 09:45:09 +01:00
Andy Green
bd36962c17 openssl: add threading apis needed for 1.0.2 and earlier
In later OpenSSL, eg 1.1.1, these apis are NOPs in OpenSSL.
They are required for normal operation with multithreading
on earlier OpenSSL, eg, 1.0.2k
2019-08-02 09:47:23 +01:00
hjfbswb
15ce3d03b9 solve complilation errors on vs2008
replace snprintf with lws_snprintf
2019-08-01 18:05:38 +01:00
hjfbswb
119fddbacb solve compilation problems on vs2012 2019-08-01 18:05:30 +01:00
Andy Green
557d51f1f4 tokenize: LWS_TOKENIZE_F_NO_INTEGERS 2019-07-20 11:27:10 -07:00
Andy Green
b3d6e28bc7 lws_sequencer 2019-06-25 12:10:18 +01:00
Andy Green
5462529bcc coverity-2019-03 update 2019-06-19 12:50:50 +01:00
Andy Green
69fbc272f0 coverity: fixes 2019-06-08 10:29:08 +01:00