Anubis module for Caddy
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

wa

Kot 4e98aabc ef72e3ca

+11 -7
+10 -2
caddy_anubis.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 + "log/slog" 5 6 "net" 6 7 "net/http" 7 8 "strconv" ··· 13 14 "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" 14 15 "github.com/caddyserver/caddy/v2/modules/caddyhttp" 15 16 "go.uber.org/zap" 17 + "go.uber.org/zap/exp/zapslog" 16 18 ) 17 19 18 20 func init() { ··· 48 50 func (m *AnubisMiddleware) Provision(ctx caddy.Context) error { 49 51 m.log = ctx.Logger(m) 50 52 51 - // slog.SetLogLoggerLevel(slog.LevelDebug) // TODO: customizable log level 53 + // TODO: figure out a better level for this 54 + zs := zapslog.NewHandler(m.log.Core(), zapslog.AddStacktraceAt(slog.LevelError + 1)) 55 + 56 + // TODO: don't set the global slog logger 57 + // currently, anubis does not allow custom loggers (https://github.com/TecharoHQ/anubis/issues/864) 58 + sl := slog.New(zs) 59 + slog.SetDefault(sl) 52 60 53 61 m.log.Debug("loading anubis policies", zap.String("policy_file", m.PolicyFname), zap.Int("default_difficulty", m.DefaultDifficulty)) 54 62 policy, err := libanubis.LoadPoliciesOrDefault(ctx, m.PolicyFname, m.DefaultDifficulty) ··· 89 97 90 98 m.DefaultDifficulty = anubis.DefaultDifficulty 91 99 m.Options.CookieExpiration = anubis.CookieDefaultExpirationTime 92 - m.Options.CookieSecure = true // TODO: temporary 100 + m.Options.CookieSecure = true // TODO: set this only on https upstreams 93 101 94 102 for nesting := d.Nesting(); d.NextBlock(nesting); { 95 103 var err error
-4
example/Caddyfile
··· 1 1 localhost { 2 - log { 3 - level debug 4 - } 5 - 6 2 @anubis { 7 3 # This matcher allows you to select specific paths for Anubis to handle. 8 4 # If you want to handle all paths, remove this block and use `anubis {...}` instead!
+1 -1
go.mod
··· 118 118 go.uber.org/automaxprocs v1.6.0 // indirect 119 119 go.uber.org/mock v0.5.0 // indirect 120 120 go.uber.org/multierr v1.11.0 // indirect 121 - go.uber.org/zap/exp v0.3.0 // indirect 121 + go.uber.org/zap/exp v0.3.0 122 122 go.yaml.in/yaml/v2 v2.4.2 // indirect 123 123 golang.org/x/crypto v0.40.0 // indirect 124 124 golang.org/x/crypto/x509roots/fallback v0.0.0-20250305170421-49bf5b80c810 // indirect