Template talk:IP range calculator

Future of Template:Blockcalc
Background:
 * I noticed a post by Diannaa at WP:VPT saying that the range block calculator at wmflabs had not worked for over a month.
 * I wrote Module:IPblock and Template:Blockcalc to emulate the calculator because requiring hand calculations seems absurd. It is likely that an operator at wmflabs could quickly reset the calculator, and that would make it work again until the next failure. However, I think a module would be more satisfactory because it should do the job and, if needed, its maintenance could be taken over by several of the skilled module writers.
 * If anyone examines the code, you will see that it checks each IP entered. On thinking about it, I see that is completely unnecessary as it only needs to check the lowest and highest IPs. I'll probably fix that and do some more thorough testing. I know the module would be used rarely, but it seems that a reliable tool of some kind will be needed forever.

Possible extra features:
 * 1) Perhaps could check whether using two or three ranges would be better than one, and if multiple ranges would cover the same IPs with fewer overall blocked IPs, they could be shown as well as the single range.
 * 2) A warning could be shown if any of the IPs in the range are sensitive per WP:SIP.
 * 3) A fair bit of code would be needed, but it would be possible to handle IPv6.
 * 4) Anything else?

Would further development be worthwhile? Or, should the wmflabs tool be fixed? If this template is wanted, how should admins be made aware of its existence? I'm pinging several active admins who are listed at Category:Wikipedia administrators willing to make range blocks: Barek ∙ EncMstr ∙ Gfoley4 ∙ HJ Mitchell ∙ Legoktm ∙ Mike V ∙ MusikAnimal ∙ PhilKnight ∙ Xaosflux ∙ Zzuuzz. Feedback wanted! Johnuniq (talk) 10:52, 14 December 2014 (UTC)
 * Just a quick note for now: I've been using NativeForeigner's range block calculator as a substitute for the one on WMF labs. You might want to check it out. Mike V  •  Talk  11:11, 14 December 2014 (UTC)


 * I tend to do this stuff in my head and through DNS/WHOIS tools, but a range block calculator is essential for any range blocking admin. A module (I'm not too familiar with them) sounds useful. If you're going to write this, though it would be novel here, I suggest you also look at the approach here, sometimes required and usually resulting in fewer blocked IPs. Also, this template doesn't actually explain how to use it. Are you supposed to find a page to preview it on? -- zzuuzz (talk) 11:43, 14 December 2014 (UTC)


 * I usually do them in my head too, but it can be useful; suggest having the output include the network and broadcast address for the range as well to make it clear. — xaosflux  Talk 15:47, 14 December 2014 (UTC)


 * The tool at Special:CheckUser still seems to work, which is what I generally use. PhilKnight (talk) 17:11, 14 December 2014 (UTC)


 * Without the WMF tool, I have been using a couple other sites to confirm the calcs in my head - but hadn't found one yet that worked as well as I would like. Blockcalc looks like a usable tool; I'll try it a couple times before deciding how I feel about using a template v. a web site. --- Barek (talk • contribs) - 17:40, 14 December 2014 (UTC)


 * Since the disappearance of the tool, I work out range blocks with a hex calculator and trial + error. Fortunately my errors are always rejected by the block page:  I tend to get the number of bits backwards and a range of more than 16 bits IP4 is illegal.  Still can't remember if that means x.x.x.x/15 or x.x.x.x/17 is the right one.  Would love to have something to easily get this right the first time.  —EncMstr (talk) 17:42, 14 December 2014 (UTC)


 * I also use NativeForeigner's tool; before a kind person pointed me to that, I used another one linked from User:HJ Mitchell/Useful things. If there's a built-in calculator available to CUs, couldn't we file a request on Phabricator for it to made available to admins? The one feature NF's tool doesn't have that the Labs tool did was that the Labs tool produced a list of IPs from which (anonymous) edits had been made recently and linked to their contributions. There is a range contribs tool, but it seems o be up and down sporadically. HJ Mitchell  &#124;  Penny for your thoughts?  17:52, 14 December 2014 (UTC)


 * In response to your other question, using this niche category you have probably pinged the admins who need this tool the least (although well versed in what calculators should do), though I repeat that I consider a calculator to be essential ( .. and that there is no existing stable tool). The people who need this the most imo are those outside the category, who only rarely have to make range blocks (or are just learning to do it in their head :) Maybe the admin noticeboard for publicity for user trials. I also agree linking this to range contribs, existing and previous blocks in the range, and other such goodies would be useful. But a stable accessible tool to find the nearest single range to block when there's a spree going on would be an excellent foundation. -- zzuuzz (talk) 20:48, 14 December 2014 (UTC)

Thanks for the responses. It appears there is no need for this template given the link posted by Mike V which seems to handle everything. In principle, such an externally hosted tool is not desirable as it could be used to determine the IP address of admins who do range blocks, but there is good reason to trust the website concerned. The tool at Special:CheckUser mentioned by PhilKnight should be made generally available. Re the module used by this template: it could be extended to do what I mentioned above, but a module cannot give a list of recent contributions from IPs in the affected range. Johnuniq (talk) 05:45, 15 December 2014 (UTC)
 * Meant to reply, never got around to it. You'll have to take my word that I'm not checking IPs (nor storing any IPs sent to the tool, also code for it is publicaly accessbile here https://github.com/bpcox/rangecalc-improved.) That being said I've meant to migrate it onto labs for a while now, when I first tried it didn't have python 3 support but hopefully in the near future I'll have it up and operating. The two things my tool does (that the Special:CheckUser tool does not, is it semi-smartly tries to identify subranges (if you input a lot of IPs over numerous CIDR ranges), and it supports IPv6 addresses. (Also supports ipv4 ranges but I'm not sure how useful that is) NativeForeigner Talk 22:45, 6 October 2015 (UTC)
 * @NativeForeigner: Sorry for the implications in my comment but I seldom resist an opportunity to remind people about security issues. I noticed the cleverness of your code and promptly binned mine! Johnuniq (talk) 02:44, 7 October 2015 (UTC)
 * Probably first time anything I've coded has been referred to as clever haha. But yeah, I actually thought similar. I would prefer to have it on toolserv but such are things. NativeForeigner Talk 01:50, 8 October 2015 (UTC)
 * @NativeForeigner: I have done a major upgrade of the module, see below. I partly wanted to do this because a module running on enwiki would be better than a tool at wmflabs which seems to have trouble from time to time. Another reason is that I've had an itch to see what is involved in handling IPv6 for several years and blockcalc seemed a good opportunity. Once I started I got hooked and have done a bunch of complex stuff—I'm not entirely happy with the results but I don't know what would be better. I'm just letting you know, and in due course I will ping others from the discussion above to slowly announce that blockcalc is an alternative that people might want to test. Johnuniq (talk) 03:48, 1 February 2016 (UTC)

Version February 2016
A major upgrade is now available with these features: See blockcalc for documentation. The results are not always helpful as too many alternatives may be shown. Also, entering a bunch of IPs from someone using proxies generates a useless list since many ranges are being used.
 * IPv4 and IPv6 addresses are handled.
 * If both IPv4 and IPv6 addresses are given, the result lists IPv4 ranges and IPv6 ranges separately.
 * Input to the template can be wikitext copied from a noticeboard; the template extracts any IPv4 or IPv6 addresses found in its parameters.
 * Where possible, each range has a link to show contributions from the range. For a single IPv4 or IPv6 address, Special:Contributions is used. For an IPv4 range, xtools/rangecontribs is used with a request to list contributions made in the last month. There is no link for an IPv6 range because no tool with that ability is known.
 * The result may list several alternatives, starting with a single range. Each alternative covers the given addresses with fewer other IPs affected.
 * By default, IPv4 ranges are not shorter than /16, and IPv6 ranges are not shorter than /19.

If anyone has ideas on how to improve the results, please let me know. Do any existing tools provide a feature which possibly should be implemented for this template?

I'll probably ping a few people who have commented here. When blockcalc seems ready for a more general announcement I'll post at WP:AN and may add a mention at WP:ADMINTOOLS and WP:ADMINGUIDE/B. Johnuniq (talk) 03:32, 1 February 2016 (UTC)
 * Looks fine. I don't really understand lua in any meaningful way. It's great we have an on wiki tool. NativeForeigner Talk 10:43, 1 February 2016 (UTC)
 * Thanks. I'll ping some others from above to let them know about the upgraded blockcalc in order to spread the word that this enwiki template now handles most wanted features. Barek ∙ Diannaa ∙ EncMstr ∙ HJ Mitchell ∙ Mike V ∙ PhilKnight ∙ Xaosflux ∙ Zzuuzz. Johnuniq (talk) 03:40, 2 February 2016 (UTC)
 * So how do I test drive it? —EncMstr (talk) 05:23, 2 February 2016 (UTC)
 * I put some more examples in my sandbox2 (permalink). Let me know if there are any questions/comments. Johnuniq (talk) 06:18, 2 February 2016 (UTC)
 * Just a note to let you know that the blockcalc template is my preferred range calc tool. I use it all the time and look forward to checking out these improvements. Thanks, — Diannaa 🍁 (talk) 14:36, 2 February 2016 (UTC)

Version November 2017
The template now uses Special:Contributions to display IP and IP range contributions, by default. That is possible due to work by MusikAnimal per an announcement at WP:AN.

The previous version displayed contributions in the last month by default, and accepted |months=2 for the last 2 months, etc. The new version ignores the  parameter and relies on the standard behavior of Special:Contributions.

Use parameter old to display the links from the old system, for example:

Johnuniq (talk) 09:40, 15 November 2017 (UTC)
 * Thanks! I should mention that the days of the old XTools Rangecontribs tool are numbered. When this happens it will redirect to Special:Contributions, but I'll try to update all the on-wiki templates, too. &mdash; MusikAnimal  talk  16:04, 15 November 2017 (UTC)