🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rocksolid.nodes
Article #379

Re: rate limiting in rslight

#379
From: Retro Guy
Date: Wed, 06 Jan 2021 22:59
31 lines
2004 bytes
On Wed, 06 Jan 2021 04:27:53 -0800
Anonymous <poster@anon.com> wrote:

> >I'm now limiting per session,
> 
> I was not aware that rslight uses sessions. How did you do that,
> cookies ?
> 
> Good that it works against the crawlers, though. I just realized that
> cookies will not work against crawlers that do not take them, so
> probably you have found another way (really curious here).
> 

What I do is connect to the session in specific files, not every file:
session_start();

Then verify a start time or create a start time (of the session), count
hits (views), then I can monitor hit rates:
$rate = ($_SESSION['views'] / (time() - $_SESSION['starttime']));

If there is a big gap since start time, it is reset to avoid spoofing
rate. Then, reading $rate it's decided whether it's too fast or not and
if it is, it sends a 429 "Too Many Requests" and exits the script
(sending no content).

In my logs, all the crawlers are receiving 429, and the non crawlers
(users) are able to load the page with no issues.

Cookies are not involved, just sessions.

Retro Guy
Technical Details
Message-ID: <20210106155913.279b35b5@desktop14.dt>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!i2pn2.org!rocksolid2!.POSTED.localhost!not-for-mail
References: <cca9cd3838da484861b2129d7d32bb89$1@news.novabbs.org> <n.1283.3r3v9b@anon.com>

Show Full Headers
Complete Article Headers
Message-ID: <20210106155913.279b35b5@desktop14.dt>
Subject: Re: rate limiting in rslight
Date: Wed, 6 Jan 2021 15:59:13 -0700
From: Retro Guy <retro_guy@retrobbs.rocksolidbbs.com>
References: <cca9cd3838da484861b2129d7d32bb89$1@news.novabbs.org> <n.1283.3r3v9b@anon.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!i2pn2.org!rocksolid2!.POSTED.localhost!not-for-mail
Newsgroups: rocksolid.nodes
Organization: RetroBBS
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: novabbs.org; posting-account="retrobbs1"; posting-host="localhost:127.0.0.1";
 logging-data="18418"; mail-complaints-to="usenet@novabbs.org"
X-Newsreader: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu)