Cleaning up

This commit is contained in:
Kyle Isom 2025-10-30 16:15:04 -07:00
parent 17e3eab464
commit 8b1e1b5d26
1 changed files with 3 additions and 3 deletions

View File

@ -48,7 +48,7 @@ func (CaddyHole) CaddyModule() caddy.ModuleInfo {
} }
// Provision sets up the CaddyHole module. // Provision sets up the CaddyHole module.
func (c *CaddyHole) Provision(ctx caddy.Context) error { func (c *CaddyHole) Provision(_ caddy.Context) error {
// Set defaults // Set defaults
if c.MinBotBytes == 0 { if c.MinBotBytes == 0 {
c.MinBotBytes = 1024 * 1024 // 1MB c.MinBotBytes = 1024 * 1024 // 1MB
@ -81,7 +81,7 @@ func (c *CaddyHole) Cleanup() error {
func (c *CaddyHole) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error { func (c *CaddyHole) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
// Check if the request is from a bot/crawler // Check if the request is from a bot/crawler
if c.isBot(r) { if c.isBot(r) {
c.feedBot(w, r) c.feedBot(w)
return nil return nil
} }
@ -117,7 +117,7 @@ func (c *CaddyHole) isBot(r *http.Request) bool {
} }
// feedBot sends random data from /dev/random to the bot. // feedBot sends random data from /dev/random to the bot.
func (c *CaddyHole) feedBot(w http.ResponseWriter, r *http.Request) { func (c *CaddyHole) feedBot(w http.ResponseWriter) {
// Calculate random amount of bytes to send // Calculate random amount of bytes to send
bytesToSend := c.MinBotBytes bytesToSend := c.MinBotBytes
if c.MaxBotBytes > c.MinBotBytes { if c.MaxBotBytes > c.MinBotBytes {