Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plys = {}
- local string_lower = string.lower
- local net_ReadHeader = net.ReadHeader
- local util_NetworkIDToString = util.NetworkIDToString
- local LIMIT = 500
- local function drop(client)
- local i = net_ReadHeader()
- local strName = util_NetworkIDToString(i)
- local log = string.format('%s FLOOD: %s <%s> %s', os.date('[%d.%m.%y - %H:%M]'), client:GetName(), client:SteamID(), strName and ('"' .. strName .. '"') or '')
- file.Append('net_logs.txt', log .. '\n')
- print(log)
- client:Kick('buffer overflow in net message')
- end
- function net.Incoming(len, client)
- local id = client:UserID()
- plys[id] = plys[id] or {}
- if plys[id][1] then
- if SysTime() - plys[id][1] >= 1 then
- plys[id] = {}
- else
- plys[id][2] = plys[id][2] + 1
- if plys[id][2] >= LIMIT then
- drop(client)
- plys[id] = {}
- return
- end
- end
- else
- plys[id] = {SysTime(), 1}
- end
- local i = net_ReadHeader()
- local strName = util_NetworkIDToString(i)
- if not strName then
- return
- end
- local func = net.Receivers[string_lower(strName)]
- if not func then
- return
- end
- len = len - 16
- func(len, client)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement