Pages: [1]   Go Down
Author Topic: Web server client IP  (Read 1014 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Offline Offline
Faraday Member
Karma: 149
Posts: 6119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It may be helpful to some if the ethernet library included a way to retrieve the client ip when using the server code. It can be used as a primitive firewall, preventing unauthorized client access. My library code changes to do this are already working.,135082.0.html
The modified ethernet library code is attached to reply #1. It uses the new ip address format (IPAddress) in the same manner as the other ip functions in Ethernet.cpp.

IPAddress clientIP = client.remoteIP();

edit: This is the total code added. Nothing else changed.

Code added to EthernetClient module:
// EthernetClient.h
IPAddress remoteIP();

// EthernetClient.cpp
IPAddress EthernetClient::remoteIP() {
    return Ethernet.remoteIP(_sock);

Code added to Ethernet module:
// Ethernet.h
IPAddress remoteIP(uint8_t s);

// Ethernet.cpp
IPAddress EthernetClass::remoteIP(uint8_t s) {
  IPAddress ret;
  return ret;
« Last Edit: December 02, 2012, 09:34:18 pm by SurferTim » Logged

Pages: [1]   Go Up
Jump to: