Commit graph

63 commits

Author SHA1 Message Date
Hans5958
d1d63d9c18
docs: fix broken link to default policy file (#137) 2025-03-27 08:43:37 -04:00
Xe Iaso
ecc6b47f90
Revert "lib/anubis: support setting extended cookie flags (#120)" (#134)
This reverts commit e7cbd349f3.
2025-03-26 20:50:54 -04:00
Xe Iaso
e7cbd349f3
lib/anubis: support setting extended cookie flags (#120)
* lib/anubis: support setting extended cookie flags

Signed-off-by: Xe Iaso <me@xeiaso.net>

* lib: use cookie name consistently

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-26 19:04:18 -04:00
Henri Vasserman
07bb5f63f9
fix(docs): Make dark mode diff lines readable (#130)
* fix(docs): Make dark mode diff lines readable

If using dark mode, these lines are not legible at all. I separated the colors into variables and added
more contrasting colors for the dark mode.

* chore: add to changelog
2025-03-26 15:44:20 -04:00
Xe Iaso
4155719422
cmd/anubis: allow setting key bytes in flag/envvar (#97)
* cmd/anubis: allow setting key bytes in flag/envvar

Docs are updated to generate a random key on load and when people press
the recycle button.

Signed-off-by: Xe Iaso <me@xeiaso.net>

* review feedback fixups

Signed-off-by: Xe Iaso <me@xeiaso.net>

* Update cmd/anubis/main.go

Signed-off-by: Xe Iaso <me@xeiaso.net>

* Apply suggestions from code review

Co-authored-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
2025-03-25 17:02:48 -04:00
Yulian Kuncheff
f29a200f09
Linting and staticcheck fixes. (#101)
* Fix linting and staticcheck issues

* Add changelog update

* Remove SetNext
2025-03-25 10:02:05 -04:00
soopyc
18cd8a66a2
docs: minor updates (#98)
* use _ instead of * for italicized text by convention

* remove mention of the `anubis` tag from /x/
2025-03-23 23:49:12 -04:00
Xe Iaso
725e11d3a6
lib: fix default difficulty (#96)
Before this did not respect the difficulty flag and instead used
difficulty 4. This has been fixed.

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-23 18:46:01 -04:00
Jared Allard
f462209b02
chore: remove built binary and prevent accidental addition again (#91)
Removes `main` from the repo and updates `.gitignore` to help prevent
accidents like this again. `.test` comes from go test binaries, which I
feel is also worth excluding

Signed-off-by: Jared Allard <jaredallard@users.noreply.github.com>
2025-03-22 22:44:11 -04:00
Jared Allard
acf5586e83
docs(README): fix mascot link (#88)
Title says it does, noticed it broke 😢

Signed-off-by: Jared Allard <jaredallard@users.noreply.github.com>
2025-03-22 22:37:16 -04:00
dependabot[bot]
9d68e73d03
build(deps): bump github.com/go-jose/go-jose/v3 from 3.0.3 to 3.0.4 (#89)
Bumps [github.com/go-jose/go-jose/v3](https://github.com/go-jose/go-jose) from 3.0.3 to 3.0.4.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Changelog](https://github.com/go-jose/go-jose/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-jose/go-jose/compare/v3.0.3...v3.0.4)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-22 21:18:02 -04:00
Yulian Kuncheff
6156d3d729
Refactor and split out things into cmd and lib (#77)
* Refactor anubis to split business logic into a lib, and cmd to just be direct usage.

* Post-rebase fixes.

* Update changelog, remove unnecessary one.

* lib: refactor this

This is mostly based on my personal preferences for how Go code should
be laid out. I'm not sold on the package name "lib" (I'd call it anubis
but that would stutter), but people are probably gonna import it as
libanubis so it's likely fine.

Packages have been "flattened" to centralize implementation with area of
concern. This goes against the Java-esque style that many people like,
but I think this helps make things simple.

Most notably: the dnsbl client (which is a hack) is an internal package
until it's made more generic. Then it can be made external.

I also fixed the logic such that `go generate` works and rebased on
main.

* internal/test: run tests iff npx exists and DONT_USE_NETWORK is not set

Signed-off-by: Xe Iaso <me@xeiaso.net>

* internal/test: install deps

Signed-off-by: Xe Iaso <me@xeiaso.net>

* .github/workflows: verbose go tests?

Signed-off-by: Xe Iaso <me@xeiaso.net>

* internal/test: sleep 2

Signed-off-by: Xe Iaso <me@xeiaso.net>

* internal/test: nix this test so CI works

Signed-off-by: Xe Iaso <me@xeiaso.net>

* internal/test: warmup per browser?

Signed-off-by: Xe Iaso <me@xeiaso.net>

* internal/test: disable for now :(

Signed-off-by: Xe Iaso <me@xeiaso.net>

* lib/anubis: do not apply bot rules if address check fails

Closes #83

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-22 18:44:49 -04:00
Valentin Anger
af6f05554f
internal/test: introduce integration tests using Playwright (#81) 2025-03-22 16:36:27 -04:00
Dennis ten Hoove
1509b06cb9
Cleanup regex (#66)
* Cleanup regex

Were were going overkill on the escape characters

* Update docs/docs/CHANGELOG.md

Co-authored-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Dennis ten Hoove <36002865+dennis1248@users.noreply.github.com>

---------

Signed-off-by: Dennis ten Hoove <36002865+dennis1248@users.noreply.github.com>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-22 13:52:14 -04:00
Xe Iaso
56cdb2e51b
Fix docker image CI for pull requests (#84)
Closes #65

Pull request images will now be `ttl.sh/techaro/pr-{number}/anubis:24h`.
2025-03-22 11:26:49 -04:00
Christian F. Coors
15d801be7d
fix: installation instructions and example (#75) 2025-03-22 07:45:32 -04:00
dependabot[bot]
c66305904b
build(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.1 to 5.2.2 (#74)
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.1 to 5.2.2.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.1...v5.2.2)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v5
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-21 20:41:19 -04:00
Xe Iaso
5f7942faca
cmd/anubis: delete example RSS reader rule (#67)
The example/default bot policy document had a rule to allow RSS readers
through based on paths that end with ".rss", ".xml", ".atom", or
".json". Frameworks like Rails will treat these specially, meaning that
going to /things/12345-whateverhaha.json could bypass Anubis.

I checked the history of this rule and it was present in the original
example policy file in Xe/x. This rule is likely a mistake and it has
been removed. I think it was for making my blog still work with RSS
readers.

Thanks to Graham Sutherland for reporting this over email.

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 17:20:17 -04:00
Dennis ten Hoove
869e46a4cc
Add MojeekBot (#64)
* Add MojeekBot

* Update docs/docs/CHANGELOG.md

Co-authored-by: Xe Iaso <me@xeiaso.net>
Signed-off-by: Dennis ten Hoove <36002865+dennis1248@users.noreply.github.com>

---------

Signed-off-by: Dennis ten Hoove <36002865+dennis1248@users.noreply.github.com>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-21 16:59:42 -04:00
Xe Iaso
07e6695430
cmd/anubis: set X-Real-Ip based on X-Forwarded-For (#63)
This triggers a SHAME release[0].

[0]: https://pridever.org/
2025-03-21 16:45:33 -04:00
Xe Iaso
a9777a3126
cmd/anubis: made with love in Canada
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 16:03:33 -04:00
Xe Iaso
5ad44d77d0
stage v1.14.0 (#59)
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 15:55:48 -04:00
Alexander Yastrebov
ad432897ca
cmd/anubis: use golang-jwt to check expiry date (#56)
* cmd/anubis: use golang-jwt to check expiry date

Also:
* check parse error
* require strict base64 decoding
* ignore always nil sha256sum error to simplify codeflow

Signed-off-by: Alexander Yastrebov <yastrebov.alex@gmail.com>

* cmd/anubis: handle unlikely case when token claims aren't the right go type

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Alexander Yastrebov <yastrebov.alex@gmail.com>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-03-21 15:47:22 -04:00
Alexander Yastrebov
194e55088b
cmd/anubis: do not return error from sha256 (#57)
hash.Write never returns error so removing it from
the results simplifies usage and eliminates dead error handling.

Signed-off-by: Alexander Yastrebov <yastrebov.alex@gmail.com>
2025-03-21 15:46:43 -04:00
Xe Iaso
4ec4dc3624
.github/workflows: don't publish provenance data for PRs
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 15:42:51 -04:00
Remilia Da Costa Faro
d6d879133e
Allow filtering by remote addresses (#52)
* Added the possibility to define rules for remote addresses

* Added change in changelog

* Added check for X-Real-Ip and X-Forwarded-For when checking for remote address filtering

* cmd/anubis: refine IP filtering logic

* Optimize the configuration so that the IP trie is created once at
  application start instead of dynamically being created every request.
* Document the changes in the changelog and docs site.
* Allow pure IP range filtering.
* Allow user agent based IP range filtering.
* Allow path based IP range filtering.
* Create --debug-x-real-ip-default flag for testing Anubis locally
  without a HTTP load balancer.

---------

Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-21 15:39:34 -04:00
Xe Iaso
e7b9b17b92
cmd/anubis: explain why users are seeing Anubis (#55)
* cmd/anubis: explain why users are seeing Anubis

Closes #25
Closes #38

Also includes the beginnings of a "user guides" section in the docs for
user-facing documentation.

* Update docs/docs/user/known-broken-extensions.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xe Iaso <me@xeiaso.net>

* cmd/anubis: fix indentation in index.templ

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-03-21 14:21:59 -04:00
Xe Iaso
d3e509517c
cmd/anubis: configurable difficulty per-bot rule (#53)
Closes #30

Introduces the "challenge" field in bot rule definitions:

```json
{
  "name": "generic-bot-catchall",
  "user_agent_regex": "(?i:bot|crawler)",
  "action": "CHALLENGE",
  "challenge": {
    "difficulty": 16,
    "report_as": 4,
    "algorithm": "slow"
  }
}
```

This makes Anubis return a challenge page for every user agent with
"bot" or "crawler" in it (case-insensitively) with difficulty 16 using
the old "slow" algorithm but reporting in the client as difficulty 4.

This is useful when you want to make certain clients in particular
suffer.

Additional validation and testing logic has been added to make sure
that users do not define "impossible" challenge settings.

If no algorithm is specified, Anubis defaults to the "fast" algorithm.

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 13:48:00 -04:00
makeworld
90049001e9
Add kagibot (#44)
* Add kagibot

Signed-off-by: makeworld <25111343+makew0rld@users.noreply.github.com>

* Update CHANGELOG.md

Signed-off-by: makeworld <25111343+makew0rld@users.noreply.github.com>

---------

Signed-off-by: makeworld <25111343+makew0rld@users.noreply.github.com>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-21 11:16:19 -04:00
Xe Iaso
38e1e8cb5e
comment out the comment PR experiment for now, ugh, I hate GitHub ACLs
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 11:06:31 -04:00
soopyc
1c00431098
general unix domain sockets support (#45)
* feat: allow binding to unix domain sockets

this is useful when the user does not want to expose more tcp ports than
needed. also simplifes configuration in some situation, like with nixos
modules as the socket paths can be automatically configured.

docs updated with additional configuration flags.

Signed-off-by: Cassie Cheung <me@soopy.moe>

* feat: graceful shutdown and cleanup on signal

this is needed to clean up left-over unix sockets, else on the next boot
listener panics with `address already in use`.

Co-authored-by: cat <cat@gensokyo.uk>
Signed-off-by: Cassie Cheung <me@soopy.moe>

* feat: support unix socket upstream targets

adds support for proxying unix socket upstreams, essentially allowing
anubis to run without listening on tcp sockets at all*.

*for metrics, neither prometheus and victoriametrics supports scraping
from unix sockets. if metrics are desired, tcp sockets are still needed.

Co-authored-by: cat <cat@gensokyo.uk>
Signed-off-by: Cassie Cheung <me@soopy.moe>

* docs: add changelog entry

---------

Signed-off-by: Cassie Cheung <me@soopy.moe>
Co-authored-by: cat <cat@gensokyo.uk>
2025-03-21 10:58:05 -04:00
Charlotte
d93adbc111
Skip TestLookup test when networking is disabled (#49) 2025-03-21 10:43:10 -04:00
Xe Iaso
f730326814
off by one
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 10:40:30 -04:00
Xe Iaso
db6d424aaa
.github/workflows/docker: only do comments if we're in a PR
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 10:36:24 -04:00
Xe Iaso
95dddb5549
cmd/containerbuild: default to ttl.sh for third party contributions (#51)
* cmd/containerbuild: default to ttl.sh for third party contributions

Closes #48

Signed-off-by: Xe Iaso <me@xeiaso.net>

* track comment tags

Signed-off-by: Xe Iaso <me@xeiaso.net>

* empty commit to make sure double-commenting doesn't work

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 10:34:01 -04:00
Xe Iaso
86b8c6c5f2
add star history chart to README
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-21 08:59:44 -04:00
Callum Thomson
f1220ecc57
Fix when hardwareConcurrency is undefined (#42) 2025-03-21 08:51:19 -04:00
Xe Iaso
94f43c7200
docs/design: add note on why anubis uses proof of work
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 17:53:52 -04:00
Dennis ten Hoove
f41b21b3cf
Explicitely define image sources in Dockerfile (#21)
* Explicitely define image sources

Explicitely refering to docker.io will make the build succeed on software such as podman which does not default to docker.io as the standard image source

* Dockerfiles: use the full legal docker.io/library name just in case

Signed-off-by: Xe Iaso <me@xeiaso.net>

* update CHANGELOG

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-20 17:28:30 -04:00
Dennis ten Hoove
d1512a1f79
Ensure content flows and stays centered on small screens (#27)
* Ensure content flows and stays centered on small screens

Fixes #18

* Do not overflow image, instead resize with page

* update CHANGELOG

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-20 17:19:45 -04:00
Xe Iaso
c88775bb8a
cmd/anubis: lower default difficulty to 4
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 16:58:49 -04:00
Donatas
eeaed6a317
fix: no duplicate work when exceeding hardcoded int (#36)
* fix: no duplicate work when exceeding that 1xxx number

* run go generate and update CHANGELOG

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-03-20 16:20:53 -04:00
Federico Gaggero
3e9a93f629
Fix: Removed several visible AI artifacts (e.g., 6 fingers) (#37)
* Fix: Removed several visible AI artifacts (e.g., 6 fingers)

* Add an entry to docs/docs/CHANGELOG.md
2025-03-20 16:09:49 -04:00
Xe Iaso
bf2c83c337
pull request template
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 16:01:44 -04:00
Xe Iaso
d84fd392c7
docs/manifest: always pull
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 15:50:08 -04:00
Xe Iaso
5258492101
oops
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 15:38:41 -04:00
Xe Iaso
d82c12de28
docs: add funding page
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 15:36:34 -04:00
Xe Iaso
c49c039fae
docs: add placeholder warning to landing page
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 15:10:37 -04:00
Xe Iaso
c47347ff76
add docs site based on docusarus (#35)
* add docs site based on docusarus

Closes #2

Signed-off-by: Xe Iaso <me@xeiaso.net>

* docs: deploy to aeacus

Signed-off-by: Xe Iaso <me@xeiaso.net>

* ready for merge

Signed-off-by: Xe Iaso <me@xeiaso.net>

* docs: fix anubis port

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 15:06:58 -04:00
Xe Iaso
240159e921
v1.13.0
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-03-20 09:28:38 -04:00