If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Announcement
Collapse
No announcement yet.
How does a script determine the store's own IP address?
How does a script determine the store's own IP address?
I know about s.remote_addr; today I need a way for a script to read its own IP address, the one for the server it's running on. Is there a system variable for that?
Appears to be only other "addr" available. I think that is what IP is returned, along with the absolute path if you needed the origin of the script that is running. (A *nix thing).
s.server_addr would have the site IP. Depending on what you are planning to use it for, you should not operate on the assumption that the value does not change from one request to the next. IF the site in question is dual stacked, meaning IPv4 and IPv6-enabled, the value will change based on the visiting traffic and whether or not it is IPv4 or IPv6. If the site is running on multiple servers with either a CDN or load balancer in front, the value will change based on the web server that handles the request as they'd all have their own independent addressing not seen by the public, but seen by Empresa.
The store in question is one of yours: What server setup are they running? Actually, it won't hurt my module if the address changes from one request to the next; I'm using it for authentication, not session tracking. I do need to know all the possible addresses in advance, so I can enter them into the whitelist setting.
I cut the store out; best to not post dev site addresses in case it ends up crawled (but it is hopefully password protected too per normal setup policy on our side).
We're slowly rolling IPv6 out to all sites (new sites have been able to use it the past few years), so it will eventually be activated on any given site. If the customer requests it be added, we can add it immediately so you can have the data now rather than worry about it possibly showing up later. Just keep in mind code written against those addr variables should never make the assumption that the value will conform to <number>.<number>.<number>.<number> since an IPv6 address differs, and either one could populate that field. We've run into issues with certain payment modules that try to do IP-based decision making when the value is IPv6.
Comment