Page MenuHomePhabricator

Need documentation for ip_in_range()
Closed, ResolvedPublic

Description

Author: alj62888

Description:
There is no documentation on this function and guessing has got me nowhere.

I tried this:

ip_in_range(user_name, "66.23.0.0/16")

but no go. Is a user_ip variable no available? Does the user_name hold ip addresses for anonymous users? I need to check the IPs of registered users.


Version: unspecified
Severity: normal

Details

Reference
bz55997

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:23 AM
bzimport added a project: AbuseFilter.
bzimport set Reference to bz55997.
bzimport added a subscriber: Unknown Object (MLST).

Call is "ip_in_range(ip, range)" and that is delegated to MediaWiki's IP::isInRange

A help text for the scroll down box on [[Special:AbuseFilter/test]] exists ("Is IP in range? (ip_in_range)")

alj62888 wrote:

Andre, the main question is what variable to use for the first parameter for the user's IP address.

The AbuseFilter does not allow you to use the IP address of a registered user. The ip_in_range function is supposed to be used for anonymous users, when you want a filter to target a specific range rather than everyone.

alj62888 wrote:

Kunal, why not? Is there some wiki philosophy or guiding principle that I am not aware of? Confused.

With the abusefilter-private user right, you can see the ip of the user, which trigged the filter. On WMF wikis this is not available, due to private policy. Only CheckUsers are allowed to see the ip of a user.

It looks like there is no way to filter against this field, because than the filter and the log details must be hidden to avoid other users to see the ip or with help of the filter regex to determine a possible ip.

alj62888 wrote:

My solution was to create a new filter variable, user_ip. So, the IP doesn't need to be shown in the log. It's not even worth me pasting the code it's so easy.

Glaisher subscribed.

It is documented at https://www.mediawiki.org/wiki/Extension:AbuseFilter/Rules_format#Functions which is linked from Special:AbuseFilter.