2022-04-20 07:58:06 +02:00
|
|
|
#ifndef ESP32_FIREWALL_API_HPP
|
|
|
|
#define ESP32_FIREWALL_API_HPP
|
|
|
|
|
|
|
|
#include "HTTPSServer.hpp"
|
|
|
|
#include "SSLCert.hpp"
|
|
|
|
#include "HTTPRequest.hpp"
|
|
|
|
#include "HTTPResponse.hpp"
|
|
|
|
#include "ArduinoJson.h"
|
|
|
|
|
2022-04-20 08:17:55 +02:00
|
|
|
#include "esp32Firewall.hpp"
|
|
|
|
|
2022-04-20 07:58:06 +02:00
|
|
|
using namespace httpsserver;
|
|
|
|
|
2022-04-20 08:17:55 +02:00
|
|
|
class esp32FirewallApi : public esp32Firewall
|
2022-04-20 07:58:06 +02:00
|
|
|
{
|
|
|
|
HTTPSServer *server;
|
|
|
|
SSLCert *certificate;
|
|
|
|
|
|
|
|
void setup_certificate();
|
|
|
|
void setup_routing();
|
2022-04-20 08:17:55 +02:00
|
|
|
void get_firewall_rule_handler(HTTPRequest *, HTTPResponse *);
|
|
|
|
void get_firewall_rules_handler(HTTPRequest *, HTTPResponse *);
|
|
|
|
bool request_has_firewall_parameter(ResourceParameters *);
|
|
|
|
void post_firewall_handler(HTTPRequest *, HTTPResponse *);
|
|
|
|
void delete_firewall_handler(HTTPRequest *, HTTPResponse *);
|
2022-04-20 07:58:06 +02:00
|
|
|
void restart_device_handler(HTTPRequest *, HTTPResponse *);
|
|
|
|
void not_found_handler(HTTPRequest *, HTTPResponse *);
|
|
|
|
|
2022-04-20 08:17:55 +02:00
|
|
|
void json_generic_response(HTTPResponse *, String, const uint16_t);
|
|
|
|
void json_message_response(HTTPResponse *, String, const uint16_t);
|
|
|
|
String construct_json_firewall_rule(firewall_rule_t *);
|
|
|
|
String construct_json_firewall();
|
|
|
|
|
2022-04-20 07:58:06 +02:00
|
|
|
public:
|
|
|
|
esp32FirewallApi(const uint16_t = 8080);
|
|
|
|
void handle_clients();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|