Native Webserver (#3343)
* Added WebServer/WebServices for Native Linux Meshtastic and web gui
* Fix bug in login functionality
* Added customized config of portdunio.ini with LovyannGFX from marelab repro
* Compile Problem resolved with developer version of LovyanGFX.git
* Compile against dev version
* Fixes to fit into main branch
* Update variant.h, main.cpp, .gitignore, WebServer.cpp, esp32s2.ini, WebServer.h, ContentHandler.cpp, rp2040.ini, nrf52.ini, ContentHelper.cpp, Dockerfile, ContentHandler.h, esp32.ini, stm32wl5e.ini
* Added linux pi std /usr/include dir
* Adding /usr/innclude for Linux compile against native libs that are not hadled by platformio
* Review log level changes & translation
* Update Dockerfile
* Fix Typo & VFS ref. Part1
* Fix Typo & VFS ref.
* Dev Version for ulfius web lib
* Update platformio.ini
* Free VFS path string
* Remove unintended changes
* More unintentional changes
* Make the HTTP server optional on native
* Tune-up for Native web defaults
* Don't modify build system yet
* Remove more unneeded changes
---------
Co-authored-by: marc hammermann <marchammermann@googlemail.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
2024-03-06 16:23:04 -06:00
|
|
|
#pragma once
|
|
|
|
|
#ifdef PORTDUINO_LINUX_HARDWARE
|
|
|
|
|
#if __has_include(<ulfius.h>)
|
|
|
|
|
#include "PhoneAPI.h"
|
|
|
|
|
#include "ulfius-cfg.h"
|
|
|
|
|
#include "ulfius.h"
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
#define STATIC_FILE_CHUNK 256
|
|
|
|
|
|
|
|
|
|
void initWebServer();
|
|
|
|
|
void createSSLCert();
|
|
|
|
|
int callback_static_file(const struct _u_request *request, struct _u_response *response, void *user_data);
|
|
|
|
|
const char *get_filename_ext(const char *path);
|
|
|
|
|
|
|
|
|
|
struct _file_config {
|
|
|
|
|
char *files_path;
|
|
|
|
|
char *url_prefix;
|
|
|
|
|
struct _u_map mime_types;
|
|
|
|
|
struct _u_map map_header;
|
|
|
|
|
char *redirect_on_404;
|
|
|
|
|
char *rootPath;
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-11 04:15:50 -08:00
|
|
|
class HttpAPI : public PhoneAPI
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
2025-11-07 15:03:56 -06:00
|
|
|
HttpAPI() { api_type = TYPE_HTTP; }
|
2025-01-11 04:15:50 -08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Nothing here yet
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/// Check the current underlying physical link to see if the client is currently connected
|
|
|
|
|
virtual bool checkIsConnected() override { return true; } // FIXME, be smarter about this
|
|
|
|
|
};
|
|
|
|
|
|
Native Webserver (#3343)
* Added WebServer/WebServices for Native Linux Meshtastic and web gui
* Fix bug in login functionality
* Added customized config of portdunio.ini with LovyannGFX from marelab repro
* Compile Problem resolved with developer version of LovyanGFX.git
* Compile against dev version
* Fixes to fit into main branch
* Update variant.h, main.cpp, .gitignore, WebServer.cpp, esp32s2.ini, WebServer.h, ContentHandler.cpp, rp2040.ini, nrf52.ini, ContentHelper.cpp, Dockerfile, ContentHandler.h, esp32.ini, stm32wl5e.ini
* Added linux pi std /usr/include dir
* Adding /usr/innclude for Linux compile against native libs that are not hadled by platformio
* Review log level changes & translation
* Update Dockerfile
* Fix Typo & VFS ref. Part1
* Fix Typo & VFS ref.
* Dev Version for ulfius web lib
* Update platformio.ini
* Free VFS path string
* Remove unintended changes
* More unintentional changes
* Make the HTTP server optional on native
* Tune-up for Native web defaults
* Don't modify build system yet
* Remove more unneeded changes
---------
Co-authored-by: marc hammermann <marchammermann@googlemail.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
2024-03-06 16:23:04 -06:00
|
|
|
class PiWebServerThread
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
char *key_pem = NULL;
|
|
|
|
|
char *cert_pem = NULL;
|
|
|
|
|
// struct _u_map mime_types;
|
|
|
|
|
std::string webrootpath;
|
2025-01-11 04:15:50 -08:00
|
|
|
HttpAPI webAPI;
|
Native Webserver (#3343)
* Added WebServer/WebServices for Native Linux Meshtastic and web gui
* Fix bug in login functionality
* Added customized config of portdunio.ini with LovyannGFX from marelab repro
* Compile Problem resolved with developer version of LovyanGFX.git
* Compile against dev version
* Fixes to fit into main branch
* Update variant.h, main.cpp, .gitignore, WebServer.cpp, esp32s2.ini, WebServer.h, ContentHandler.cpp, rp2040.ini, nrf52.ini, ContentHelper.cpp, Dockerfile, ContentHandler.h, esp32.ini, stm32wl5e.ini
* Added linux pi std /usr/include dir
* Adding /usr/innclude for Linux compile against native libs that are not hadled by platformio
* Review log level changes & translation
* Update Dockerfile
* Fix Typo & VFS ref. Part1
* Fix Typo & VFS ref.
* Dev Version for ulfius web lib
* Update platformio.ini
* Free VFS path string
* Remove unintended changes
* More unintentional changes
* Make the HTTP server optional on native
* Tune-up for Native web defaults
* Don't modify build system yet
* Remove more unneeded changes
---------
Co-authored-by: marc hammermann <marchammermann@googlemail.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
2024-03-06 16:23:04 -06:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
PiWebServerThread();
|
|
|
|
|
~PiWebServerThread();
|
|
|
|
|
int CreateSSLCertificate();
|
|
|
|
|
int CheckSSLandLoad();
|
|
|
|
|
uint32_t requestRestart = 0;
|
|
|
|
|
struct _u_instance instanceWeb;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern PiWebServerThread *piwebServerThread;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|