I had some referrers show up to my blog in the past few days that I consider quite gross. Most fedi instances agree and defederate with them. You probably know the ones.
Anyway, I wanted to add a polite "you are not welcome here" in the client-side JS, but I didn't want to drop a list of domain names in case they think it's "advertising" for their gross content.
So I decided to write a script that:
- Generate a random key.
- Shuffle the list of domain names, using a CSPRNG.
- Store a truncated HMAC-SHA256 of the domain name with the ephemeral key.
- Generate a JSON containing the random key and truncated HMAC tags.
Then I dump this JSON into my WordPress site. If the domain hashes to the same truncated tag, it overwrites the body tag.
https://gist.github.com/soatok/2929e319fa65752c67dbf18d5d38b657