I was wondering why my server was sluggish. Server owners, remove this if you have this addon.

If you have the command “ulx dban” on your server, I’m suspecting that it’s causing some performance issues.
Whenever my server has been up for over a day, I’ve noticed that network usage skyrockets through the channel disconnects_u
I believe I found the culprit:

This script saves every single disconnect, and does not remove old ones. My server is heavily populated and by the end of the day, there has been over a thousand disconnects. This means, 1000s individual disconnects are stored in a table.
This inherently is okay. However, this script literally sends each of the 1000 entries in separate usermessages. Whenever a staff member connects, the discs_request command is ran and hundreds of usermessages are sent.

Can anyone confirm that this is causing any slow-downs?

The last thing you want is for somebody to join your server and begin spamming that command. Yeah it’s probably causing your issues. Here’s an untested modification of that script that stores only up to 20 disconnections.



local allDisconnected = {}
local disconnectionHistory = 20
 
local function plyDiscoBan( ply )
 
        if #allDisconnected == disconnectionHistory then
                table.remove( allDisconnected, 1 )
        end

        table.insert( allDisconnected, { tostring( ply:SteamID() ), tostring( ply:Nick() ), tostring( string.sub( tostring( ply:IPAddress() ), 1, string.len( ply:IPAddress() ) - 6 ) ), tostring( os.date( "%H:%M" ) ) } )
 
end
hook.Add( "PlayerDisconnected", "plyDiscoBan", plyDiscoBan )
 
local function printIDTable()
        PrintTable( allDisconnected )
end
concommand.Add( "print_disc_steamids", printIDTable )
 
 
local function DisconnectsCommand( ply, c, a )
 
        if ply:IsValid() then
                for k,v in ipairs( allDisconnected ) do
                        umsg.Start( "disconnects_u", ply )
                        umsg.String( v[2] )
                        umsg.String( v[1] )
                        umsg.String( v[3] )
                        umsg.String( v[4] )
                        umsg.End()
                end
        end
 
end
 
concommand.Add( "discs_request", DisconnectsCommand )


I commend whoever decided this was clever:


tostring( string.sub( tostring( ply:IPAddress() ), 1, string.len( ply:IPAddress() ) - 6 ) )

jesus fucking christ why would you ever think that doing something like sending 1000s of messages at once (on spawn nonetheless) would be a good idea