cleanup main

This commit is contained in:
Florian Hoss 2022-05-03 20:28:17 +02:00
parent d08a0599a6
commit 458e3fbc6f

View file

@ -8,9 +8,11 @@
#endif #endif
#include "Firewall.hpp" #include "Firewall.hpp"
#include "API.hpp"
fw::Firewall *firewall; fw::Firewall *firewall;
String ip = "0.0.0.0"; fw::API *firewallApi;
WiFiServer wifiServer(80); WiFiServer wifiServer(80);
void setup_wifi() void setup_wifi()
@ -26,32 +28,18 @@ void setup_wifi()
} }
Serial.println(); Serial.println();
Serial.print("IP Address: "); Serial.print("IP Address: ");
ip = WiFi.localIP().toString(); Serial.println(WiFi.localIP());
Serial.println(ip);
wifiServer.begin(); wifiServer.begin();
} }
void setup() void setup()
{ {
setup_wifi(); 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() void loop()
{ {
WiFiClient client = wifiServer.available(); firewallApi->handle_client();
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();
} }