all working as intended
This commit is contained in:
parent
a08ea4803b
commit
a8cd48c756
3 changed files with 16 additions and 3 deletions
|
@ -5,7 +5,7 @@ namespace firewall
|
||||||
Firewall::Firewall()
|
Firewall::Firewall()
|
||||||
{
|
{
|
||||||
this->amount_of_rules = retrieve_settings_value("amount_of_rules");
|
this->amount_of_rules = retrieve_settings_value("amount_of_rules");
|
||||||
for (uint8_t i = 0; i < this->amount_of_rules; i++)
|
for (uint8_t i = 1; i <= this->amount_of_rules; i++)
|
||||||
{
|
{
|
||||||
firewall_rule_t *rule_ptr = retrieve_firewall_rule(i);
|
firewall_rule_t *rule_ptr = retrieve_firewall_rule(i);
|
||||||
add_rule_to_firewall(rule_ptr);
|
add_rule_to_firewall(rule_ptr);
|
||||||
|
@ -96,6 +96,9 @@ namespace firewall
|
||||||
}
|
}
|
||||||
free(current_rule_ptr);
|
free(current_rule_ptr);
|
||||||
this->amount_of_rules--;
|
this->amount_of_rules--;
|
||||||
|
store_settings_value("amount_of_rules", this->amount_of_rules);
|
||||||
|
if (this->amount_of_rules != 0)
|
||||||
|
store_all_firewall_rules(head);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,16 @@ namespace firewall
|
||||||
return rule_ptr;
|
return rule_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Storage::store_all_firewall_rules(firewall_rule_t *head)
|
||||||
|
{
|
||||||
|
firewall_rule_t *temp = head;
|
||||||
|
while (temp != NULL)
|
||||||
|
{
|
||||||
|
store_firewall_rule(temp);
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Storage::store_firewall_rule(firewall_rule_t *rule_ptr)
|
void Storage::store_firewall_rule(firewall_rule_t *rule_ptr)
|
||||||
{
|
{
|
||||||
char rulename[9]; // fwRule99\n
|
char rulename[9]; // fwRule99\n
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "Preferences.h"
|
#include "Preferences.h"
|
||||||
#include "SPIFFS.h"
|
#include "SPIFFS.h"
|
||||||
#include "FirewallTypes.h"
|
#include "FirewallTypes.h"
|
||||||
#include "mbedtls/md.h"
|
|
||||||
#include "SSLCert.hpp"
|
#include "SSLCert.hpp"
|
||||||
|
|
||||||
namespace firewall
|
namespace firewall
|
||||||
|
@ -20,10 +19,11 @@ namespace firewall
|
||||||
void store_settings_value(const char *, const uint8_t);
|
void store_settings_value(const char *, const uint8_t);
|
||||||
|
|
||||||
firewall_rule_t *retrieve_firewall_rule(const uint8_t);
|
firewall_rule_t *retrieve_firewall_rule(const uint8_t);
|
||||||
|
void store_all_firewall_rules(firewall_rule_t *);
|
||||||
void store_firewall_rule(firewall_rule_t *);
|
void store_firewall_rule(firewall_rule_t *);
|
||||||
|
|
||||||
httpsserver::SSLCert *retrieve_certificate();
|
httpsserver::SSLCert *retrieve_certificate();
|
||||||
void store_certificate(httpsserver::SSLCert *certificate);
|
void store_certificate(httpsserver::SSLCert *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Storage();
|
Storage();
|
||||||
|
|
Reference in a new issue