#ifndef FIREWALL_H
#define FIREWALL_H
#include "WebServer.h"
#include "cJSON.h"
#include "esp32-hal-log.h"
typedef struct firewall_rule
{
int key;
char source[IP4ADDR_STRLEN_MAX];
char destination[IP4ADDR_STRLEN_MAX];
char protocol[4];
char target[7];
struct firewall_rule *next;
} firewall_rule_t;
class ESPFirewall
WebServer *firewall_api;
int amount_of_rules;
struct firewall_rule *head;
void setup_routing();
void custom_message_response(const char *message, int response_code);
void prepare_firewall_json(cJSON *jsonResponse, firewall_rule_t *link);
firewall_rule_t *add_rule_to_firewall(const char *source, const char *destination, const char *protocol, const char *target);
void post_firewall_handler();
void get_firewall_handler();
public:
ESPFirewall(int port = 8080);
void handle_clients();
};
#endif