Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. === modified file 'plugins/Script/examples/access.lua'
  2. --- plugins/Script/examples/access.lua 2010-11-10 22:48:35 +0000
  3. +++ plugins/Script/examples/access.lua 2010-11-12 19:02:14 +0000
  4. @@ -168,6 +168,19 @@
  5. end
  6. end
  7.  
  8. +local function recheck_info()
  9. + local entities = cm:getEntities()
  10. + local size = entities:size()
  11. + if size > 0 then
  12. + for i = 0, size - 1 do
  13. + local c = entities[i]:asClient()
  14. + if c then
  15. + verify_info(c)
  16. + end
  17. + end
  18. + end
  19. +end
  20. +
  21. settings.address = {
  22. alias = { host = true, dns = true },
  23.  
  24. @@ -274,18 +287,7 @@
  25. }
  26.  
  27. settings.maxnicklength = {
  28. - change = function()
  29. - local entities = cm:getEntities()
  30. - local size = entities:size()
  31. - if size > 0 then
  32. - for i = 0, size - 1 do
  33. - local c = entities[i]:asClient()
  34. - if c then
  35. - verify_info(c)
  36. - end
  37. - end
  38. - end
  39. - end,
  40. + change = recheck_info,
  41.  
  42. help = "maximum number of characters allowed per nick, 0 = no limit",
  43.  
  44. @@ -375,6 +377,76 @@
  45. value = 1
  46. }
  47.  
  48. +settings.minsharesize = {
  49. + alias = { minss = true },
  50. +
  51. + change = recheck_info,
  52. +
  53. + help = "minimum share size allowed in bytes, 0 = disabled",
  54. +
  55. + value = 0
  56. +}
  57. +
  58. +settings.minslotsize = {
  59. + alias = { minsl = true },
  60. +
  61. + change = recheck_info,
  62. +
  63. + help = "minimum number of opened upload slots required, 0 = disabled",
  64. +
  65. + value = 0
  66. +}
  67. +
  68. +settings.minhubslotratio = {
  69. + alias = { minhsr = true },
  70. +
  71. + change = recheck_info,
  72. +
  73. + help = "minimum hub/slot ratio required, 0 = disabled",
  74. +
  75. + value = 0
  76. +}
  77. +
  78. +settings.maxsharesize = {
  79. + alias = { maxss = true },
  80. +
  81. + change = recheck_info,
  82. +
  83. + help = "maximum share size allowed in bytes, 0 = disabled",
  84. +
  85. + value = 0
  86. +}
  87. +
  88. +settings.maxslotsize = {
  89. + alias = { maxsl = true },
  90. +
  91. + change = recheck_info,
  92. +
  93. + help = "maximum number of opened upload slots allowed, 0 = disabled",
  94. +
  95. + value = 0
  96. +}
  97. +
  98. +settings.maxhubslotratio = {
  99. + alias = { maxhsr = true },
  100. +
  101. + change = recheck_info,
  102. +
  103. + help = "maximum hub/slot ratio allowed, 0 = disabled",
  104. +
  105. + value = 0
  106. +}
  107. +
  108. +settings.maxhubscount = {
  109. + alias = { maxhubs = true },
  110. +
  111. + change = recheck_info,
  112. +
  113. + help = "maximum number of connected hubs allowed, 0 = disabled",
  114. +
  115. + value = 0
  116. +}
  117. +
  118. settings.sendversion = {
  119. alias = { displayversion = true },
  120.  
  121. @@ -906,6 +978,57 @@
  122. return false
  123. end
  124.  
  125. + local ss = base.tonumber(c:getField("SS"))
  126. + if ss then
  127. + if settings.minsharesize.value > 0 and ss < settings.minsharesize.value then
  128. + 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")
  129. + return false
  130. + end
  131. +
  132. + if settings.maxsharesize.value > 0 and ss > settings.minsharesize.value then
  133. + 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")
  134. + return false
  135. + end
  136. + end
  137. +
  138. + local sl = base.tonumber(c:getField("SL"))
  139. + if sl then
  140. + if settings.minslotsize.value > 0 and sl < settings.minslotsize.value then
  141. + 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))
  142. + return false
  143. + end
  144. +
  145. + if settings.maxslotsize.value > 0 and sl > settings.maxslotsize.value then
  146. + 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))
  147. + return false
  148. + end
  149. + end
  150. +
  151. + local h1 = base.tonumber(c:getField("HN"))
  152. + local h2 = base.tonumber(c:getField("HR"))
  153. + local h3 = base.tonumber(c:getField("HO"))
  154. + local h
  155. + if (h1 and h2 and h3) then
  156. + h = base.tonumber(h1) + base.tonumber(h2) + base.tonumber(h3)
  157. + if settings.maxhubscount.value > 0 and h > settings.maxhubscount.value then
  158. + 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))
  159. + return false
  160. + end
  161. + end
  162. +
  163. + if sl and h and sl > 0 and h > 0 then -- Correct hubcount may not arrive with the first info
  164. + local r = h / sl
  165. + if settings.minhubslotratio.value > 0 and r < settings.minhubslotratio.value then
  166. + 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))
  167. + return false
  168. + end
  169. +
  170. + if settings.maxhubslotratio.value > 0 and r > settings.minhubslotratio.value then
  171. + 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))
  172. + return false
  173. + end
  174. + end
  175. +
  176. return true
  177. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement