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
#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();
}