Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === modified file 'plugins/Script/examples/access.lua'
- --- plugins/Script/examples/access.lua 2010-11-10 22:48:35 +0000
- +++ plugins/Script/examples/access.lua 2010-11-12 19:02:14 +0000
- @@ -168,6 +168,19 @@
- end
- end
- +local function recheck_info()
- + local entities = cm:getEntities()
- + local size = entities:size()
- + if size > 0 then
- + for i = 0, size - 1 do
- + local c = entities[i]:asClient()
- + if c then
- + verify_info(c)
- + end
- + end
- + end
- +end
- +
- settings.address = {
- alias = { host = true, dns = true },
- @@ -274,18 +287,7 @@
- }
- settings.maxnicklength = {
- - change = function()
- - local entities = cm:getEntities()
- - local size = entities:size()
- - if size > 0 then
- - for i = 0, size - 1 do
- - local c = entities[i]:asClient()
- - if c then
- - verify_info(c)
- - end
- - end
- - end
- - end,
- + change = recheck_info,
- help = "maximum number of characters allowed per nick, 0 = no limit",
- @@ -375,6 +377,76 @@
- value = 1
- }
- +settings.minsharesize = {
- + alias = { minss = true },
- +
- + change = recheck_info,
- +
- + help = "minimum share size allowed in bytes, 0 = disabled",
- +
- + value = 0
- +}
- +
- +settings.minslotsize = {
- + alias = { minsl = true },
- +
- + change = recheck_info,
- +
- + help = "minimum number of opened upload slots required, 0 = disabled",
- +
- + value = 0
- +}
- +
- +settings.minhubslotratio = {
- + alias = { minhsr = true },
- +
- + change = recheck_info,
- +
- + help = "minimum hub/slot ratio required, 0 = disabled",
- +
- + value = 0
- +}
- +
- +settings.maxsharesize = {
- + alias = { maxss = true },
- +
- + change = recheck_info,
- +
- + help = "maximum share size allowed in bytes, 0 = disabled",
- +
- + value = 0
- +}
- +
- +settings.maxslotsize = {
- + alias = { maxsl = true },
- +
- + change = recheck_info,
- +
- + help = "maximum number of opened upload slots allowed, 0 = disabled",
- +
- + value = 0
- +}
- +
- +settings.maxhubslotratio = {
- + alias = { maxhsr = true },
- +
- + change = recheck_info,
- +
- + help = "maximum hub/slot ratio allowed, 0 = disabled",
- +
- + value = 0
- +}
- +
- +settings.maxhubscount = {
- + alias = { maxhubs = true },
- +
- + change = recheck_info,
- +
- + help = "maximum number of connected hubs allowed, 0 = disabled",
- +
- + value = 0
- +}
- +
- settings.sendversion = {
- alias = { displayversion = true },
- @@ -906,6 +978,57 @@
- return false
- end
- + local ss = base.tonumber(c:getField("SS"))
- + if ss then
- + if settings.minsharesize.value > 0 and ss < settings.minsharesize.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Your share size (" .. c:getField("SS") .. " B) is too low, the minimum required size is " .. base.tostring(settings.minsharesize.value) .. " bytes")
- + return false
- + end
- +
- + if settings.maxsharesize.value > 0 and ss > settings.minsharesize.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Your share size (" .. c:getField("SS") .. " B) is too high, the maximum allowed size is " .. base.tostring(settings.minsharesize.value) .. " bytes")
- + return false
- + end
- + end
- +
- + local sl = base.tonumber(c:getField("SL"))
- + if sl then
- + if settings.minslotsize.value > 0 and sl < settings.minslotsize.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Your number of opened upload slots (" .. c:getField("SL") .. ") is too few, the minimum required number of slots is " .. base.tostring(settings.minslotsize.value))
- + return false
- + end
- +
- + if settings.maxslotsize.value > 0 and sl > settings.maxslotsize.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Your number of opened upload slots (" .. c:getField("SL") .. ") is too high, the maximum allowed number of slots is " .. base.tostring(settings.maxslotsize.value))
- + return false
- + end
- + end
- +
- + local h1 = base.tonumber(c:getField("HN"))
- + local h2 = base.tonumber(c:getField("HR"))
- + local h3 = base.tonumber(c:getField("HO"))
- + local h
- + if (h1 and h2 and h3) then
- + h = base.tonumber(h1) + base.tonumber(h2) + base.tonumber(h3)
- + if settings.maxhubscount.value > 0 and h > settings.maxhubscount.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "The number of hubs you're connected to (" .. base.tostring(h) .. ") is too high, the maximum allowed hubs count is " .. base.tostring(settings.maxhubscount.value))
- + return false
- + end
- + end
- +
- + if sl and h and sl > 0 and h > 0 then -- Correct hubcount may not arrive with the first info
- + local r = h / sl
- + if settings.minhubslotratio.value > 0 and r < settings.minhubslotratio.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Your hubs/slots ratio (" .. base.tostring(r) .. ") is too low, you must lower your number of opened upload slots to achive ratio " .. base.tostring(settings.minhubslotratio.value))
- + return false
- + end
- +
- + if settings.maxhubslotratio.value > 0 and r > settings.minhubslotratio.value then
- + autil.dump(c, adchpp.AdcCommand_ERROR_PROTOCOL_GENERIC, "Your hubs/slots ratio (" .. base.tostring(r) .. ") is too high, you must open up more upload slots or disconnect from some hubs to achive ratio " .. base.tostring(settings.maxhubslotratio.value))
- + return false
- + end
- + end
- +
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement