42 lines
999 B
C++
42 lines
999 B
C++
#ifndef FIREWALL_H
|
|
#define FIREWALL_H
|
|
|
|
#include "Arduino.h"
|
|
#include "AsyncJson.h"
|
|
#include "ArduinoJson.h"
|
|
#ifdef ESP32
|
|
#include "WiFi.h"
|
|
#include "AsyncTCP.h"
|
|
#elif defined(ESP8266)
|
|
#include "ESP8266WiFi.h"
|
|
#include "ESPAsyncTCP.h"
|
|
#endif
|
|
#include "ESPAsyncWebServer.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
|
|
{
|
|
AsyncWebServer *firewall_api;
|
|
unsigned int amount_of_rules = 0;
|
|
struct firewall_rule *head = NULL;
|
|
|
|
void add_rule_to_firewall(const char *source, const char *destination, const char *protocol, const char *target);
|
|
void get_firewall_handler(AsyncWebServerRequest *request);
|
|
void post_firewall_handler(AsyncWebServerRequest *request);
|
|
void not_found(AsyncWebServerRequest *request);
|
|
void setup_routing();
|
|
|
|
public:
|
|
ESPFirewall(int port = 8080);
|
|
};
|
|
|
|
#endif
|