cleanup main
This commit is contained in:
parent
d08a0599a6
commit
458e3fbc6f
1 changed files with 7 additions and 19 deletions
|
@ -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();
|
||||
}
|
Reference in a new issue