├── .gitignore
├── premake5.lua
├── README.md
└── src
└── main.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/
2 | projects/
3 | garrysmod_common/
--------------------------------------------------------------------------------
/premake5.lua:
--------------------------------------------------------------------------------
1 | PROJECT_GENERATOR_VERSION = 3
2 |
3 | newoption({
4 | trigger = "gmcommon",
5 | description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
6 | value = "path to garrysmod_common directory"
7 | })
8 |
9 | local gmcommon = assert(_OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON"),
10 | "you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
11 | include(gmcommon)
12 |
13 | CreateWorkspace({name = "netlimiter", abi_compatible = true})
14 | CreateProject({serverside = true})
15 | IncludeLuaShared()
16 | IncludeHelpersExtended()
17 | IncludeSDKCommon()
18 | IncludeSDKTier0()
19 | IncludeSDKTier1()
20 | IncludeSDKLZMA()
21 | IncludeScanning()
22 | IncludeDetouring()
23 | files({"src/*.cpp", "src/*.hpp"})
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## NetLimiter for Garry's Mod servers
2 |
3 | This module is an implementation of the net_chan_limit_msec convar that is available on CSGO and TF2 servers.
4 | This module allows you to limit the amount of processing time a player can use for networking effectively killing all flooding exploits. It works by detouring the ProcessMessages function that handles all networking.
5 | This module is also designed to be as simplified as possible to insure that it is optimized.
6 |
7 | ## Usage.
8 |
9 | Place the DLL in lua/bin.
10 | Create an file in lua/autorun/server that runs ``require("netlimiter")`` and define ``net_chan_limit_msec 100`` in your server.cfg. You can change the limit to what suites your server best.
11 |
12 | ## Compilation
13 | To compile this project you will need [garrysmod_common][1].
14 |
15 |
16 | ## Credits other than myself
17 | [Asriel][2]: Helped me get the detour working and with implementing the ratelimiting itself. Was good fun creating this module.
18 | [Daniel][3]: He is the creator of garrysmod_common which makes it easier for developers to create modules for Garry's Mod and also created a module called sourcenet(My favourite module) that gave a good insight into source engine networking.
19 |
20 | [1]: https://github.com/danielga/garrysmod_common
21 | [2]: https://github.com/A5R13L
22 | [3]: https://github.com/danielga
23 |
24 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include