Skip to main content

Module traffic

Module traffic 

Source
Expand description

Traffic insights (18.15.0): who visits — people, AI agents, bots — worked out by rws from each request, for the admin UI’s Traffic page.

This first part is the classifier, classify: from the client’s address, User-Agent and path it names what kind of client this is, using

  • the IP ranges Google, Bing, Apple, DuckDuckGo, OpenAI, Perplexity and Common Crawl publish for their crawlers (a match is verified; a User-Agent that claims one of them from elsewhere is spoofed);
  • ai.robots.txt’s AI agents and crawler-user-agents’ bot patterns (both MIT, bundled, regenerated by ci/gen_bot_lists.py);
  • requests only scanners make (/.env, /.git/config, /wp-login.php…).

A browser User-Agent that matches none of them is a Kind::Browser: whether it’s a person is decided later, by whether that client loads the page’s assets as a browser does.

Re-exports§

pub use record::enable;
pub use record::enabled;

Modules§

config
[traffic] settings (RWS_CONFIG_TRAFFIC_*).
record
Counting traffic: every request (fed from the access-log path, so all protocols and whether or not lines are written) lands in hourly counts per host and group, daily unique visitors, and daily top lists.
summary
The Traffic page’s data: totals for a period and the one before it, a series (hourly up to 48 hours, daily beyond), and the top lists.

Structs§

Class
A classified client.

Enums§

Group
The three groups the Traffic page shows (and this server’s own calls).
Kind
What a client is, more precisely.

Functions§

classify
What the client at ip, sending user_agent, asking for path, is.
save
Save the counts now (at shutdown).
start
Start counting, with the saved counts loaded and saved again every five minutes (when persist gives a file). The rws binary calls this when the admin API is on and [traffic] enabled isn’t false.