Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library

License: GPLv2 Build Status Code Coverage Fuzzing Status

Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs for TCP, UDP, HTTP, WebSocket, MQTT. It has been designed for connecting devices and bringing them online. On the market since 2004, used by vast number of open source and commercial products - it even runs on the International Space Station! Mongoose makes embedded network programming fast, robust, and easy.

Connectivity is vital for software and embedded devices, but there are many pitfalls to consider when embedding a web server. This white paper breaks down on the top 9 things to avoid when embedding a web server.

Looking for a pre-compiled Mongoose web server Windows or Mac binary?

Looking for a complete IoT solution? Check out

  • VCON - Arduino compatible MCU modules with built-in firmware OTA updates
  • Mongoose OS - open source embedded operating system for low-power connected microcontrollers. Secure, designed for commercial Internet of Things products

Support

Features

  • Cross-platform: works on Linux/UNIX, MacOS, Windows, Android, FreeRTOS, etc
  • Supported embedded architectures: ESP32, ESP8266, TI, NRF52, STM32, PIC32, NXP, and more
  • Builtin protocols: plain TCP/UDP, HTTP, MQTT, Websocket
  • SSL/TLS support: mbedTLS, OpenSSL or custom (via API)
  • Asynchronous DNS resolver
  • Tiny static and run-time footprint
  • Source code is both ISO C and ISO C++ compliant
  • Very easy to integrate: just copy mongoose.c and mongoose.h files to your build tree

Licensing

Mongoose is released under Commercial and GNU GPL v.2 open source licenses.

Commercial Projects: Contact us for commercial license.

Dashboard Example

Mongoose is often used to implement device dashboards and real-time data exchange over Websocket. Here is a dashboard example that illustrates the functionality:

Developing a new product? Contact us today to discuss how Mongoose can help.

Contributions

Contributions are welcome! Please follow the guidelines below:

  • Sign Cesanta CLA and send GitHub pull request
  • When making pull requests, please make sure that it has only one commit, and imlements/fixes only one piece of functionality
Owner
Cesanta Software
Embedded Communication
Cesanta Software
Comments
  • Allow controlling behavior when MG_MAX_RECV_SIZE is reached

    Allow controlling behavior when MG_MAX_RECV_SIZE is reached

    When MG_MAX_RECV_SIZE is reached we may want to stop reading rather than throwing an error as a full buffer may just mean we need to wait for the consumer to clear the buffer on a future poll iteration.

    Each poll iteration will call MG_EV_POLL which can consume from the buffer to allow reading to continue, we should not assume that the buffer will always be consumed below the recv max after each poll iteration as the consumer may need to apply backpressure to the recv buffer if the consumer is not able to clear the recv buffer faster than read_conn fills it.

    Introduce a MG_EV_BUFFER_FULL event which allows the user to choose what to do when the buffer is reached, with the existing erroring behavior remaining the default.

  • HTTPS client with Mongoose+Krypton in ARM results in Bus Error

    HTTPS client with Mongoose+Krypton in ARM results in Bus Error

    Hello!

    First have to tell HTTP client implemented with Mongoose runs fine in my ARM9. Problems occur when turned into HTTPS using Krypton. (However Application with HTTPS runs ok in Linux PC)

    What is done for HTTPS: -URLs changed from http:// to https:// -added Krypton files -built with flags -DMG_ENABLE_SSL=1 & -DMG_DISABLE_PFS=1

    Here is some mg debug log:

    https_error

    Please help.

    Cheerio WilsonLP

  • Add top level Makefile and targets for DLL

    Add top level Makefile and targets for DLL

    I see that mongoose 5.2 removed the Makefile. I believe that the idea that everyone should download sources and compile as embedded.

    Although in some situation it would be great to distribute it as a shared library. Some distros (like Linux Arch) are in strong favor of this way. It would be great if mongoose could be distributed as a shared library.

    So it would be nice to have Makefile that:

    • compiles *.so *.a with some predefined set of compile flag (enable all features by default is probably the best idea)
    • installs compiled binary files + header files
    • has 'check' targtet
    • *.pc file with compilation flags that are in sync with shared libraries
  • Multithreaded worker example

    Multithreaded worker example

    docs/Options.md mentions about num_threads, but the struct static_config_options doesn't have this option. I also see that there is a non static function mg_start_thread, but it is not used anywhere in the examples. Is it possible to have an example explaining the use of mongoose using multiple worker threads?

  • mongoose segfaulted with num_threads 1 & global_auth_file option

    mongoose segfaulted with num_threads 1 & global_auth_file option

    When i set num_threads 1 and run my cgi application, mongoose segfaulted after page content is shown.

    The debug output:

    *** 1362423056.0xb76666c0.mg_start.5284: [num_threads] -> [1] *** 1362423056.0xb76666c0.mg_start.5284: [access_log_file] -> [stdout] *** 1362423056.0xb76666c0.mg_start.5284: [error_log_file] -> [stderr] *** 1362423056.0xb76666c0.mg_start.5284: [listening_ports] -> [443s] *** 1362423056.0xb76666c0.mg_start.5284: [ssl_certificate] -> [/etc/mongoose/server.crt] *** 1362423056.0xb76666c0.mg_start.5284: [document_root] -> [/var/www] *** 1362423056.0xb76666c0.mg_start.5284: [global_auth_file] -> [/var/www/.htpasswd] *** 1362423056.0xb76666c0.mg_start.5284: [authentication_domain] -> [z-box] *** 1362423056.0xb76666c0.mg_start.5294: Setting default: [cgi_pattern] -> [.cgi$|.pl$|**.php$] *** 1362423056.0xb76666c0.mg_start.5294: Setting default: [ssi_pattern] -> [**.shtml$|*_.shtm$] *_* 1362423056.0xb76666c0.mg_start.5294: Setting default: [enable_directory_listing] -> [yes] *** 1362423056.0xb76666c0.mg_start.5294: Setting default: [index_files] -> [index.html,index.htm,index.cgi,index.shtml,index.php,index.lp] *** 1362423056.0xb76666c0.mg_start.5294: Setting default: [enable_keep_alive] -> [no] *** 1362423056.0xb76666c0.mg_start.5294: Setting default: [request_timeout_ms] -> [30000] Mongoose web server v. 3.8 started on port(s) 443s with web root [/var/www] *** 1362423056.0xb6b50b70.consume_socket.4999: going idle *** 1362423065.0xb7350b70.accept_new_connection.5125: Accepted socket 4 *** 1362423065.0xb7350b70.produce_socket.5092: queued socket 4 *** 1362423065.0xb6b50b70.consume_socket.5011: grabbed socket 4, going busy *** 1362423065.0xb7350b70.accept_new_connection.5125: Accepted socket 5 *** 1362423065.0xb7350b70.produce_socket.5092: queued socket 5 *** 1362423070.0xb6b50b70.send_http_error.946: [Error 500: Server Error Client closed connection] *** 1362423070.0xb6b50b70.consume_socket.4999: going idle *** 1362423070.0xb6b50b70.consume_socket.5011: grabbed socket 5, going busy *** 1362423070.0xb6b50b70.handle_request.4356: /cgi-bin/main.cgi *** 1362423070.0xb6b50b70.consume_socket.4999: going idle *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 4 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 4 *** 1362423070.0xb6b50b70.consume_socket.5011: grabbed socket 4, going busy *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 5 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 5 *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 6 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 6 *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 7 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 7 *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 8 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 8 *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 9 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 9 *** 1362423070.0xb6b50b70.handle_request.4356: /css/main.css *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 4 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 4 *** 1362423070.0xb6b50b70.consume_socket.4999: going idle *** 1362423070.0xb6b50b70.consume_socket.5011: grabbed socket 5, going busy *** 1362423070.0xb6b50b70.handle_request.4356: /js/main.tabs.js *** 1362423070.0xb6b50b70.consume_socket.4999: going idle *** 1362423070.0xb6b50b70.consume_socket.5011: grabbed socket 6, going busy *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 5 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 5 *** 1362423070.0xb6b50b70.handle_request.4356: /js/jquery.js *** 1362423070.0xb7350b70.accept_new_connection.5125: Accepted socket 6 *** 1362423070.0xb7350b70.produce_socket.5092: queued socket 6 *** 1362423070.0xb6b50b70.consume_socket.4999: going idle *** 1362423070.0xb6b50b70.consume_socket.5011: grabbed socket 7, going busy *** 1362423070.0xb6b50b70.handle_request.4356: /ip_base.js *** 1362423070.0xb6b50b70.send_http_error.946: [Error 404: Not Found File not found] *** 1362423070.0xb6b50b70.consume_socket.4999: going idle *** 1362423070.0xb6b50b70.consume_socket.5011: grabbed socket 8, going busy *** 1362423076.0xb6b50b70.send_http_error.946: [Error 500: Server Error Client closed connection]

    I have coredump, but i don't know how to attach it here.

  • Sometimes static files are truncated when using SSL because SSL_Write returns -1 (SSL_ERROR_WANT_WRITE)

    Sometimes static files are truncated when using SSL because SSL_Write returns -1 (SSL_ERROR_WANT_WRITE)

    Only occurs sometimes and only after a bunch of SSL_Writes have succeed. Basically everying is ok (a bunch of SSL_Writes 8192 bytes success) but then suddenly SSL_Write returns -1 (after calling SSL_get_error in the error I see SSL_ERROR_WANT_WRITE). I have a 5 sec poll period on the select. Can reproduce once every 10 requests (ctrl+f5 refresh) on Chrome/IE and on different files (js/css) of ~300KBs. Using self-signed certificated you provided and no proxies (browser and server are on same machine). Is it just me ? Could it be related to non-blocking sockets introduced in v5 ?

    Googling for it I get the idea I need to call SSL_Write again (w/ same arguments) because negotiation wasnt finished. From Man pages: "The operation did not complete; the same TLS/SSL I/O function should be called again later. If, by then, the underlying BIO has data available for reading (if the result code is SSL_ERROR_WANT_READ) or allows writing data (SSL_ERROR_WANT_WRITE), then some TLS/SSL protocol progress will take place, i.e. at least part of an TLS/SSL record will be read or written. The retry may again lead to a SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE condition. There is no fixed upper limit for the number of iterations that may be necessary until progress becomes visible at application protocol level."

  • Fix for erroneous MG_EV_HTTP_CHUNK

    Fix for erroneous MG_EV_HTTP_CHUNK

    Do not send MG_EV_HTTP_CHUNK if chunk len would be zero and response is not yet fully received.

    This can occur in circumstances where the first socket read contains only the header (no data). In this case, the calculated chunk length is zero.

  • [Windows] 'unit_test.exe' failure

    [Windows] 'unit_test.exe' failure

    The unit_test.exe program always fails for me. Running as set V=5 & unit_test.exe I get this output:

    -> [9876543210,7]
    ...
    3cab2d23 3 sock.c:301:write_conn        4 0x2b8 29:0 29 err 0
    3cab2d33 4 sock.c:608:mg_mgr_poll       1 -- tchrc
    3cab2d43 4 sock.c:608:mg_mgr_poll       5 r- tchrc
    3cab2d52 3 sock.c:291:read_conn         5 0x2b4 0:0 29 err 0
    3cab2d62 4 http.c:660:uri_to_path2      5 /foo/version.h -> ./src/version.h 3
    3cab2d81 4 sock.c:608:mg_mgr_poll       4 -- tchrc
    3cab2d91 4 sock.c:608:mg_mgr_poll       1 -- tchrc
    3cab2da0 4 sock.c:608:mg_mgr_poll       5 -w tchrc
    3cab2db0 3 sock.c:301:write_conn        5 0x2b4 129:0 129 err 0
    3cab2dcf 4 sock.c:608:mg_mgr_poll       4 -- tchrc
    3cab2def 4 sock.c:608:mg_mgr_poll       1 -- tchrc
    3cab2dfe 4 sock.c:608:mg_mgr_poll       5 -- tchrc
    3cab2dfe 4 sock.c:608:mg_mgr_poll       4 r- tchrc
    3cab2dfe 3 sock.c:291:read_conn         4 0x2b8 0:0 129 err 0
    3cab2dfe 3 net.c:163:mg_close_conn      4 closed
    3cab2e0e 4 sock.c:608:mg_mgr_poll       1 -- tchrc
    3cab2e0e 4 sock.c:608:mg_mgr_poll       5 r- tchrc
    3cab2e0e 3 sock.c:291:read_conn         5 0x2b4 0:0 -1 err 0
    3cab2e0e 3 net.c:163:mg_close_conn      5 closed
    3cab2e0e 4 sock.c:608:mg_mgr_poll       1 -- tchrc
    FAILURE test/unit_test.c:2270: cmpbody(buf, expected) == 0
    

    Seems the cause is DOS line-ending of src/version.h. If I first do a dos2unix src\version.h, it passes. Can the unit_test be suited for this case? Or are we expected to have git always convert files to Unix line-endings? core.autocrlf=false or something?

    The 2nd problem is on the file test/data/київ.txt which also has a DOS file-ending. But my dos2unix program is unable to convert it.
    A change to core.autocrlf=false and git pull after a check-out does not modify such files. Ref. https://github.com/atom/github/issues/1830

    What to do with these things?

  • Crash on mg_tls_init

    Crash on mg_tls_init

    • My goal is: running a bot
    • My actions were: api server for the bot accepts a connection with mbedtls for the crypto
    • My expectation was: no crash
    • The result I saw: a crash
    • My question is: why crash and how fix?

    Environment

    • mongoose version: latest commit as of 04/07/2021 (dd-mm-yyyy)
    • custom changes?: n
      • If yes, provide the diff below, and the releavant commit:
    • build environment:
      • OS: debian linux
      • Compiler/IDE: gcc/g++
    • relevant example (see https://github.com/cesanta/mongoose/tree/master/examples) is: ?
    • relevant documentation topic (see https://cesanta.com/docs/) is: ?

    MBEDTLS VERSION:

    [email protected]:~/bin# apt list | grep mbedtls
    
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    
    libmbedtls-dev/stable,now 2.16.0-1 amd64 [installed]
    libmbedtls-doc/stable 2.16.0-1 all
    libmbedtls12/stable,now 2.16.0-1 amd64 [installed,automatic]
    [email protected]:~/bin# 
    

    (Source code if that helps: https://github.com/djpiper28/CockatriceTournamentBot) Bind address: https://127.0.0.1:8000, SSL Certificates generated by certbot and don't expire for about a month. Request sent:

    authtoken=[REDACTED]
    gamename=test-deck-hashes/Match3
    password=[REDACTED]
    playerCount=1
    spectatorsAllowed=0
    spectatorsNeedPassword=0
    spectatorsCanChat=0
    spectatorsCanSeeHands=0
    onlyRegistered=0
    playerDeckVerification=1
    playerName=*
    deckHash=ie03v62v
    
    

    COREDUMP:

    Core was generated by `./botExec'.
    Program terminated with signal SIGABRT, Aborted.
    #0  __GI_raise ([email protected]=6) at ../sysdeps/unix/sysv/linux/raise.c:50
    50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    [Current thread is 1 (Thread 0x7fb614bd9700 (LWP 16315))]
    (gdb) bt full
    #0  __GI_raise ([email protected]=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            set = {__val = {0, 94430847706812, 11, 94430847706812, 140420008742048, 94430847706817, 0, 0, 0, 0, 0, 0, 140420008741552, 140420008741576, 140420008742083, 140420008741552}}
            pid = <optimized out>
            tid = <optimized out>
            ret = <optimized out>
    #1  0x00007fb615628535 in __GI_abort () at abort.c:79
            save_stage = 1
            act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 11 times>, 17179869184, 140419795065520, 0, 140420008740912, 140420008741168}}, sa_flags = 347965488, sa_restorer = 0x1000}
            sigs = {__val = {32, 0 <repeats 15 times>}}
    #2  0x00007fb61567f508 in __libc_message ([email protected]=do_abort, [email protected]=0x7fb61578a28d "%s\n") at ../sysdeps/posix/libc_fatal.c:181
            ap = {{gp_offset = 24, fp_offset = 0, overflow_arg_area = 0x7fb614bd8940, reg_save_area = 0x7fb614bd88d0}}
            fd = 2
            list = <optimized out>
            nlist = <optimized out>
            cp = <optimized out>
            written = <optimized out>
    #3  0x00007fb615685c1a in malloc_printerr ([email protected]=0x7fb615788376 "corrupted size vs. prev_size") at malloc.c:5341
    No locals.
    #4  0x00007fb615685e74 in malloc_consolidate ([email protected]=0x7fb608000020) at malloc.c:4488
            fb = <optimized out>
            maxfb = 0x7fb608000078
            p = <optimized out>
            nextp = 0x0
            unsorted_bin = 0x7fb608000080
            first_unsorted = <optimized out>
            nextchunk = <optimized out>
            size = <optimized out>
            nextsize = <optimized out>
            prevsize = <optimized out>
            nextinuse = <optimized out>
            bck = <optimized out>
            fwd = <optimized out>
    #5  0x00007fb615688a58 in _int_malloc ([email protected]=0x7fb608000020, [email protected]=1960) at malloc.c:3695
            nb = 1968
            idx = 78
            bin = <optimized out>
            victim = <optimized out>
            size = <optimized out>
            victim_index = <optimized out>
            remainder = <optimized out>
            remainder_size = <optimized out>
            block = <optimized out>
            bit = <optimized out>
            map = <optimized out>
            fwd = <optimized out>
            bck = <optimized out>
            tcache_unsorted_count = <optimized out>
            tcache_nb = <optimized out>
            tc_idx = <optimized out>
            return_cached = <optimized out>
            __PRETTY_FUNCTION__ = "_int_malloc"
    #6  0x00007fb61568b1a2 in __libc_calloc (n=<optimized out>, elem_size=<optimized out>) at malloc.c:3428
            av = <optimized out>
            oldtop = 0x7fb608016240
    --Type <RET> for more, q to quit, c to continue without paging--c
            p = <optimized out>
            bytes = 1960
            sz = 1960
            csz = <optimized out>
            oldtopsize = 44480
            mem = <optimized out>
            clearsize = <optimized out>
            nclears = <optimized out>
            d = <optimized out>
            hook = <optimized out>
            __PRETTY_FUNCTION__ = "__libc_calloc"
    #7  0x000055e26520394d in mg_tls_init (c=0x7fb608011ab0, opts=0x7ffc8070c950) at src/tls.c:68
            tls = 0x55e265204236 <mg_url_is_ssl(char const*)+64>
            rc = 0
            ca = 0x0
            cert = 0x7fb614bd8df7 ""
            certkey = 0x55e2653c0770 "https://127.0.0.1:8000"
            __func__ = "mg_tls_init"
    #8  0x000055e265117817 in eventHandler (c=0x7fb608011ab0, event=4, ev_data=0x0, fn_data=0x7ffc8070c920) at /root/Tricebot/CockatriceTournamentBot/src/api_server.c:677
            s = 0x7fb608003cf0
            api = 0x7ffc8070c920
    #9  0x000055e2651f9a1b in mg_call (c=0x7fb608011ab0, ev=4, ev_data=0x0) at src/event.c:13
    No locals.
    #10 0x000055e2652025b3 in accept_conn (mgr=0x7fb614bd8e90, lsn=0x7fb608000b20) at src/sock.c:486
            buf = "127.0.0.1:55672\000a\340 e\342U\000\000\000\000\000\000\000\000\000\000a\340 e\342U\000"
            c = 0x7fb608011ab0
            usa = {sa = {sa_family = 2, sa_data = "\331x\177\000\000\001\000\000\000\000\000\000\000"}, sin = {sin_family = 2, sin_port = 30937, sin_addr = {s_addr = 16777343}, sin_zero = "\000\000\000\000\000\000\000"}, sin6 = {sin6_family = 2, sin6_port = 30937, sin6_flowinfo = 16777343, sin6_addr = {__in6_u = {__u6_addr8 = "\000\000\000\000\000\000\000\000\060\216\275\024\266\177\000", __u6_addr16 = {0, 0, 0, 0, 36400, 5309, 32694, 0}, __u6_addr32 = {0, 0, 347967024, 32694}}}, sin6_scope_id = 347967064}}
            sa_len = 16
            fd = 6
            __func__ = "accept_conn"
    #11 0x000055e265202f00 in mg_mgr_poll (mgr=0x7fb614bd8e90, ms=100) at src/sock.c:675
            c = 0x7fb608000b20
            tmp = 0x0
            now = 1625423402179
            __func__ = "mg_mgr_poll"
    #12 0x000055e2651185ed in pollingThread (apiIn=0x7ffc8070c920) at /root/Tricebot/CockatriceTournamentBot/src/api_server.c:1064
            mgr = {conns = 0x7fb608011ab0, dns4 = {url = 0x55e265222711 "udp://8.8.8.8:53", c = 0x0}, dns6 = {url = 0x55e265222728 "udp://[2001:4860:4860::8888]:53", c = 0x0}, dnstimeout = 3000, nextid = 3, userdata = 0x0}
            c = 0x7fb608000b20
            api = 0x7ffc8070c920
            cont = 1
    #13 0x00007fb615af1fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
            ret = <optimized out>
            pd = <optimized out>
            now = <optimized out>
            unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140420008744704, -3554313377566241517, 140722463360270, 140722463360271, 140420008744704, 0, 3585045260700405011, 3585042937650400531}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
            not_first_call = <optimized out>
    #14 0x00007fb6156ff4cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
    
  • mg_serve_http broke in v6.3 and v6.4

    mg_serve_http broke in v6.3 and v6.4

    When i run mongoose 6.2, my site works properly (using HTTP). When I swap out mongoose with either v6.3 or v6.4, none of my static pages are sent to the browser properly.

  • Websocket server send data

    Websocket server send data

    This is not exactly a bug, but watching the documentation and the examples I cannot find how the server can send data to client using websockets.

    All I can see is that the websockets callbacks are called when a websocket connection is started. But how is it possible to send data from the server to the client?

    I need to send an information every second to the client.

  • Improve STM32 driver

    Improve STM32 driver

    • Frames are now read in order, and only host owned descriptors are checked
    • Read as many frames as possible (but don't loop forever)
    • Discard bad frames
    • Improved exit out of suspended condition
    • If a frame arrives while processing, it will now generate a new interrupt (formerly it would wait for another frame to arrive as we reset the flag on exit) siege varies a lot but seems to give numbers 10% higher on average with this mods: ~200 tps to /api/hi on both F429 and F746

    NOTE: removing printf() from the driver exposed an issue in the order of gcc parameters in the F429-freertos-mip example Makefile, causing a linkage problem; so the modified Makefile...

  • Support for '%I' format

    Support for '%I' format

    When running some MIP examples, I see strange hex-values instead of a plain IPv4 address:

    14b08f9d 3 mip.c:397:rx_arp             ARP response: we're 0xa00004f
    

    So my idea is to add support for a %I format in src/fmt.c. Like:

    --- a/src/fmt.c 2022-10-08 07:35:51
    +++ b/src/fmt.c 2022-10-31 08:12:46
    @@ -1,5 +1,6 @@
     #include "fmt.h"
     #include "iobuf.h"
    +#include "net.h"
    
     static void mg_pfn_iobuf_private(char ch, void *param, bool expand) {
       struct mg_iobuf *io = (struct mg_iobuf *) param;
    @@ -309,6 +310,12 @@
               n += scpy(out, param, (char *) &hex[p[j] & 15], 1);
             }
             n += scpy(out, param, (char *) &dquote, 1);
    +      } else if (c == 'I') {
    +        char I_buf [20];
    +        struct mg_addr addr;
    +        addr.ip = va_arg(*ap, unsigned long);
    +        addr.is_ip6 = 0;
    +        n += scpy(out, param, mg_ntoa(&addr, I_buf, sizeof(I_buf)), sizeof(I_buf));
           } else if (c == 'V') {
             // Print base64-encoded double-quoted string
             size_t len = (size_t) va_arg(*ap, int);
    

    And use it like:

    --- a/mip/mip.c 2022-11-30 12:56:33
    +++ b/mip/mip.c 2022-11-30 15:07:08
    @@ -393,7 +393,7 @@
         memcpy(arp->sha, ifp->mac, sizeof(pkt->arp->sha));
         arp->tpa = pkt->arp->spa;
         arp->spa = ifp->ip;
    -    MG_DEBUG(("ARP response: we're %#lx", (long) mg_ntohl(ifp->ip)));
    +    MG_DEBUG(("ARP response: we're %I", ifp->ip));
         ether_output(ifp, PDIFF(eth, arp + 1));
       } else if (pkt->arp->op == mg_htons(2)) {
    

    Thus getting something not so strange:

    14b2e015 3 mip.c:397:rx_arp             ARP response: we're 10.0.0.79
    
  • Fix and enable armhf test

    Fix and enable armhf test

    make armhf fails at the moment - becase it is 32bit arm arch. It is disabled at GA: https://github.com/cesanta/mongoose/blob/a8bef964635804272ef6ed5eb8a354d73aaa5307/.github/workflows/test.yml#L31

    Please fix the test and enable it on GA

  • OpenSSL configure TLS1.3 ciphers

    OpenSSL configure TLS1.3 ciphers

    When using mongoose as a https server with OpenSSL (here 1.1.1o) and TLS 1.3 it is not possible to restrict the allowed ciphers for TLS1.3. Actually the given string (for example "AES:...:!SHA:!aNULL:...") does not affect provided TLS1.3 ciphers by the webserver. This may due to the usage of "SSL_CTX_set_cipher_list()", which only works for TLS <= 1.2, for TLS 1.3 openssl provides the function "SSL_CTX_set_ciphersuites()", see: https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_ciphersuites.html

    Used nmap and sslscan are verify results.

    Additionally it would be nice to be able to restrict / configure the allowed ECDHE groups used for key exchange.

  • mg_sock_send run infinitely

    mg_sock_send run infinitely

    • My goal is: describe
    • My actions were: describe
    • My expectation was: describe
    • The result I saw: provide logs or description
    • My question is: mg_sock_send() run in an infinite loop if buffer length exceeds Maximum Segment Size(default 1440), send() return BSD_EWOULDBLOCK. I run mongoose in a thread which priority is osPriorityNormal, and net_core's priority also is osPriorityNormal, so that Thread net_core is always in the block state, because thread mongoose is always running.

    Environment

    • mongoose version: 7.8 MG_ARCH_RTX
    • Compiler/IDE and SDK: KEIL 5.37
    • Target hardware/board: stm32h743
    • Connectivity chip/module: LAN8742a
Like libevent and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.
Like libevent and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.

中文版 Intro Like libevent, libev, and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols. Features cr

Dec 3, 2022
Dohd is a minimalist DNS-over-HTTPS daemon that redirects all DoH queries to a local DNS server running on localhost:53 (UDP)

dohd Dohd (pron. doh-dee) is a minimalist DNS-over-HTTPS daemon that redirects all DoH queries to a local DNS server running on localhost:53 (UDP). Fe

Nov 1, 2022
Nov 26, 2022
Winpcap-based network packet capture tool, support TLS (part), UDP, ICMP, TCP, ARP, DNS and other protocol analysis, interface reference wireshark.
Winpcap-based network packet capture tool, support TLS (part), UDP, ICMP, TCP, ARP, DNS and other protocol analysis, interface reference wireshark.

Winpcap-based network packet capture tool, support TLS (part), UDP, ICMP, TCP, ARP, DNS and other protocol analysis, interface reference wireshark.

Nov 20, 2022
Simple embeddable C++11 async tcp,http and websocket serving.

net11 Simple embeddable C++11 async tcp,http and websocket serving. What is it? An easily embeddable C++11 networking library designed to make buildin

Mar 28, 2020
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid

Nov 29, 2022
Portable, single-file, protocol-agnostic TCP and UDP socket wrapper, primarily for game networking

Documentation This is a header-only library, as such most of its functional documentation is contained within the "header section" of the source code

Aug 29, 2022
an easy implementation of a multi-process tcp server and a multi-thread tcp client
an easy implementation of a multi-process tcp server and a multi-thread tcp client

一个TCP多进程服务器-多线程客户端的简单实现。 客户端类似Apache ab的测试功能,能够通过向某一个ip端口发送指定并发量和总数量的tcp短连接;服务端处理tcp短连接,每来一条消息就打印一条log。 使用cmake编译,建议在vscode里编译,或者命令行 # 终端进入目录 mkdir bu

Nov 28, 2021
Built a client-server application using TCP and UDP sockets, in which the clients can subscribe/unsubscribe to various topics.

Built a client-server application using TCP and UDP sockets, in which the clients can subscribe/unsubscribe to various topics.

Jun 22, 2022
A project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server.
A project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server.

PS4 Server 9.00 This is a project designed for the esp8266 D1 Mini or the esp8266 D1 Mini PRO to provide a wifi http server and dns server. this is fo

Nov 28, 2022
Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services.
Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services.

Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services. The project is unique among realtime push solutions in that it is designed to address the needs of API creators. Pushpin is transparent to clients and integrates easily into an API stack.

Nov 24, 2022
Small and fast cross-platform networking library, with support for messaging, IPv6, HTTP, SSL and WebSocket.

frnetlib Frnetlib, is a cross-platform, small and fast networking library written in C++. There are no library dependencies (unless you want to use SS

Nov 25, 2022
HTTP and WebSocket built on Boost.Asio in C++11
HTTP and WebSocket built on Boost.Asio in C++11

HTTP and WebSocket built on Boost.Asio in C++11 Branch Linux/OSX Windows Coverage Documentation Matrix master develop Contents Introduction Appearance

Dec 1, 2022
Provide translation, currency conversion, and voting services. First using telnet you create a connection to a TCP socket, then the server connects to 3 UDP sockets hosted on other servers to do tasks.

to run micro servers g++ translator.cpp -o translator ./translator <port 1> g++ voting.cpp -o voting ./voting <port 2> g++ currency_converter.cpp -o c

Oct 29, 2021
cuehttp is a modern c++ middleware framework for http(http/https)/websocket(ws/wss).

cuehttp 简介 cuehttp是一个使用Modern C++(C++17)编写的跨平台、高性能、易用的HTTP/WebSocket框架。基于中间件模式可以方便、高效、优雅的增加功能。cuehttp基于boost.asio开发,使用picohttpparser进行HTTP协议解析。内部依赖了nl

Nov 18, 2022
H2O - the optimized HTTP/1, HTTP/2, HTTP/3 server

H2O - an optimized HTTP server with support for HTTP/1.x, HTTP/2 and HTTP/3 (experimental) Copyright (c) 2014-2019 DeNA Co., Ltd., Kazuho Oku, Tatsuhi

Nov 27, 2022
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

What Is RESTinio? RESTinio is a header-only C++14 library that gives you an embedded HTTP/Websocket server. It is based on standalone version of ASIO

Nov 25, 2022
websocket and http client and server library, coming with ws, a command line swiss army knife utility

Hello world IXWebSocket is a C++ library for WebSocket client and server development. It has minimal dependencies (no boost), is very simple to use an

Nov 19, 2022
A protocol for secure client/server connections over UDP

netcode netcode is a simple connection based client/server protocol built on top of UDP. It has the following features: Encrypted and signed packets S

Dec 5, 2022