Cloudflare IP Referral Support

Started by C. Davis, November 04, 2015, 11:55:17 PM

Previous topic - Next topic

C. Davis

Link to Mod

Introduction
Some of you may have been wanting to use Cloudflare with your forums and noticed that it uses the IP of your server as the $_SERVER["REMOTE_ADDR"] causing issues with banning people and even displaying people's IPs. I've found a VERY simple work around and implemented it in this simple mod. It pretty much checks if the Remote address is your server IP or inside of cloudflare's ip range that they own, it will change the $_SERVER["REMOTE_ADDR"] to the Cloudflare user address.

The IP ranges in the list come from here: https://www.cloudflare.com/ips

As far as I'm aware it is 100% working.

Installation Instructions

If you do not have Tapatalk installed, use only cloudflare_ip_refferal_support_v1.zip

If you have Tapatalk, use only cloudflare_ip_refferal_support_tapatalk_v1.zip

Changelog
v1.2-
Cloudflare IPs changed into an array

v1-
Initial Release

License

The MIT License (MIT)

Copyright (c) 2015 Connor Davis

Permission is hereby granted,
free of charge, to any person obtaining a copy
of this software and associated
documentation files (the "Software"), to deal
in the Software without restriction,
including without limitation the rights
to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell
copies of the Software, and to permit persons
to whom the Software is
furnished to do so, subject to the following conditions:


The above copyright notice and this permission notice shall be included in
all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED
"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE
SOFTWARE.

dougiefresh

@C. Davis: Nice mod!  I noticed that you had two versions of the same mod, so I did a comparsion between both versions and found that you can merge both versions by changing this:
Code (Find) Select
<file name="$boarddir/mobiquo/mobiquo.php">
to this:
Code (Replace) Select
<file name="$boarddir/mobiquo/mobiquo.php" error="skip">
This enables you to only distribute one package for both situations.  Hope this helps you!

Mojohaza1

I installed this last week and initially all semed to be working fine then I notice one user has an IP of "0.0.0.0" showing in the users online section.

This or some other factor seems to make it generate literally tens of errors per minute.


Just a taste
8: Undefined offset: 3
?topic=12446.0 Today at 12:23:38 am
8: Undefined offset: 2
?topic=12446.0 Today at 12:23:38 am
8: Undefined offset: 1
?topic=12446.0 Today at 12:23:38 am
8: Undefined offset: 3
?topic=12446.0 Today at 12:23:38 am
8: Undefined offset: 2
?topic=12446.0 Today at 12:23:38 am


More precisely: Undefined offset: 3
File: (removed the start) /Themes/default/smfhacks_templates/global-hf.template.php (main sub template - eval?)
Line: 382


When I uninstall the mod the errors instantly stop.

Conflict with another of my mods probably?

Also, your description says download v1 zip, your change log says you're at v1.2 and the actual latest version is 1.3 according to the mods page.
Make it clearer?

N64dude

I installed this and my forum comes up with this

Fatal error: Cannot redeclare ip_in_network() (previously declared in /home/thexephy/public_html/originalforum/index.php:5) in /home/thexephy/public_html/originalforum/index.php on line 92

how can i fix this so i can tell my friend who created my forum, to sort it out for me.

Kindred

you appear to have installed the mod twice.

You will have to manually remove the duplicated code (probably from several areas)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Vagrancy

I get the 0.0.0.0 address too (currently for only 1 account), both on Who's Online and in Track User. No errors have been generated as of yet, however.

chrishicks

I'm 99.99% sure a 0.0.0.0 IP is when a user is on IPv6. If I use my account through my VPN I will have an actual IP because I connect to my site via IPv4 and when I turn off the VPN I connect with IPv6. I've tested this using a few Firefox add-ons and can easily reproduce it with other browsers and computers in the house as well. In your Cloudflare settings(Network - IPv6 Compatibility) you can turn off IPv6 if you want to test it to see if that helps with the 0.0.0.0 issue. It never bothered me so I never disabled the setting myself so I can't say for sure if it's the exact problem/solution but it's worth a try.

Vagrancy

Nice find, I will check that out immediately.

MultiformeIngegno

RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

chrishicks

Looking at the IPs in their list the only new one I see is 131.0.72.0/22(since this mod only uses IPv4). I just added the following to the code for the mod in index.php.

'15' => array(
'ip' => '131.0.72.0',
'range' => '22'
),



mrhope

It doesn't appear that C. Davis is still active. However, I was planning on testing this mod tomorrow and thought it would be worth mentioning that on the Cloudflare IP page (https://www.cloudflare.com/ips/), the following IP range was removed.

QuoteJun 7, 2017: 199.27.128.0/21 removed from ips-v4

Also, they have a new IP range (131.0.72.0/22). So, element 14 of the array should be updated to the following code.


'14' => array(
    'ip' => '131.0.72.0',
    'range' => '22'
),


If anyone has a suggestion on a better Cloudflare IP mod that's maintained, I'd also welcome suggestions.

mrhope

Attempting to install this with 2.0.18 I get the following error.

Quote
Incorrect string value: '''' for function inet_aton
File: /home/hope/public_html/forum/Sources/Subs.php
Line: 2650

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.18, while your database is at version 2.0.10. The above error might possibly go away if you execute the latest version of upgrade.php.

vbgamer45

That is normally an IPv6 error SMF 2.0.x doesn't support it by default

You can also fork this as your own mod too the license for the mod allows it.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mrhope

Thank you, you're right that error is related to IPv6 and CloudFlare no longer allows you to disable IPv6.

QuoteWhy can't I turn off IPv6?
At Cloudflare we believe in being good to the Internet and good to our customers. By moving on from the legacy world of IPv4-only to the modern-day world where IPv4 and IPv6 are treated equally, we believe we are doing exactly that. In the Cloudflare dashboard, IPv6 is no longer something you can toggle on and off, it's always just on.

So, I don't think I'd want to fork this mod since SMF does not support IPv6 by default. Is there a method of suggesting this mod get removed. Without IPv6 support, this mod isn't going to resolve issues for anyone running Cloudflare.

vbgamer45

There is a mod that adds ipv6 to smf 2.0.x https://custom.simplemachines.org/mods/index.php?mod=3051

Otherwise SMF 2.1 would be the way to go
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

LWillisjr

I realize this is an old topic. But I am wondering what any of you are doing if your site uses CloudFlare. I am not able to use IP addresses on our forum as they all come in the CloudFlare range. With SMF 2.1.3 now I am not longer able to use this mod. It is not compatible. Does anyone have a fix or know of a different mod that will correctly report IP addresses for users?


Advertisement: