aboutsummaryrefslogtreecommitdiff
path: root/cmd/anubis/main.go
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-02-14 13:39:34 -0500
committerXe Iaso <me@xeiaso.net>2025-02-14 13:39:34 -0500
commit1acc1602f2ff678c0e4bf49fa62345505ec0aa35 (patch)
treed2eec95941c9cd0a53f6de89cfde44222aa55940 /cmd/anubis/main.go
parent17c44496aaa77e8d0a499db8c044cb42ab00086b (diff)
downloadx-1acc1602f2ff678c0e4bf49fa62345505ec0aa35.tar.xz
x-1acc1602f2ff678c0e4bf49fa62345505ec0aa35.zip
cmd/anubis: enable DNSBL checking via dronebl
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd/anubis/main.go')
-rw-r--r--cmd/anubis/main.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go
index a15dba8..477fe50 100644
--- a/cmd/anubis/main.go
+++ b/cmd/anubis/main.go
@@ -30,6 +30,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"within.website/x"
"within.website/x/cmd/anubis/internal/config"
+ "within.website/x/cmd/anubis/internal/dnsbl"
"within.website/x/internal"
"within.website/x/xess"
)
@@ -213,6 +214,19 @@ func (s *Server) maybeReverseProxy(w http.ResponseWriter, r *http.Request) {
)
policyApplications.WithLabelValues(cr.Name, string(cr.Rule)).Add(1)
+ ip := r.Header.Get("X-Real-Ip")
+
+ if s.policy.DNSBL && ip != "" {
+ resp, err := dnsbl.Lookup(ip)
+ if err != nil {
+ lg.Error("can't look up ip in dnsbl", "err", err)
+ } else {
+ lg.Info("DNSBL hit", "status", resp.String())
+ templ.Handler(base("Oh noes!", errorPage(fmt.Sprintf("DroneBL reported an entry: %s, see https://dronebl.org/lookup?ip=%s", resp.String(), ip))), templ.WithStatus(http.StatusOK)).ServeHTTP(w, r)
+ return
+ }
+ }
+
switch cr.Rule {
case config.RuleAllow:
lg.Debug("allowing traffic to origin (explicit)")