Can be used for cases where device has no networking but mongoose is still needed for its event loop.
CL: mg: Add net_if_null, a no-op net interface
PUBLISHED_FROM=e79b4a8667508bbde1437dda9dad77ce3a3aa630
* Change return type of mg_mgr_poll to return number of events
* Add mg_mgr_min_timer
* Refactor main poll loop to remove LwIP-specific stuff
CL: Refactor mg polling
PUBLISHED_FROM=dc94618b32fa3c84a2f053bd04d134297780ec82
h/t @YankunLi
Closes https://github.com/cesanta/mongoose/pull/939
CL: mg: Fix a bug in mg_mgr_init_opt with opts.num_ifaces
PUBLISHED_FROM=a87518b3505429a3cf9cd6d84b3b781e7dbdcfd5
Do not clear buffer at the end of multipart request to allow following request to proceed.
Closes https://github.com/cesanta/mongoose/pull/940
CL: mg: Fix pipelining issue with multipart upload
PUBLISHED_FROM=cc7d38b126eaa863553ee4e124cfafcd72030fcf
curl -F file1 -F file2 ...
Add a unit test and fix a minor memory leak when returning an error.
CL: mg_file_upload_handler: Support multiple files
PUBLISHED_FROM=5c4bf2be676346fb782e80f50f79df6a6721ac88
Set CLOSE_IMMEDIATELY flag when destroying conn.
This avoid some races in LWIP adapter.
CL: mg_lwip: Fix race during clean conenction teardown
PUBLISHED_FROM=5c67982390dfaf83527e85d1291f64c6050aa932
Per standard, cookies are delimited by `; `.
CL: Fix mg_http_parse_header: treat ";" as a delimiter.
PUBLISHED_FROM=039243c30f5fabf4a4700a43506f841b3268306a
A major cleanup, disentangling net_if and ssl_if.
Pulled a lot of common logic into the core and reduced size of net_if implementations.
CL: Mongoose net_if and ssl_if refactoring
PUBLISHED_FROM=29bd4dcb264a1fd96b3dd164e2d880e1c2c0921e
Consume buffer as soon as we know there is no boundary there, no need to delay until next chunk arrives.
This prevents stall where buffer fills up in one go and next chunk never arrives.
CL: Fix an edge case in multipart HTTP upload parsing
PUBLISHED_FROM=025f9001d272df2a75ece22b199b1944d5db9840
* Limit total amount of headroom, in absolute terms (`MBUF_SIZE_MAX_HEADROOM`).
* If unable to allocate with headroom, fall back to allocating the required minimum.
* For mOS, set default `MBUF_SIZE_MULTIPLIER` to 2 to avoid floating point operations.
Since max headroom size is now capped to 128 bytes, this will not result in much of a bloat.
PUBLISHED_FROM=11d4fc65a46a805bb7c8960f89a3d0b753c58bb8
freshen: implement ota rollback
freshen: api for rpc
freshen: implement rpc api (without transport)
PUBLISHED_FROM=9f935f676161c81464a0dc53d5d8d085b2437ffb
Which is a replacement of (deprecated) `mg_http_parse_header`, but,
similarly to `asprintf`, allocates a new buffer if the client-provided
one is not large enough.
Also use it throughout mongoose code, and thus some header-related
limitations are removed; in particular,
https://github.com/cesanta/mongoose/issues/813 is fixed.
CL: Mongoose Web Server: Deprecate `mg_http_parse_header()` and implement `mg_http_parse_header2()` instead, which allocates a new buffer if the client-provided one is not large enough (similarly to `asprintf`).
CL: Mongoose Web Server: Fix limitations of header value lengths, e.g. when parsing authentication headers such as nonce, etc.
PUBLISHED_FROM=c75b1bbbbdb294ea85075ce69b1368f115fdd1ef
In certain files it was necessary to make tests work from public
mongoose repo, so this commit makes things consistent.
PUBLISHED_FROM=694454d0ff007229c65d524a2a2beaf126420f15
Before it resulted in an endless recursion.
Resolves https://github.com/cesanta/mongoose/issues/871
CL: Mongoose Web Server: Fail if passed a NULL handler to `mg_bind` or `mg_bind_opt`.
PUBLISHED_FROM=376e5d330a643fa530f6a27a422a1500f986c721
CL: Mongoose Web Server: Digest authentication: Fix nonce validity check (expired nonce or nonce from the future did not cause the the check to fail)
CL: Mongoose Web Server: Digest authentication: Fix nonce request value; it worked before because nonce validity check was broken as well
CL: Mongoose Web Server: Digest authentication: Add `nonce` argument to `mg_http_create_digest_auth_header()`: clients should use the value received from the server's authentication request.
Resolves https://github.com/cesanta/mongoose/issues/809
PUBLISHED_FROM=5e59f90ed6b2a4311ed6763159da81c2aaf6af4c
CL: Mongoose Web Server: Websocket: Respond to Ping with Pong
CL: Mongoose Web Server: Websocket: Properly close a connection with Close frame (in response to a client's close and when protocol failure is detected)
CL: Mongoose Web Server: Websocket: Fix support of fragmented messages
CL: Mongoose Web Server: Websocket: Add support for control frames interjected in the middle of a fragmented message
PUBLISHED_FROM=e2b3794aaacc64633540c493194cccc62afa2077
`path_info` was dereferenced without checking for NULL, and a few lines
below, it was checked for NULL.
CL: none
PUBLISHED_FROM=9f14dc68c152b9b1119b276f047686d831bace38
CL: Mongoose Web Server: Fix socket leak when there are too many open file descriptors
Fixes https://github.com/cesanta/mongoose/issues/870
PUBLISHED_FROM=c802b6834a54eca37821d46efde192c527e0a6b7
2.0 redefined LWIP_VERSION in a way that is no longer compatible with use by preprocessor (boo).
also, tcp_pcb.acked is gone, but we only use it for debug, so it doesn't matter.
PUBLISHED_FROM=776f90a08bd5024fa8a61dae257af6c60ec6710d
ECDHE is way too slow on ESP8266 w/o cryptochip, this sometimes results in WiFi STA deauths.
Disable DHE completely because it's just hopelessly slow.
PUBLISHED_FROM=d9c8e95b7d5c992f9e127726c569f187b1e0b453
Make sure topic is properly NUL-terminated.
Ignore SUBSCRIBE requests with no topic expressions.
PUBLISHED_FROM=a00f39dda44fe63299e971a91a98f8ee57dd2a64
ev_timer_time may remain the same for legit reason, so to prevent looping, instead, reset it before invoking the handler.
To let user know what the initial setting was, pass it as the argument instead of current time (which is kind of pointless).
PUBLISHED_FROM=fa328009f097f9b49b5b0dd13a38ee6d6e6518de
Now apps should use getters and setters instead of accessing struct
fields directly, e.g. instead of `get_cfg()->update.timeout` it should
be `mgos_sys_config_get_update_timeout()` to get the current value, and
`mgos_sys_config_set_update_timeout(123)` to update the value.
For now, the config structs are public, but they will be made private
soon, so use accessors to keep your code working.
PUBLISHED_FROM=f7d582421a8d7e4d1ed50a280f2670d8b62f8d45
Mongoose would report consumed bytes twice if mg_call is invoked recursively (e.g. proto_handler uses mg_call to invoke user's handler).
Reporting twice as much recved as was delivered effectively disables LwIP's TCP throttling and causes buffers to grow too big.
PUBLISHED_FROM=4ad5cd5db4dd54623bd6de2d50d32ddcc9e2b08a
Add checks on the number of subscribe requests per packet and overall per-session subscription limit.
PUBLISHED_FROM=faaf5c50af31a0694c9308a664f2e418dbb0eb18
For now, we only support SPIFFS-in-a-box, same as CC3200.
On CC3200SF it should be possible to have SPIFFS on built-in flash, but that is left for later.
PUBLISHED_FROM=dee337c8cd8ed288c22abe9960eef81e6e90cc4a
Achievement unlocked: CC3220 port prints a boot banner.
Then locks up.
Included in this PR is refactoring to pull out common parts to be shared with CC3200.
PUBLISHED_FROM=5fb9d9a00bb9ce7f63dde20bc1876076b76d5257
Fixed bug in websocket handshake:
now adding Sec-WebSocket-Protocol header in handshake response.
PUBLISHED_FROM=e4a71ff9dc4aeec63db40cb7f356dc5b25c1215a
With different filesystem implementations and storage drivers, like grown-ups have :)
This is not currently used to add any new functionality, we still have
only one FS and driver on ESP8266 and ESP32; CC3200 has two: SPIFFS and SLFS.
This will be used soon to implement filesystems on additional SPI flash chips and SD cards.
PUBLISHED_FROM=293960fef82952c505e9b1925aac7724c7308362
Merge commits are not explicitly ignored either: they're just naturally
ignored as empty commits.
PUBLISHED_FROM=12871fd4c9b1e9de4e57e13d810bffd98ddba299
Merge commits are not explicitly ignored either: they're just naturally
ignored as empty commits.
PUBLISHED_FROM=2c814104eedd76ee90813488277ecaaf2baf6315
Other minor fixes.
Also decrease idle poll interval to 100 ms, as a workaround for some cases of incorrect next poll delay computation.
Added HW tests for SSL fetches.
Fixescesanta/mongoose-os#262
PUBLISHED_FROM=4d19f845768b4b3b990d25959d4211972368d7fc
Remove the specialized URI parser, clean up code a bit.
Fix parsing of URIs with IPv6 hosts (http://[2001:2:3::4]:567/)
PUBLISHED_FROM=968ad97585d928123106ce3828920ee073113f83
Connection may not (yet) have a TCP or UDP PCB associated with it.
mg_lwip_if_get_conn_addr should not crash in this case.
PUBLISHED_FROM=fd0ed683b18b3f549135c9d79eeadfc7348ab05a
TCP ACK may arrive after the we've corresponding mg_connection has already been closed.
Fixescesanta/mongoose-os#235
PUBLISHED_FROM=8164b86131ef08c1b2a6a08630920d600b3f91ac
Remote address is not associated with an outgoing UDP socket.
Instead, it is stored in mg_connection.sa
PUBLISHED_FROM=16f82ee8a69b995d684ec96b8db6b5591cd400db
[...] after handing data off to LWIP, do not wait for ACK.
We don't do it in net_if_socket, don't do it here either.
Also prevents multiple send attempt on the same send_mbuf data.
PUBLISHED_FROM=4e5a677ebda84af1514f34299e53ce856a537883
If http.auth_{domain,file} are configured, all HTTP requests require valid digest authorization header.
This applies to files served by mg_http_serve as well as synamic endpoints such as /update and /rpc.
mongoose-os#229
PUBLISHED_FROM=824d594147cfeb2428b463d24478b207839aa5e2
Add `mjs_check_arg()` which checks whether argument is provided, and
checks its type. It simplifies code and makes it smaller (because
error strings are not ad-hoc, so they are not duplicated)
As part of that, also commonize type stringifying: implement
`mjs_stringify_type` and reimplement `mjs_typeof` on top of that.
Use `mjs_check_arg()` in `mjs_string_slice()` and
`mjs_string_char_code_at()`.
PUBLISHED_FROM=0b72cf479738ff405d991cbd4bf9e75edda0f111
E.g. given the expression `foo/#`:
- `foo/bar` matches
- `foo/` should not match
- `foo` should not match
PUBLISHED_FROM=40f3290cb9a478b22d9f1ab6382884b5de70e266
Must be invoked on mongoose main task, not on LWIP
Also request immediate poll oif there is data to be sent and space to
send it.
PUBLISHED_FROM=53576651452d8d7193da9e63f5b97f6f8729c45b
Fixed a bunch of things to make OTA work on ESP32 with flash encryption:
writes to app aprtitions must be 32-byte aligned and mod 32 in size.
When merging filesystems during update, use spiffs_vfs_* functions so
that old fs is properly decrypted.
Refactored cs_dirent stuff: SPIFFS support moved to spiffs_vfs.c,
added dirent.h on ESP8266 and CC3200 which includes cs_dirent.h
Define DIR and dirent only if asked (ESP8266, CC3200, WIN32).
PUBLISHED_FROM=58b0d05cdc41b1a9e02d341e2a1cdcb012829232
- LWIP UDP sockets are always writable and they are not reported as
such by select() (bug? featuyre?). TCP sockets are ok.
- Always deliver MG_EV_POLL, whether we have other fd_events or not.
Otherwise MG_EV_POLL would not be delivered at all to perma-writable
UDP sockets (as they are on LWIP).
- Ignore EAGAIN/EWOULDBLOCK errors while connecting, this happens
during SSL handshake.
PUBLISHED_FROM=3b1ee0d2b0c672512da5c9d6141aba1112983426
Namely, define it if only `MG_ENABLE_HTTP_STREAMING_MULTIPART` and
`MG_ENABLE_FILESYSTEM` are on
PUBLISHED_FROM=3094738a4b76ceb09a3c2374e8d9d914b71c3441
Assume handshake request was declined if either MG_F_CLOSE_IMMEDIATELY _or_ MG_F_SEND_AND_CLOSE is set.
PUBLISHED_FROM=60af32a3f8890e826205465b9add2f58b1d46e5f
Renegotiation is disabled, so we don't need them.
Reduces per-connection usage when idle by 3K.
PUBLISHED_FROM=24b2ac9557107f7da412dae6a42257c9b7c812d5
- Only allow one TCP segment in flight. Each segment is 1.5K and it
adds up. This may increase latency, but memory is precious on ESP.
At teh same time, optimize use of tcp_output: do not send a new segment
on every write, only call tcp_output at the end of connection
processing during poll.
- Build LWIP with DNS disabled. We have our won resolver, and LWIP's
allocates large static buffers (1K).
- mbedTLS: Deallocate peer's certificate at the end of SSL handshake,
reduces idle SSL connection footprint by ~1.5K.
Some tweaks to the heap log viewer (which made all the above possible).
PUBLISHED_FROM=6e84bba64eacb2d737561e09313918104921ea80
Also performs trnasparent SPIFFS -> SLFS cert copy.
If the file's extension is .pem, convert it to DER format and put on SLFS.
PUBLISHED_FROM=364caab21969ca28a05802c4dde93a11d1e0feda
Also fixed a memory leak on reconnect: previously, each reconnect was
creating a `struct mg_connection` which was never reclaimed
PUBLISHED_FROM=eefdcf557e032ac81d5ed3aba55ac912e400148e
The only client of `mg_http_common_url_parse` (namely,
`mg_connect_http_base`) expects `port_i` to be the index in the address
string at which the port was added.
PUBLISHED_FROM=b095926b5485e4674e3c59ff8481171831fb61ae
If the path starts with /, do not drop it.
There are no directories on SLFS, but use of /pretend/paths/to/files.txt
is common. What we do drop is the ./ prefix (added by mongoose when document_root=.)
PUBLISHED_FROM=5108bc078dfaf8f8afa4db554b4769d9d7b8a103
It wasn't checked for `NULL`, and on CC3200 NULL dereferencing addresses
doesn't cause a crash, so it worked by pure luck: ctx->ssl_key was 0.
After `mg_` to `miot_` refactoring it's not the case anymore (presumably
because linker arranged objects in a different order), so this bug shown
up.
PUBLISHED_FROM=0f1cc73a078c18432c68ae0f9b14dd06b3bb4279
in light of the root cause discovered by rojer
and addressed in cesanta/dev#5882 for the http connection code path.
PUBLISHED_FROM=aea563150a0411cbe3fdc6f7911529f3136cc76f
Long-lived UDP "connections" i.e. interactions that involve more
than one request and response are rare, most are transactional:
response is sent and the "connection" is closed. Or - should be.
But users (including ourselves) tend to forget about that part,
because UDP is connectionless and one does not think about
processing a UDP request as handling a connection that needs to be
closed. Thus, we begin with SEND_AND_CLOSE flag set, which should
be a reasonable default for most use cases, but it is possible to
turn it off the connection should be kept alive after processing.
PUBLISHED_FROM=1677d8024aa9afa7e18d8a04d829b699f7f2f103
* Make kr_{send,recv} report status via return code instaed of errno
* Move mg_if_* recv and connect callback invocation out of LWIP
callbacks: these can be nested and we don't want that to happen
to our callbacks. Instead, we post events for the event manager to
process during next poll.
PUBLISHED_FROM=9b3c1de796fae381dea1641807e51d7a897a398e
LWIP part has been finally fully split from the ESP part, and ESP
platform defs reduced to bare minimum. It is now possible to use LWIP
in either low-level or socket mode without any ESP dependencies,
and NXP Kinetis platform is the first to make use of it.
PUBLISHED_FROM=4a9055897609c812296bdab5b4943ffde641ced2
Possible values:
MG_NET_IF_SOCKET (1) - traditional BSD socket API
MG_NET_IF_SIMPLELINK (2) - TI's SimpleLink socket interface
MG_NET_IF_LWIP_LOW_LEVEL - a net_if implementation that uses LWIP's
low-level API, when LWIP_SOCKET is not available.
PUBLISHED_FROM=a5c0aebb7b6bdb1f1f4cb3210763d16f3ab5e133
Factor out SSI and WS code from http.c
HTTP + WS are enabled by default, but MQTT is built without HTTP
support as a compilation test.
PUBLISHED_FROM=925ed9a55abb193ed7deac1c9675a0e5b35dca50
"#if FOO" still works with simple -DFOO, but gives more flexibility.
Specifically, if user expressed no preference (FOO is not defined),
we can apply reasonable defaults (this is the legitimate use of ifdef).
In short, from now on, please use
#if MG_ENABLE_FOO
instead of
#ifdef MG_ENABLE_FOO
Since we are all used to #ifdef, this change also adds a precommit check
to police this. Specifically, in *.h and *.c files that are Copyright Cesanta,
"ifdef" and "if defined()" are not allowed to be used with macros that contain
ENABLE or DISABLE, unless the like also contains "ifdef-ok".
Hence, if you are sure you want to use ifdef, use this:
#ifdef MG_ENABLE_FOO /* ifdef-ok */
PUBLISHED_FROM=9be829448f53cff575d6cae8b9945fb12531c15a
esp_mg_net_if was a rat's nest of mongoose net_if and event manager
implementaions and the event loop task for the ESP8266 miot port.
From that, pieces that are related to LWIP support have been pulled out,
separated into net_if and event manager files, and event loop task
has been moved under the miot esp8266 dirrectory.
This is done to facilitate LWIP code reuse. This may not be the end of
it, but it's a start.
Note: custom retransmit logic has been removed for now. Can be
reintroduced later is necessary.
PUBLISHED_FROM=fd5bbf75714583ce95776d4c76b6c5b5dc535364
This is the variant of MG_EV_SSI_CALL with context of the SSI call being
processed in addition to the tag argument. Specifically, call handler
now gets access to the HTTP request and the name of the file being processed.
MG_EV_SSI_CALL is preserved for backward compatibility.
PUBLISHED_FROM=eeea7487c062505abdb23b6f64994ff7a6b60ff8
Make paths embedded in amalgamated files nice and relative.
This facilitates subsequent clean un- and re-amalgamation.
PUBLISHED_FROM=d83e6000617c54ceaeb78b80c25814996043fe66
On my way, fixed a couple of cases where we had `()` in the header, and
non-empty argument list in the source file.
PUBLISHED_FROM=5519526cf84e2bbd425a726fcc112fea1a95cbf1
It was observed that sl_Send can return SL_EAGAIN, despite the fact that
we only call write_to_socket if it was reported as writeable.
PUBLISHED_FROM=e4cbacb3f16bb7abb479222d7dcbfbe113a39161
Complete rewrite of the C Clubby implementation: it is now modeled after
the Go implementation, with a slight difference that codec and channel
are the same object (something we should probably do in Go as well, as
we only have a single type of channel so far, which is used with all
types of codecs).
This implementation also comes with a new external API,
which is hopefully cleaner and easier to use (see mg_clubby.h).
In this PR I am not adding any new types of channels, but a UART channel
as well as websocket listener channel will be added after this lands.
PUBLISHED_FROM=d545d4bb6434e2a02ad159f9e4b64e594a4797e7
So that socket/connection/whatever is really closed by the time user code is run.
Speed up test_http_endpoints by using appropriate wait conditions.
PUBLISHED_FROM=5fc8a772cc2a9c3b8c9dbddde9f99b41ce4d334c