mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-26 12:14:56 +00:00
Add built-in TLS 1.3 stack: server side, EC support
This commit is contained in:
1 parent
df3c216315
commit
a0e66fb9e6
19 files changed
+12683
-637
No files matched your search
@@ -49,6 +49,8 @@ ifeq ($(TLS), mbedtls)
|
||||
CFLAGS += -DMG_TLS=MG_TLS_MBED -Wno-conversion -Imbedtls/include
|
||||
CFLAGS += -DMBEDTLS_CONFIG_FILE=\"mbedtls_config.h\" mbedtls/library/*.c
|
||||
$(PROG): mbedtls
|
||||
else
|
||||
CFLAGS += -DMG_TLS=MG_TLS_BUILTIN
|
||||
endif
|
||||
|
||||
# Cleanup. Delete built program and all build artifacts
|
||||
|
||||
@@ -123,9 +123,9 @@ static void handle_debug(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
}
|
||||
|
||||
static size_t print_int_arr(void (*out)(char, void *), void *ptr, va_list *ap) {
|
||||
size_t len = 0, num = va_arg(*ap, size_t); // Number of items in the array
|
||||
size_t i, len = 0, num = va_arg(*ap, size_t); // Number of items in the array
|
||||
int *arr = va_arg(*ap, int *); // Array ptr
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
for (i = 0; i < num; i++) {
|
||||
len += mg_xprintf(out, ptr, "%s%d", i == 0 ? "" : ",", arr[i]);
|
||||
}
|
||||
return len;
|
||||
@@ -168,21 +168,19 @@ static void handle_events_get(struct mg_connection *c,
|
||||
|
||||
static void handle_settings_set(struct mg_connection *c, struct mg_str body) {
|
||||
struct settings settings;
|
||||
char *s = mg_json_get_str(body, "$.device_name");
|
||||
bool ok = true;
|
||||
memset(&settings, 0, sizeof(settings));
|
||||
mg_json_get_bool(body, "$.log_enabled", &settings.log_enabled);
|
||||
settings.log_level = mg_json_get_long(body, "$.log_level", 0);
|
||||
settings.brightness = mg_json_get_long(body, "$.brightness", 0);
|
||||
char *s = mg_json_get_str(body, "$.device_name");
|
||||
if (s && strlen(s) < MAX_DEVICE_NAME) {
|
||||
free(settings.device_name);
|
||||
settings.device_name = s;
|
||||
} else {
|
||||
free(s);
|
||||
}
|
||||
|
||||
// Save to the device flash
|
||||
s_settings = settings;
|
||||
bool ok = true;
|
||||
s_settings = settings; // Save to the device flash
|
||||
mg_http_reply(c, 200, s_json_header,
|
||||
"{%m:%s,%m:%m}", //
|
||||
MG_ESC("status"), ok ? "true" : "false", //
|
||||
|
||||
@@ -652,7 +652,7 @@ static const unsigned char v1[] = {
|
||||
0, 0 // .
|
||||
};
|
||||
static const unsigned char v2[] = {
|
||||
31, 139, 8, 8, 246, 5, 126, 101, 0, 3, 99, 111, // ......~e..co
|
||||
31, 139, 8, 8, 87, 102, 129, 101, 0, 3, 99, 111, // ....Wf.e..co
|
||||
109, 112, 111, 110, 101, 110, 116, 115, 46, 106, 115, 0, // mponents.js.
|
||||
237, 93, 235, 115, 219, 70, 146, 255, 238, 191, 98, 162, // .].s.F....b.
|
||||
242, 45, 169, 181, 0, 225, 77, 64, 182, 148, 114, 156, // .-....M@..r.
|
||||
@@ -2668,7 +2668,7 @@ static const struct packed_file {
|
||||
time_t mtime;
|
||||
} packed_files[] = {
|
||||
{"/web_root/bundle.js.gz", v1, sizeof(v1), 1695912421},
|
||||
{"/web_root/components.js.gz", v2, sizeof(v2), 1702757878},
|
||||
{"/web_root/components.js.gz", v2, sizeof(v2), 1702979159},
|
||||
{"/web_root/history.min.js.gz", v3, sizeof(v3), 1695912421},
|
||||
{"/web_root/index.html.gz", v4, sizeof(v4), 1693654553},
|
||||
{"/web_root/main.css.gz", v5, sizeof(v5), 1702757929},
|
||||
|
||||
@@ -10,8 +10,13 @@ bool hal_gpio_read(int pin) {
|
||||
return (pin >= 0 && pin <= 29) ? gpio_get_out_level((uint) pin) : false;
|
||||
}
|
||||
|
||||
void hal_gpio_write(int pin, bool val) {
|
||||
if (pin >= 0 && pin <= 29) gpio_put((uint) pin, val);
|
||||
bool hal_gpio_write(int pin, bool val) {
|
||||
if (pin >= 0 && pin <= 29) {
|
||||
gpio_put((uint) pin, val);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int hal_led_pin(void) {
|
||||
@@ -56,6 +61,10 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_dta) {
|
||||
if (ev == MG_EV_HTTP_MSG) return mg_http_reply(c, 200, "", "ok\n");
|
||||
}
|
||||
|
||||
uint64_t mg_now(void) {
|
||||
return mg_millis();
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||
|
||||
@@ -13,6 +13,7 @@ SOURCES += mongoose.c net.c packed_fs.c
|
||||
|
||||
# Example specific build options. See README.md
|
||||
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\"
|
||||
CFLAGS += -DMG_TLS=MG_TLS_BUILTIN
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
RM = cmd /C del /Q /F /S
|
||||
|
||||
@@ -24,8 +24,9 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||
}
|
||||
|
||||
#ifdef MQTT_DASHBOARD
|
||||
void hal_gpio_write(int pin, bool status) { // For MQTT dashboard HAL
|
||||
bool hal_gpio_write(int pin, bool status) { // For MQTT dashboard HAL
|
||||
gpio_write((uint16_t) pin, status);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hal_gpio_read(int pin) { // For MQTT dashboard HAL
|
||||
|
||||
Reference in new issue
Block a user