0
\$\begingroup\$

I have checked the following project and similar other webservers. https://randomnerdtutorials.com/esp8266-web-server/

My main issue with this code is that there is no way to restrict where can clients connect from. A function is available client.RemoteIP() to determine the client's IP but this only seems to be possible if the client sends a valid HTTP request otherwise the code does not even go into the if (client) { // If a new client connects, section.

The problem with this if someone just telnets on the port that will BLOCK all connections for other clients (the main loop will be blocked as well) as long as his connected.

Isn't there a lower IP layer filtering possible with the ESP8266 to avoid this?

Even if there is what can be done to force anyone, to disconnect after X seconds?

The Wifihttps server provides an example for timeout:

https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiHTTPSServer/WiFiHTTPSServer.ino

if (millis() > timeout) {
    Serial.println("timeout");
    client.flush();
    client.stop();
    return;
  }

The problem with this again that it will only be applied for valid clients not if someone connects on the port with telnet.

\$\endgroup\$
  • \$\begingroup\$ use the http server lib, not the low level networking lib. you can't use telnet on the http server, and it gives you a lot of control in an easy to use package. \$\endgroup\$ – dandavis May 17 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.