Jump to content

Module:Sensitive IP addresses/API

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 23:47, 24 July 2016 (sketch out plan of attack). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module provides functions for handling sensitive IP addresses.

-- Load modules
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType

local sensitivityReasons = {
	political = true,
	technical = true,
}

-- Plan of attack:
-- * Load the data from Module:Sensitive IP addresses/list via a formatting module
--   at Module:Sensitive IP addresses/data
--   * This module will do preprocessing that must be done for every query
-- * Make an API so that other modules can query this module for data about
--   sensitive IPs and ranges.
--   * Export query results as both a Lua table and as JSON
-- * Use this API to create a table to be used in
--   [[Template:Sensitive IP addresses]].

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p = {}

function p.isValidSensitivityReason(s)
	checkType('isValidSensitivityReason', 1, s, 'string')
	return sensitivityReasons[s] ~= nil
end

function p.getSensitivityReasons()
	local ret = {}
	for reason in pairs(sensitivityReasons) do
		ret[#ret + 1] = reason
	end
	table.sort(ret)
	return ret
end

return p