diff --git a/ESPFirewall/src/main.cpp b/ESPFirewall/src/main.cpp index c0aa9ac..04b8c05 100644 --- a/ESPFirewall/src/main.cpp +++ b/ESPFirewall/src/main.cpp @@ -8,9 +8,11 @@ #endif #include "Firewall.hpp" +#include "API.hpp" fw::Firewall *firewall; -String ip = "0.0.0.0"; +fw::API *firewallApi; + WiFiServer wifiServer(80); void setup_wifi() @@ -26,32 +28,18 @@ void setup_wifi() } Serial.println(); Serial.print("IP Address: "); - ip = WiFi.localIP().toString(); - Serial.println(ip); + Serial.println(WiFi.localIP()); wifiServer.begin(); } void setup() { setup_wifi(); - firewall = new fw::Firewall(cert, key, username, password, ip, 8080); + firewall = new fw::Firewall(); + firewallApi = new fw::API(firewall, cert, key, username, password); } void loop() { - WiFiClient client = wifiServer.available(); - if (client) - { - Serial.print("Client connected with IP:"); - Serial.println(client.remoteIP()); - - if (firewall->check_client(client)) - Serial.println("good client"); - else - Serial.println("bad client"); - - client.stop(); - Serial.println("Client disconnected"); - } - firewall->handle_api_client(); + firewallApi->handle_client(); } \ No newline at end of file