Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. local plys = {}
  2.  
  3. local string_lower = string.lower
  4. local net_ReadHeader = net.ReadHeader
  5. local util_NetworkIDToString = util.NetworkIDToString
  6.  
  7. local LIMIT = 500
  8.  
  9. local function drop(client)
  10. local i = net_ReadHeader()
  11. local strName = util_NetworkIDToString(i)
  12.  
  13. local log = string.format('%s FLOOD: %s <%s> %s', os.date('[%d.%m.%y - %H:%M]'), client:GetName(), client:SteamID(), strName and ('"' .. strName .. '"') or '')
  14. file.Append('net_logs.txt', log .. '\n')
  15. print(log)
  16. client:Kick('buffer overflow in net message')
  17. end
  18.  
  19. function net.Incoming(len, client)
  20. local id = client:UserID()
  21. plys[id] = plys[id] or {}
  22.  
  23. if plys[id][1] then
  24. if SysTime() - plys[id][1] >= 1 then
  25. plys[id] = {}
  26. else
  27. plys[id][2] = plys[id][2] + 1
  28.  
  29. if plys[id][2] >= LIMIT then
  30. drop(client)
  31. plys[id] = {}
  32. return
  33. end
  34. end
  35. else
  36. plys[id] = {SysTime(), 1}
  37. end
  38.  
  39. local i = net_ReadHeader()
  40. local strName = util_NetworkIDToString(i)
  41.  
  42. if not strName then
  43. return
  44. end
  45.  
  46. local func = net.Receivers[string_lower(strName)]
  47.  
  48. if not func then
  49. return
  50. end
  51.  
  52. len = len - 16
  53.  
  54. func(len, client)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement