Anubis module for Caddy

Add private_key option

Changed files
+18 -6
example
+11 -1
caddy_anubis.go
···
package caddy_anubis
import (
"fmt"
"log/slog"
"net"
···
})
m.Options.Policy = policy
m.anubis, err = libanubis.New(m.Options)
-
if err != nil {
return err
}
···
return d.ArgErr()
}
m.PolicyFname = d.Val()
}
} // anubis options
···
package caddy_anubis
import (
+
"crypto/ed25519"
+
"encoding/hex"
"fmt"
"log/slog"
"net"
···
})
m.Options.Policy = policy
m.anubis, err = libanubis.New(m.Options)
if err != nil {
return err
}
···
return d.ArgErr()
}
m.PolicyFname = d.Val()
+
case "private_key":
+
if !d.Next() {
+
return d.ArgErr()
+
}
+
seed, err := hex.DecodeString(d.Val())
+
if err != nil {
+
return d.WrapErr(err)
+
}
+
m.Options.ED25519PrivateKey = ed25519.NewKeyFromSeed(seed)
}
} // anubis options
+7 -5
example/Caddyfile
···
localhost {
@anubis {
-
# This matcher allows you to select specific paths for Anubis to handle.
# If you want to handle all paths, remove this block and use `anubis {...}` instead!
path / # don't let AI scrapers browse the file index
path /.within.website/* # required for anubis to work
···
}
log http.handlers.anubis {
-
level DEBUG
}
anubis @anubis {
-
# This setting gets overridden a lot by the default bot policy.
-
difficulty 4
-
# Custom bot policy
policy_fname example/botPolicy.yaml
# FIXME: required for OpenGraph passthrough!
## TODO: access upstream directly somehow?
···
localhost {
@anubis {
+
# This matcher allows you to select specific paths for Anubis to handle.
# If you want to handle all paths, remove this block and use `anubis {...}` instead!
path / # don't let AI scrapers browse the file index
path /.within.website/* # required for anubis to work
···
}
log http.handlers.anubis {
+
level DEBUG
}
anubis @anubis {
+
# This setting gets overridden a lot by the default bot policy.
+
difficulty 4
+
# Custom bot policy.
policy_fname example/botPolicy.yaml
+
+
private_key "a183a07283e86b669e30e153ad4f0c7a9e2bbc3218fc8fa9d6b858b29e97d22b"
# FIXME: required for OpenGraph passthrough!
## TODO: access upstream directly somehow?