Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get real client IP
#1
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.
from on connect
from start session
from request
from response
from conext

what ever bind or peer or host  - all point to MyExternal IP (the router ip at my internet provider).

i use no-ip. that direct all to my IP from the to my router. there i have forward to 192.168.1.50.

my server is there, wait for port 5555.

the request is always come to the server. but i dont know from whom.

thanks for help
Reply
#2
(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.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)