#include "theSecrets.h" #include "theCerts.h" #ifdef ESP32 #include "WiFi.h" #elif defined(ESP8266) #include "ESP8266WiFi.h" #endif #include "Firewall.hpp" #include "API.hpp" fw::Firewall *firewall; fw::API *firewallApi; WiFiServer wifiServer(80); void setup_wifi() { Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.begin(ssid, psk); Serial.printf("Attempting to connect to WPA SSID: %s\n", ssid); while (WiFi.status() != WL_CONNECTED) { Serial.print('.'); delay(1000); } Serial.println(); Serial.print("IP Address: "); Serial.println(WiFi.localIP()); wifiServer.begin(); } void setup() { setup_wifi(); firewall = new fw::Firewall(); firewallApi = new fw::API(firewall, cert, key, username, password); } void loop() { firewallApi->handle_client(); WiFiClient client = wifiServer.available(); if (client) { if (firewall->is_client_allowed(client)) Serial.println("allowed"); else Serial.println("rejected"); client.stop(); } }