This commit is contained in:
Florian Hoss 2022-05-02 20:49:18 +02:00
parent 09a04b60a9
commit 3cf4f4445a
3 changed files with 10 additions and 16 deletions

View file

@ -187,12 +187,12 @@ namespace fw
return false; return false;
else else
{ {
return this->server->hasArg("source") || for (uint8_t i = 0; i < firewall_fields_amount; i++)
this->server->hasArg("destination") || {
this->server->hasArg("protocol") || if (!this->server->hasArg(firewall_fields[i]))
this->server->hasArg("port_from") || return false;
this->server->hasArg("port_to") || }
this->server->hasArg("target"); return true;
} }
} }

View file

@ -54,11 +54,6 @@ namespace fw
uint16_t server_port; uint16_t server_port;
void handle_client(); void handle_client();
String get_url_base(); String get_url_base();
String protocol_to_string(firewall_protocol_t &protocol);
firewall_protocol_t string_to_protocol(String &protocol);
String target_to_string(firewall_target_t &target);
firewall_target_t string_to_target(String &target);
String response_code_to_string(const uint16_t response_code);
public: public:
API(const char *cert, const char *key, const char *username, const char *password, const String ip, const uint16_t port); API(const char *cert, const char *key, const char *username, const char *password, const String ip, const uint16_t port);

View file

@ -39,16 +39,15 @@ namespace fw
uint8_t key; uint8_t key;
char source[IPV4ADDRESS_LENGTH]; char source[IPV4ADDRESS_LENGTH];
char destination[IPV4ADDRESS_LENGTH]; char destination[IPV4ADDRESS_LENGTH];
uint16_t port_from; // port is max 65565 uint32_t port_from; // port can be max 65565
uint16_t port_to; uint32_t port_to; // range of uint16_t: 0 to 65535
firewall_protocol_t protocol; firewall_protocol_t protocol;
firewall_target_t target; firewall_target_t target;
struct firewall_rules *next; struct firewall_rules *next;
} firewall_rule_t; } firewall_rule_t;
const byte numChars = 12; static const uint8_t firewall_fields_amount = 6;
const char firewall_fields[][numChars] = { const char firewall_fields[firewall_fields_amount][12] = {
"key",
"source", "source",
"destination", "destination",
"port_from", "port_from",