SneakyDave
Well-known member
I thought I'd start out simple to see if I could create a small add-on for myself and other Cloudflare users.
I'm just starting out with xF add-ons, but I'm familiar with PHP and MVC frameworks.
This add-on would simply replace the $_SERVER['REMOTE_ADDR'] (Cloudflare IP) with $_SERVER['HTTP_CF_CONNECTING_IP'] (true visitor IP) if the HTTP_CF_CONNECTING_IP was set.
Right now, the way I do this, is to put this code in the config.php file, which is an ugly brute force option. So I thought there'd be a way to do this with a code event listener.
Running through the code and the event listeners, I thought a good place to do this re-assignment would be in visitor_setup, but after doing a little more digging, its obvious that the REMOTE_ADDR is used in the Session class. I would need to do this re-assignment prior to that.
Going through debug, it doesn't look like there's anything that fires for the Session class, or I'm just not good at trying to find out where these things fire.
Am I correct in going down the road of using a code event listener? Am I correct in assuming that beings that I'm focusing on the Session class, there aren't any code event listeners that I can use?
Could I possibly extend the FrontController or AutoLoader to do this work?
I'm pretty thick skinned, so please call me an idiot if I've completely gone off the rails on how this can be accomplished.
Thanks in advance.
I'm just starting out with xF add-ons, but I'm familiar with PHP and MVC frameworks.
This add-on would simply replace the $_SERVER['REMOTE_ADDR'] (Cloudflare IP) with $_SERVER['HTTP_CF_CONNECTING_IP'] (true visitor IP) if the HTTP_CF_CONNECTING_IP was set.
Right now, the way I do this, is to put this code in the config.php file, which is an ugly brute force option. So I thought there'd be a way to do this with a code event listener.
Running through the code and the event listeners, I thought a good place to do this re-assignment would be in visitor_setup, but after doing a little more digging, its obvious that the REMOTE_ADDR is used in the Session class. I would need to do this re-assignment prior to that.
Going through debug, it doesn't look like there's anything that fires for the Session class, or I'm just not good at trying to find out where these things fire.
Am I correct in going down the road of using a code event listener? Am I correct in assuming that beings that I'm focusing on the Session class, there aren't any code event listeners that I can use?
Could I possibly extend the FrontController or AutoLoader to do this work?
I'm pretty thick skinned, so please call me an idiot if I've completely gone off the rails on how this can be accomplished.
Thanks in advance.