Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sensitive IP addresses/summary
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local mSIPA_API = require('Module:Sensitive IP addresses/API') local yesno = require('Module:Yesno') local p = {} -- Strips a suffix from a CIDR string if the suffix is of a given bitLength. -- bitLength must be either 32 or 128. -- This is intended to allow CIDR strings to be represented as a single IP -- address if this can be done unambiguously. local function stripCIDRSuffix(cidr, bitLength) assert(bitLength == 32 or bitLength == 128, 'bitLength was not 32 or 128') local pattern = '/' .. bitLength .. '$' cidr = cidr:gsub(pattern, '') return cidr end -- Takes an array of CIDR ranges and returns a new array with ranges -- appropriate for printing. local function prettifyRanges(ranges, bitLength) local ret = {} for i, cidr in ipairs(ranges) do ret[i] = stripCIDRSuffix(cidr, bitLength) end return ret end -- Turns an array of CIDR ranges into its string representation. local function stringifyRanges(ranges, bitLength, separator) if not ranges then return '' end ranges = prettifyRanges(ranges, bitLength) return table.concat(ranges, separator) end function p._table(options) -- Return a wikitext table summarizing all the sensitive IP ranges -- and the entities they belong to. -- Load dependencies local lang = mw.language.getContentLanguage() -- Set up options options = options or {} local rangeSeparator = options.rangeseparator or ', ' local showNotes = yesno(options.notes) local nColumns = showNotes and 3 or 4 -- Get the entity data local data = mSIPA_API.query{entities={'all'}} if data['error'] then error(string.format('%s: %s', data['error'].code, data['error'].info)) end -- Make the table root local root = mw.html.create('table') if options.class then root:addClass(options.class) end if options.style then root:cssText(options.style) end -- Add main header if options.mainheader then root:tag('tr'):tag('td') :attr('colspan', nColumns) :cssText(options.cellstyle) :wikitext(options.mainheader) end -- Add column headers local headerRow = root:tag('tr') headerRow :tag('th') :cssText(options.cellstyle) :wikitext('[[IPv4]]') :done() :tag('th') :cssText(options.cellstyle) :wikitext('[[IPv6]]') :done() :tag('th') :cssText(options.cellstyle) :wikitext('Description') if showNotes then headerRow:tag('th') :cssText(options.cellstyle) :wikitext('Notes') end -- Add data cells for i, id in ipairs(data.sensitiveips['entity-ids']) do local entityData = data.sensitiveips.entities[id] if not options.reason or options.reason == entityData.reason then local dataRow = root:tag('tr') dataRow :tag('td') :cssText(options.cellstyle) :wikitext(stringifyRanges( entityData.ipv4Ranges, 32, rangeSeparator )) :done() :tag('td') :cssText(options.cellstyle) :wikitext(stringifyRanges( entityData.ipv6Ranges, 128, rangeSeparator )) :done() :tag('td') :cssText(options.cellstyle) :wikitext(lang:ucfirst(entityData.description)) if showNotes then dataRow:tag('td') :cssText(options.cellstyle) :wikitext(entityData.notes) end end end return tostring(root) end function p.table(frame) local args = require('Module:Arguments').getArgs(frame, { frameOnly = true }) return p._table(args) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Sandbox other
(
edit
)
Template:Tag
(
edit
)
Template:Used in system
(
edit
)
Module:Arguments
(
edit
)
Module:Effective protection level
(
edit
)
Module:High-use
(
edit
)
Module:IP
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Sensitive IP addresses/API
(
edit
)
Module:Sensitive IP addresses/list
(
edit
)
Module:Sensitive IP addresses/summary
(
edit
)
Module:Sensitive IP addresses/summary/doc
(
edit
)
Module:String
(
edit
)
Module:Transclusion count
(
edit
)
Module:Transclusion count/data/S
(
edit
)
Module:Yesno
(
edit
)