cleanup Firewall

This commit is contained in:
Florian Hoss 2022-05-03 20:15:01 +02:00
parent e25cca86f1
commit 1e87f21334
2 changed files with 137 additions and 23 deletions

View file

@ -1,34 +1,27 @@
#ifndef FIREWALL_HPP
#define FIREWALL_HPP
#ifndef ESP32_FIREWALL_HPP
#define ESP32_FIREWALL_HPP
#include "API.hpp"
#include "Utils.hpp"
#include "Storage.hpp"
namespace fw
{
class Firewall : public API
class Firewall : public Storage
{
private:
public:
Firewall(const char *, const char *, const char *, const char *, const String ip, const uint16_t = 8080);
Firewall();
~Firewall();
void handle_api_client();
bool check_client(WiFiClient);
};
Firewall::Firewall(const char *cert, const char *key, const char *username, const char *password, const String ip, const uint16_t port)
: API(cert, key, username, password, ip, port) {}
Firewall::~Firewall() {}
void Firewall::handle_api_client()
{
handle_client();
}
bool Firewall::check_client(WiFiClient client)
{
if (client.remoteIP())
return false;
else
return true;
}
firewall_rule_t *get_rule_head();
void add_rule_to_firewall(firewall_rule_t *rule_ptr, const bool save_in_eeprom = true);
firewall_rule_t *add_rule_to_firewall(String source, String destination, String port_from, String port_to, String protocol, String target);
firewall_rule_t *get_rule_from_firewall(const uint8_t key);
ok_t delete_rule_from_firewall(const uint8_t key);
protected:
uint8_t amount_of_rules = 0;
firewall_rule_t *rule_head = NULL;
};
}
#endif