Add rate limiter and rate limit refreshAll
refreshAll is a very instruction heavy call, it will easily overrun instruction limit on unstrusted clients if not controlled
This commit is contained in:
parent
d006d88009
commit
0f16fc3579
@ -521,7 +521,7 @@ function ping.syncState(tbl)
|
||||
for k, v in pairs(tbl) do
|
||||
local_state[k]=v
|
||||
end
|
||||
PartsManager.refreshAll()
|
||||
rateLimit(1, PartsManager.refreshAll, "refreshAll")
|
||||
end
|
||||
-- }}}
|
||||
|
||||
@ -579,6 +579,12 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function rateLimit(ticks, next, name)
|
||||
if cooldown(ticks+1, name) then
|
||||
namedWait(ticks, next, name)
|
||||
end
|
||||
end
|
||||
|
||||
-- }}}
|
||||
|
||||
|
||||
@ -631,7 +637,6 @@ function tick()
|
||||
ping.oof(player.getHealth())
|
||||
end
|
||||
|
||||
|
||||
if old_state.isUnderwater ~= player.isUnderwater() then syncState() end
|
||||
old_state.isUnderwater=player.isUnderwater()
|
||||
-- End of tick --
|
||||
|
Loading…
x
Reference in New Issue
Block a user