Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Modül:IPblok

bullvar_katip

Administrator
Katılım
21 Mayıs 2024
Mesajlar
532,105
-- Her birini kapsayan minimum boyutlu IP adresi bloklarını hesaplayın -- Değişken olarak IPv4 veya IPv6 adresleri girilir. local bit32 = require('bit32') local Collection -- a table to hold items Collection = { add = function (self, item) if item ~= nil then self.n = self.n + 1 self[self.n] = item end end, join = function (self, sep) return table.concat(self, sep) end, remove = function (self, pos) if self.n > 0 and (pos nil or (0 ' or ':' lines:add(markup .. text) end end local function show_ip(ip) -- Show IP or record it to be included in a "from to" sequence of IPs. if is_next_ip(seq2, ip) then seq2 ip seqmany true else show_sequence seq1 ip seq2 ip seqmany false end end if iplist.n < 1 then return end if lines.n > 0 then lines:add end if omitted.n > 0 then lines:add('Warning, omitted as invalid: ' .. omitted:join(' ')) lines:add end local heading_line if not iplist.nolist then lines:add -- this blank line is replaced with a heading heading_line lines.n end local duplicates Collection.new local previous iplist:sort -- Check for duplicates which can interfere with method to get ranges. for i, ip in ipairs(iplist) do if previous ip then duplicates:add(i) -- index to omit duplicate later elseif not iplist.nolist then show_ip(ip) end previous = ip end show_sequence local duplicate_text = if duplicates.n > 0 then duplicate_text = ' (after omitting some duplicates)' for i = duplicates.n, 1, -1 do iplist:remove(duplicates) end end local heading_text = string.format('Sorted %d %s address%s', iplist.n, iplist.ipname, iplist.n 1 and or 'es' ) if heading_line then lines[heading_line] heading_text .. duplicate_text .. ':' end local strings iplist.want_plain and plaintext or wikitable strings.notes nil -- needed when module is kept loaded for multiple tests strings.want_old iplist.want_old strings.nonote iplist.nonote strings.months iplist.months lines:add(strings.header) local upto lines.n for _, summary in ipairs(make_summaries(iplist)) do show_summary(lines, strings, iplist, summary) end lines:add(strings.footer) if upto + 1 lines.n then -- Show message in the very unlikely event that no results are found. lines:add('----') lines:add('No suitable ranges found; use to see all ranges.') end if strings.notes then lines:add lines:add("Notes") for _, key in ipairs({'range', 'gadget'}) do if strings.notes[key] then lines:add(strings.notes[key]) end end end end local function make_options(args) -- Return table of options from validated args or throw error. local options = {} if not empty(args.comment) then options.comment = args.comment end -- Parameter 'months' is only used if 'old' is also used. local months = math.floor(tonumber(args.months) or tonumber(args.month) or 1) if months < 1 then months = 1 elseif months > 12 then months = 12 end options.months = months -- silently ignore invalid input local allocation if not empty(args.allocation) then allocation = tonumber(args.allocation) if not (allocation and 48 <= allocation and allocation <= 128) then error('Invalid allocation "' .. args.allocation .. '" (should be 48 to 128; default is 64)', 0) end end local maxresults if not empty(args.results) then if args.results 'all' then options.all true allocation allocation or 128 maxresults 1000 else maxresults tonumber(args.results) if not (maxresults and 1 < maxresults and maxresults < 100) then error('Invalid results "' .. args.results .. '" (should be 1 to 100)', 0) end end end options.allocation allocation or 64 options.maxresults maxresults or 10 local keywords { -- Table of k, v strings. -- If an argument matches k, an option named v is set to true. ok 'noannounce', old 'want_old', nolist 'nolist', nonote 'nonote', text 'text', } local want_old for i, arg in ipairs(args) do local flag keywords[arg:match('^%s*(%w+)%s*$')] if flag then options 'skip' options[flag] true if flag 'want_old' then want_old = true end end end if not want_old then options.nonote = true end return options end local function _IPblock(args) -- Process given args; can be called from another module. -- Throw an error if need to report a problem. local options = make_options(args) local v4list, v4omitted = Collection.new, Collection.new local v6list, v6omitted = Collection.new, Collection.new v4list.ipsize = 32 v4list.ipname = 'IPv4' v6list.ipsize = 128 v6list.ipname = 'IPv6' v4list.allocation = 32 v6list.allocation = options.allocation if options.all then v4list.minsize = 0 v6list.minsize = 0 else v4list.minsize = 16 -- cannot block more IPs than /16 for IPv4 v6list.minsize = 19 -- or /19 for IPv6 ($wgBlockCIDRLimit) end for _, k in ipairs({'maxresults', 'months', 'want_old', 'nolist', 'nonote'}) do v4list[k] = options[k] v6list[k] = options[k] end if options.text then v4list.want_plain = true v6list.want_plain = true end for i, arg in ipairs(args) do if options ~= 'skip' then for line in string.gmatch(arg .. '\n', '[\t ]*(.-)[\t\r ]*\n') do -- Skip line if is empty or a comment. if line ~= then local comment = options.comment if not (comment and line:sub(1, #comment) == comment) then line = line :gsub('Special:Contributions/', ' ') -- so input "Special:Contributions/1.2.3.4" works :gsub('Special:Contribs/', ' ') :gsub('[!"#&\'+,%-;<=>?[%]_{|}]', ' ') -- replace accepted delimiters with a space :gsub('\226\128\142', ' ') -- replace LTR marks (U+200E) extract_ipv4(v4list, v4omitted, line) extract_ipv6(v6list, v6omitted, line) end end end end end if v4list.n < 1 and v6list.n < 1 then error('No valid IPv4 or IPv6 address in arguments', 0) end local lines = Collection.new if not options.noannounce then -- 1: Commented out April 2016 as expired. -- 1: lines:add("Please see this announcement.") -- 2: Commented out December 2017 as expired. -- 2: lines:add("By default, links now use Special:Contributions per this announcement.") end process_ips(lines, v4list, v4omitted) process_ips(lines, v6list, v6omitted) return lines:join('\n') end local function IPblock(frame) -- Return wikitext to display the smallest IPv4 or IPv6 CIDR range that -- covers each address given in the arguments, or return error text. -- Input can have any mixture of IPs; IPv4 and IPv6 are processed separately. local ok, msg = pcall(_IPblock, frame:getParent.args) if ok then return msg end return end local function sha1(frame) -- Return SHA-1 hash of first parameter. -- This is for use at User:Johnuniq/Security to generate hash of a password. local text = (frame.args[1] or ):match("^%s*(.-)%s*$") if text ~= then return 'SHA-1 hash after removing any leading or trailing whitespace is ' end return 'Usage: to display the SHA-1 hash of .' end return { IPblock = IPblock, _IPblock = _IPblock, sha1 = sha1, }
 

Tema özelleştirme sistemi

Bu menüden forum temasının bazı alanlarını kendinize özel olarak düzenleye bilirsiniz.

Zevkine göre renk kombinasyonunu belirle

Tam ekran yada dar ekran

Temanızın gövde büyüklüğünü sevkiniz, ihtiyacınıza göre dar yada geniş olarak kulana bilirsiniz.

Izgara yada normal mod

Temanızda forum listeleme yapısını ızgara yapısında yada normal yapıda listemek için kullanabilirsiniz.

Forum arkaplan resimleri

Forum arkaplanlarına eklenmiş olan resimlerinin kontrolü senin elinde, resimleri aç/kapat

Sidebar blogunu kapat/aç

Forumun kalabalığında kurtulmak için sidebar (kenar çubuğunu) açıp/kapatarak gereksiz kalabalıklardan kurtula bilirsiniz.

Yapışkan sidebar kapat/aç

Yapışkan sidebar ile sidebar alanını daha hızlı ve verimli kullanabilirsiniz.

Radius aç/kapat

Blok köşelerinde bulunan kıvrımları kapat/aç bu şekilde tarzını yansıt.

Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Geri