Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get real client IP
(09-12-2020, 09:29 PM)mazluta Wrote: i build Mailer Server using idHTTPServer
i want to get the client IP  (the best will be in commanget).

but every thing i tried give me the IP of my Router.

Because the router is the actual client to your server. The outside client is connected to the router, not to your server directly.

When your server is behind a router, there is no way for your server to get the outside client's IP/Port directly from the TCP connection. That information is simply not available at the TCP level. So, your only hope to get that info would be if the outside client (or more likely the router) sends that info to your server via a custom "X-..." header in the forwarded HTTP requests, for example in the "X-Forwarded-For" header. Have you tried looking at all available HTTP headers (in the ARequestInfo.RawHeaders property) to see if the desired client info is present there?

(09-12-2020, 09:29 PM)mazluta Wrote: the request is always come to the server. but i dont know from whom.

The AContext.Binding.PeerIP and AContext.Binding.PeerPort properties are still relevant, for purposes of differentiating clients. They still represent the outside client, they will simply have IP/Port values representing the router's LAN endpoint for the outside client. They will still be unique and addressable, since that is required for the TCP connection between your server and the client to work properly.


Messages In This Thread
get real client IP - by mazluta - 09-12-2020, 09:29 PM
RE: get real client IP - by rlebeau - 09-14-2020, 05:59 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)