WIFIO is a dual Arduino WIFI module (ESP8266+ATMEGA328P) FCC approve-able with transferable licence. Can use the 328P for I/O expansion also...

Moderator: igrr

User avatar
By Hans53
#48608 Hi everyone
I had a Webserver running on an Arduino Uno using the “Ethercard” library together with “tinyFAT” SD library
There it was possible to get the target IP address, if a section was uncommented in the example code

/* uncomment this if you want to have printed the ip of the target browser
Serial.print("content send to ");
for(int i=30; i<34; i++) {
Serial.print(Ethernet::buffer[i]);
if (i<33) Serial.print(".");
}
Serial.println(" ");
*/

Is it possible to read the target IP using the “ESP8266WebServer”library?
The original web server in running perfectly on the ESP8266, but it would be real nice to know who is trying to access it
HansP
User avatar
By Hans53
#48718
martinayotte wrote:With the ESP8266WebServer library, you can simply do a Serial.print(webserver.client.remoteIP().toString())


Hi
I tried with this
But the code did not compile



#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

Server declaration
ESP8266WebServer server(80);

In setup
void setup() {
server.onNotFound(handleNotFound);
}

void handleNotFound(){
String HTTP_req = server.uri();
if (loadFromSdCard(server.uri())) return;
if(HTTP_req.indexOf("ajax_switch") > -1){
Serial.print(server.client.remoteIP().toString());
handle_Ajax(1);
}

Error message:
Arduino: 1.6.9 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 4M (Min SPIFFS), ck, Disabled, None"
C:\Users\Hans\Documents\Arduino\ESP_Ajax_Server\ESP_Ajax_Server.ino: In function 'void handleNotFound()':
ESP_Ajax_Server:141: error: 'server.ESP8266WebServer::client' does not have class type
Serial.print(server.client.remoteIP().toString());
exit status 1
'server.ESP8266WebServer::client' does not have class type