Rack Off
El cheapo alternative to some of the heavier, or more encumbered, proof-of-work
challenge based bot defense systems. Likely nowhere near as good. Very simple.
Probably works. Maybe.
"Rack Off" is Australian for "Go Away". You say it when you don't want to use
stronger language. Given what abusive scrapers are doing to the open internet,
it's probably time for stronger language.
Quickstart
inner := http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
})
rackOffConfig := rackoff.Config{
SecretKey: "<secret>",
CookieName: "rackoff",
Difficulty: 16,
TokenLifetime: 24 * time.Hour,
ChallengeTimeout: 2 * time.Minute,
}
rackOff, err := rackoff.NewMiddleware(rackOffConfig, inner, nil)
if err != nil {
return err
}
http.ListenAndServe("127.0.0.1:8990", rackOff)
Expectation management
This is a tool I hack on for my own amusement in an ad-hoc fashion. No
stability guarantees are made, the code is not guaranteed to work, and
anything may be changed, renamed or removed at any time as I see fit.
If you wish to use any of this, I strongly recommend you copy-paste pieces
as-needed (including tests and license/attribution) into your own project,
or fork it for your own purposes.
Bug reports are welcome, feature requests discouraged, and code contributions
will not be accepted.
License
rackoff is Copyright Blake Williams code@shabbyrobe.org. It is licensed
under the MIT license.