From a5dac15262d5555e2f1b5b60a96e725467230508 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 6 Oct 2024 15:55:09 -0300 Subject: [PATCH] block more bots. --- block.go | 10 +++++++--- render_robots.go | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/block.go b/block.go index be21596..4cebf2a 100644 --- a/block.go +++ b/block.go @@ -20,6 +20,10 @@ func agentBlock(next http.HandlerFunc) http.HandlerFunc { "DotBot", "ClaudeBot", "GPTBot", + "bingbot", + "MJ12Bot", + "PetalBot", + "Applebot", } { if strings.Contains(ua, bua) { // log.Debug().Str("ua", ua).Msg("user-agent blocked") @@ -34,7 +38,7 @@ func agentBlock(next http.HandlerFunc) http.HandlerFunc { func ipBlock(next http.HandlerFunc) http.HandlerFunc { ranges := make([]*net.IPNet, 0, 18) - for _, line := range []string{ + for _, cidr := range []string{ // alicloud "47.52.0.0/16", "47.76.0.0/16", @@ -56,9 +60,9 @@ func ipBlock(next http.HandlerFunc) http.HandlerFunc { "172.64.0.0/13", "131.0.72.0/22", } { - _, ipnet, err := net.ParseCIDR(strings.TrimSpace(line)) + _, ipnet, err := net.ParseCIDR(cidr) if err != nil { - log.Error().Str("line", line).Err(err).Msg("failed to parse cloudflare ip range") + log.Error().Str("cidr", cidr).Err(err).Msg("failed to parse cloudflare ip range") continue } ranges = append(ranges, ipnet) diff --git a/render_robots.go b/render_robots.go index b59cf8d..4346417 100644 --- a/render_robots.go +++ b/render_robots.go @@ -23,6 +23,18 @@ Disallow: / User-agent: dotbot Disallow: / +User-agent: bingbot +Disallow: / + +User-agent: MJ12bot +Disallow: / + +User-agent: PetalBot +Disallow: / + +User-agent: Applebot +Disallow: / + User-agent: * Allow: /