Skip to content

feat: added support for filters in WebServer library #9842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 13, 2024
Merged
Prev Previous commit
Next Next commit
fix: ON_STA_FILTER & ON_AP_FILTER
  • Loading branch information
ayushsharma82 committed Jun 12, 2024
commit 229d693932cf460091d7cec69479dd23ef95ba37
22 changes: 13 additions & 9 deletions libraries/WebServer/src/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
*/

#include <Arduino.h>

#if SOC_WIFI_SUPPORTED
#include "WiFi.h"
#endif

#include <esp32-hal-log.h>
#include <libb64/cdecode.h>
#include <libb64/cencode.h>
Expand Down Expand Up @@ -799,13 +804,12 @@ String WebServer::_responseCodeToString(int code) {
}
}

bool ON_STA_FILTER(WebServer &server) {
return (
(WiFi.localIP() != IPAddress(0, 0, 0, 0) && server.client().localIP() != IPAddress(0, 0, 0, 0))
&& WiFi.localIP() == server.client().localIP()
);
}
#if SOC_WIFI_SUPPORTED
bool ON_STA_FILTER(WebServer &server) {
return WiFi.STA.localIP() == server.client().localIP();
}

bool ON_AP_FILTER(WebServer &server) {
return WiFi.localIP() == server.client().localIP();
}
bool ON_AP_FILTER(WebServer &server) {
return WiFi.AP.localIP() == server.client().localIP();
}
#endif
1 change: 0 additions & 1 deletion libraries/WebServer/src/WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <functional>
#include <memory>
#include "FS.h"
#include "WiFi.h"
#include "Network.h"
#include "HTTP_Method.h"
#include "Uri.h"
Expand Down
Loading