From a8cd48c756ba3b159741489e28948b656ace7ad2 Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Wed, 20 Apr 2022 21:35:36 +0200 Subject: [PATCH] all working as intended --- SourceCode/arduino/lib/Firewall/esp32Firewall.cpp | 5 ++++- SourceCode/arduino/lib/Firewall/esp32Storage.cpp | 10 ++++++++++ SourceCode/arduino/lib/Firewall/esp32Storage.hpp | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/SourceCode/arduino/lib/Firewall/esp32Firewall.cpp b/SourceCode/arduino/lib/Firewall/esp32Firewall.cpp index b1ceb7f..223c305 100644 --- a/SourceCode/arduino/lib/Firewall/esp32Firewall.cpp +++ b/SourceCode/arduino/lib/Firewall/esp32Firewall.cpp @@ -5,7 +5,7 @@ namespace firewall Firewall::Firewall() { 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); add_rule_to_firewall(rule_ptr); @@ -96,6 +96,9 @@ namespace firewall } free(current_rule_ptr); 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; } diff --git a/SourceCode/arduino/lib/Firewall/esp32Storage.cpp b/SourceCode/arduino/lib/Firewall/esp32Storage.cpp index 882dda8..cbdb75b 100644 --- a/SourceCode/arduino/lib/Firewall/esp32Storage.cpp +++ b/SourceCode/arduino/lib/Firewall/esp32Storage.cpp @@ -61,6 +61,16 @@ namespace firewall 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) { char rulename[9]; // fwRule99\n diff --git a/SourceCode/arduino/lib/Firewall/esp32Storage.hpp b/SourceCode/arduino/lib/Firewall/esp32Storage.hpp index 558c23b..cd88378 100644 --- a/SourceCode/arduino/lib/Firewall/esp32Storage.hpp +++ b/SourceCode/arduino/lib/Firewall/esp32Storage.hpp @@ -4,7 +4,6 @@ #include "Preferences.h" #include "SPIFFS.h" #include "FirewallTypes.h" -#include "mbedtls/md.h" #include "SSLCert.hpp" namespace firewall @@ -20,10 +19,11 @@ namespace firewall void store_settings_value(const char *, 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 *); httpsserver::SSLCert *retrieve_certificate(); - void store_certificate(httpsserver::SSLCert *certificate); + void store_certificate(httpsserver::SSLCert *); public: Storage();