Up to Main Index Up to Journal for January, 2022 JOURNAL FOR SUNDAY 9TH JANUARY, 2022 ______________________________________________________________________________ SUBJECT: Reworked quota (rate limiting per IP address connections) DATE: Sun 9 Jan 19:44:29 GMT 2022 In my haste to get per IP address quota out I bungled the effort somewhat… The code was hacked into the server source. Quota could expiring too soon due to cache slots being of a fixed period and fractional slot times not being taken into account — they are now. So, a brilliant start to 2022 :( I’ve since put quota into their own quota package and cleaned up the server code. I’ve also reworked the quota code to iron out the initial bugs. Based on feedback I have also added a Debug.Quota configuration option. If Debug.Quota is set to true lines like the following will be written to the server log: QC[1 ] M[0000000000000000...0000000000000101 ] X[19:01:46] A[127.0.0.1] QC[2 ] M[0000000000000000...0000000000000111*] X[19:01:49] A[127.0.0.2] The QC indicates a quota cache line and has a sequence number, starting at 1 for each report. The M value shows the 64bit slot mask, 0 is an unused slot and 1 is a used slot. If the bits are followed by an asterisk ‘*’ the client IP address shown in the A value is over quota and cannot connect. The X value is the expiry time of the cache line. It should be noted that the IP address in the A value is always reported, even if Server.LogClient is set to false. The quota implementation does not use timers or Go routines to watch for expired quota. All house-keeping is performed automatically when a client connects. Up to 1,000 expired quota can be purged from the cache at a time, unless quota debugging is turned on — then the whole cache is checked. This keeps the CPU overhead for enabling quota low. Purging expired quota keeps the memory overhead of using quota low. The new quota implementation is now out on the public dev branch. Next I’m adding the #DEBUG command. Then I’ll be starting the groundwork for combat by adding health and the HIT command I used for testing. I think that will bring the new code up to par with the previous v0.0.18 release? -- Diddymus Up to Main Index Up to Journal for January, 2022