<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ASensitive_IP_addresses%2Fsummary</id>
	<title>Module:Sensitive IP addresses/summary - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ASensitive_IP_addresses%2Fsummary"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Sensitive_IP_addresses/summary&amp;action=history"/>
	<updated>2026-06-12T23:43:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:Sensitive_IP_addresses/summary&amp;diff=479407&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Sensitive_IP_addresses/summary&amp;diff=479407&amp;oldid=prev"/>
		<updated>2021-07-16T05:56:08Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local mSIPA_API = require('Module:Sensitive IP addresses/API')&lt;br /&gt;
local yesno = require('Module:Yesno')&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Strips a suffix from a CIDR string if the suffix is of a given bitLength.&lt;br /&gt;
-- bitLength must be either 32 or 128.&lt;br /&gt;
-- This is intended to allow CIDR strings to be represented as a single IP&lt;br /&gt;
-- address if this can be done unambiguously.&lt;br /&gt;
local function stripCIDRSuffix(cidr, bitLength)&lt;br /&gt;
	assert(bitLength == 32 or bitLength == 128, 'bitLength was not 32 or 128')&lt;br /&gt;
	local pattern = '/' .. bitLength .. '$'&lt;br /&gt;
	cidr = cidr:gsub(pattern, '')&lt;br /&gt;
	return cidr&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Takes an array of CIDR ranges and returns a new array with ranges&lt;br /&gt;
-- appropriate for printing.&lt;br /&gt;
local function prettifyRanges(ranges, bitLength)&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	for i, cidr in ipairs(ranges) do&lt;br /&gt;
		ret[i] = stripCIDRSuffix(cidr, bitLength)&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Turns an array of CIDR ranges into its string representation.&lt;br /&gt;
local function stringifyRanges(ranges, bitLength, separator)&lt;br /&gt;
	if not ranges then&lt;br /&gt;
		return ''&lt;br /&gt;
	end&lt;br /&gt;
	ranges = prettifyRanges(ranges, bitLength)&lt;br /&gt;
	return table.concat(ranges, separator)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._table(options)&lt;br /&gt;
	-- Return a wikitext table summarizing all the sensitive IP ranges&lt;br /&gt;
	-- and the entities they belong to.&lt;br /&gt;
&lt;br /&gt;
	-- Load dependencies&lt;br /&gt;
	local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
	-- Set up options&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	local rangeSeparator = options.rangeseparator or ', '&lt;br /&gt;
	local showNotes = yesno(options.notes)&lt;br /&gt;
	local nColumns = showNotes and 3 or 4&lt;br /&gt;
&lt;br /&gt;
	-- Get the entity data&lt;br /&gt;
	local data = mSIPA_API.query{entities={'all'}}&lt;br /&gt;
	if data['error'] then&lt;br /&gt;
		error(string.format('%s: %s', data['error'].code, data['error'].info))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Make the table root&lt;br /&gt;
	local root = mw.html.create('table')&lt;br /&gt;
	if options.class then&lt;br /&gt;
		root:addClass(options.class)&lt;br /&gt;
	end&lt;br /&gt;
	if options.style then&lt;br /&gt;
		root:cssText(options.style)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add main header&lt;br /&gt;
	if options.mainheader then&lt;br /&gt;
		root:tag('tr'):tag('td')&lt;br /&gt;
			:attr('colspan', nColumns)&lt;br /&gt;
			:cssText(options.cellstyle)&lt;br /&gt;
			:wikitext(options.mainheader)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add column headers&lt;br /&gt;
	local headerRow = root:tag('tr')&lt;br /&gt;
	headerRow&lt;br /&gt;
		:tag('th')&lt;br /&gt;
			:cssText(options.cellstyle)&lt;br /&gt;
			:wikitext('[[IPv4]]')&lt;br /&gt;
			:done()&lt;br /&gt;
		:tag('th')&lt;br /&gt;
			:cssText(options.cellstyle)&lt;br /&gt;
			:wikitext('[[IPv6]]')&lt;br /&gt;
			:done()&lt;br /&gt;
		:tag('th')&lt;br /&gt;
			:cssText(options.cellstyle)&lt;br /&gt;
			:wikitext('Description')&lt;br /&gt;
	if showNotes then&lt;br /&gt;
		headerRow:tag('th')&lt;br /&gt;
			:cssText(options.cellstyle)&lt;br /&gt;
			:wikitext('Notes')&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Add data cells&lt;br /&gt;
	for i, id in ipairs(data.sensitiveips['entity-ids']) do&lt;br /&gt;
		local entityData = data.sensitiveips.entities[id]&lt;br /&gt;
		if not options.reason or options.reason == entityData.reason then&lt;br /&gt;
			local dataRow = root:tag('tr')&lt;br /&gt;
			dataRow&lt;br /&gt;
				:tag('td')&lt;br /&gt;
					:cssText(options.cellstyle)&lt;br /&gt;
					:wikitext(stringifyRanges(&lt;br /&gt;
						entityData.ipv4Ranges,&lt;br /&gt;
						32,&lt;br /&gt;
						rangeSeparator&lt;br /&gt;
					))&lt;br /&gt;
					:done()&lt;br /&gt;
				:tag('td')&lt;br /&gt;
					:cssText(options.cellstyle)&lt;br /&gt;
					:wikitext(stringifyRanges(&lt;br /&gt;
						entityData.ipv6Ranges,&lt;br /&gt;
						128,&lt;br /&gt;
						rangeSeparator&lt;br /&gt;
					))&lt;br /&gt;
					:done()&lt;br /&gt;
				:tag('td')&lt;br /&gt;
					:cssText(options.cellstyle)&lt;br /&gt;
					:wikitext(lang:ucfirst(entityData.description))&lt;br /&gt;
			if showNotes then&lt;br /&gt;
				dataRow:tag('td')&lt;br /&gt;
					:cssText(options.cellstyle)&lt;br /&gt;
					:wikitext(entityData.notes)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.table(frame)&lt;br /&gt;
	local args = require('Module:Arguments').getArgs(frame, {&lt;br /&gt;
		frameOnly = true&lt;br /&gt;
	})&lt;br /&gt;
	return p._table(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>