aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-03-31 18:27:01 -0400
committerGitHub <noreply@github.com>2025-03-31 18:27:01 -0400
commitf844fffd1ebd4178292df09ce181ad0d6db4038f (patch)
tree3e6c8beed46530575703aa523b95eec7a0862587 /lib
parent4b8efcba9bec96f03e55ce3151cf02c0f269ca02 (diff)
downloadanubis-f844fffd1ebd4178292df09ce181ad0d6db4038f.tar.xz
anubis-f844fffd1ebd4178292df09ce181ad0d6db4038f.zip
v1.15.1: Zenos yae Galvus: Echo 1 (#181)v1.15.1
* version 1.15.0 (#144) Signed-off-by: Xe Iaso <me@xeiaso.net> * cmd/anubis actually check the result with the correct difficulty Signed-off-by: Xe Iaso <me@xeiaso.net> * v1.15.1: Zenos yae Galvus: Echo 1 Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net> Co-authored-by: Henri Vasserman <henv@hot.ee>
Diffstat (limited to 'lib')
-rw-r--r--lib/anubis.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/anubis.go b/lib/anubis.go
index 83e04dd..026f912 100644
--- a/lib/anubis.go
+++ b/lib/anubis.go
@@ -145,14 +145,13 @@ func New(opts Options) (*Server, error) {
}
type Server struct {
- mux *http.ServeMux
- next http.Handler
- priv ed25519.PrivateKey
- pub ed25519.PublicKey
- policy *policy.ParsedConfig
- opts Options
- DNSBLCache *decaymap.Impl[string, dnsbl.DroneBLResponse]
- ChallengeDifficulty int
+ mux *http.ServeMux
+ next http.Handler
+ priv ed25519.PrivateKey
+ pub ed25519.PublicKey
+ policy *policy.ParsedConfig
+ opts Options
+ DNSBLCache *decaymap.Impl[string, dnsbl.DroneBLResponse]
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -428,9 +427,9 @@ func (s *Server) PassChallenge(w http.ResponseWriter, r *http.Request) {
}
// compare the leading zeroes
- if !strings.HasPrefix(response, strings.Repeat("0", s.ChallengeDifficulty)) {
+ if !strings.HasPrefix(response, strings.Repeat("0", rule.Challenge.Difficulty)) {
s.ClearCookie(w)
- lg.Debug("difficulty check failed", "response", response, "difficulty", s.ChallengeDifficulty)
+ lg.Debug("difficulty check failed", "response", response, "difficulty", rule.Challenge.Difficulty)
templ.Handler(web.Base("Oh noes!", web.ErrorPage("invalid response")), templ.WithStatus(http.StatusForbidden)).ServeHTTP(w, r)
failedValidations.Inc()
return